MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
socketstreamdrive.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/socketstreamdrive.h,v 1.37 2017/09/09 09:18:21 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 /*
33  * Author: Michele Attolico <attolico@aero.polimi.it>
34  */
35 
36 /* socket driver */
37 
38 #ifndef SOCKETSTREAMDRIVE_H
39 #define SOCKETSTREAMDRIVE_H
40 
41 #include "streamdrive.h"
42 
43 #ifdef USE_SOCKET
44 
45 #include "usesock.h"
46 
47 /* SocketStreamDrive - begin */
48 
49 class SocketStreamDrive : public StreamDrive {
50 protected:
51  unsigned int InputEvery;
52  bool bReceiveFirst;
53  unsigned int InputCounter;
54 
55  UseSocket *pUS;
56  int recv_flags;
57  struct timeval SocketTimeout;
58 
59  StreamDriveEcho *pSDE;
60 
61 public:
62  SocketStreamDrive(unsigned int uL,
63  const DriveHandler* pDH,
64  UseSocket *pUS, bool c,
65  const std::string& sFileName,
66  integer nd, const std::vector<doublereal>& v0,
68  unsigned int ie, bool bReceiveFirst,
69  int flags,
70  const struct timeval& st,
71  StreamDriveEcho *pSDE);
72 
73  virtual ~SocketStreamDrive(void);
74 
75  /* Scrive il contributo del DriveCaller al file di restart */
76  virtual std::ostream& Restart(std::ostream& out) const;
77 
78  virtual void ServePending(const doublereal& t);
79 };
80 
81 /* SocketStreamDrive - end */
82 
83 #endif // USE_SOCKET
84 
85 class DataManager;
86 class MBDynParser;
87 
88 struct StreamDR : public DriveRead {
89 private:
90  std::string s;
91 
92 public:
93  StreamDR(void) { NO_OP; };
94  StreamDR(const std::string &s) : s(s) { NO_OP; };
95 
96  virtual Drive *
97  Read(unsigned uLabel, const DataManager *pDM, MBDynParser& HP);
98 };
99 
100 /* Luca Conti edits - GSOC 2017 */
101 
102 /* file drive content type reader: every content type must inherit
103 from this struct and implement its own Read method */
105  virtual StreamDrive::Modifier * Read(std::vector<doublereal> &v0, MBDynParser& HP, int &idrives) = 0;
106  virtual ~FileDriveContentTypeReader(void) { NO_OP; };
107 };
108 /* bag of content-type readers - every content type is registered inside
109 of it by using SetFileDriveContentType(...) */
110 typedef std::map<std::string,FileDriveContentTypeReader*> FileDriveContentTypeMap;
112 
114  virtual bool IsWord(const std::string& s) const;
115 };
117 
118 /* registration function: call it to register a new content type */
119 bool SetFileDriveContentType(const char *name, FileDriveContentTypeReader *rf);
120 
121 /* deallocation of all content types in fileDriveContentTypeMap, if any was added */
123 
124 #endif /* SOCKETSTREAMDRIVE_H */
virtual bool IsWord(const std::string &s) const
FileDriveContentTypeWordSetType fileDriveContentTypeWordSet
std::string s
virtual std::ostream & Restart(std::ostream &out) const =0
Definition: drive.h:89
StreamDR(const std::string &s)
virtual void ServePending(const doublereal &t)=0
#define NO_OP
Definition: myassert.h:74
FileDriveContentTypeMap fileDriveContentTypeMap
void DestroyFileDriveContentTypes(void)
bool SetFileDriveContentType(const char *name, FileDriveContentTypeReader *rf)
virtual Drive * Read(unsigned uLabel, const DataManager *pDM, MBDynParser &HP)
virtual ~FileDriveContentTypeReader(void)
std::map< std::string, FileDriveContentTypeReader * > FileDriveContentTypeMap
static std::stack< cleanup * > c
Definition: cleanup.cc:59
virtual StreamDrive::Modifier * Read(std::vector< doublereal > &v0, MBDynParser &HP, int &idrives)=0
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51