MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
streamdrive.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/streamdrive.h,v 1.21 2017/08/28 10:34:39 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 /* socket driver */
33 
34 #ifndef STREAMDRIVE_H
35 #define STREAMDRIVE_H
36 
37 #include "filedrv.h"
38 #include "bufmod.h"
39 
40 /* StreamDrive - begin */
41 
42 class StreamDrive : public FileDrive {
43 public:
44  class Modifier {
45  public:
46  Modifier(void);
47  virtual ~Modifier(void);
48  virtual size_t GetSize(void) const = 0;
49  virtual void Modify(doublereal *out, const void *in) const = 0;
50  };
51 
52  class Copy : public StreamDrive::Modifier {
53  protected:
55 
56  public:
57  Copy(integer iND);
58  size_t GetSize(void) const;
59  void Modify(doublereal *out, const void *in) const;
60  };
61 
62 protected:
63  /* MBox buffer */
64  int size;
65  std::vector<char> buf;
66 
67  bool create;
68 
69  const Modifier *pMod;
70 
71 public:
72  StreamDrive(unsigned int uL,
73  const DriveHandler* pDH,
74  const std::string& sFileName,
75  integer nd, const std::vector<doublereal>& v0,
76  bool c, StreamDrive::Modifier *pmod);
77 
78  virtual ~StreamDrive(void);
79  void SetModifier(const Modifier *p);
80  const StreamDrive::Modifier *pGetModifier(void) const;
81 };
82 
83 extern StreamDrive::Modifier *
85 
86 /* StreamDrive - end */
87 
88 /* StreamDriveEcho - begin */
89 
91 private:
93  std::string sOutFileName;
94  std::vector<doublereal> echoBuf;
95  std::ofstream outFile;
98 
99 public:
101  ~StreamDriveEcho(void);
102  bool bIsEcho(void) const;
103  bool Init(const std::string& msg, unsigned uLabel, unsigned nChannels);
104  void EchoPrepare(const doublereal *pbuf, unsigned nChannels);
105  void Echo(const doublereal *pbuf, unsigned nChannels);
106 };
107 
108 extern StreamDriveEcho *
110 
111 /* StreamDriveEcho - end */
112 
114 {
115 protected:
116  size_t m_size;
117  std::vector<BufCast *> m_data;
118 
119 public:
120  StreamDriveCopyCast(size_t size, const std::vector<BufCast *>& data);
121  ~StreamDriveCopyCast(void);
122 
123  size_t GetSize(void) const;
124  void Modify(doublereal *out, const void *in) const;
125 };
126 
127 #endif // STREAMDRIVE_H
size_t GetSize(void) const
Definition: streamdrive.cc:102
const DriveHandler * pDrvHdl
Definition: streamdrive.h:92
Copy(integer iND)
Definition: streamdrive.cc:95
~StreamDriveEcho(void)
Definition: streamdrive.cc:217
std::vector< BufCast * > m_data
Definition: streamdrive.h:117
std::vector< char > buf
Definition: streamdrive.h:65
void Modify(doublereal *out, const void *in) const
Definition: streamdrive.cc:108
std::string sFileName
Definition: filedrv.h:46
void Echo(const doublereal *pbuf, unsigned nChannels)
Definition: streamdrive.cc:264
StreamDriveEcho * ReadStreamDriveEcho(const DataManager *pDM, MBDynParser &HP)
Definition: streamdrive.cc:280
std::vector< doublereal > echoBuf
Definition: streamdrive.h:94
virtual size_t GetSize(void) const =0
virtual ~StreamDrive(void)
Definition: streamdrive.cc:62
virtual ~Modifier(void)
Definition: streamdrive.cc:90
const StreamDrive::Modifier * pGetModifier(void) const
Definition: streamdrive.cc:80
void Modify(doublereal *out, const void *in) const
Definition: streamdrive.cc:159
virtual void Modify(doublereal *out, const void *in) const =0
void EchoPrepare(const doublereal *pbuf, unsigned nChannels)
Definition: streamdrive.cc:256
static std::stack< cleanup * > c
Definition: cleanup.cc:59
std::ofstream outFile
Definition: streamdrive.h:95
bool Init(const std::string &msg, unsigned uLabel, unsigned nChannels)
Definition: streamdrive.cc:223
StreamDriveEcho(const DriveHandler *pDrvHdl, std::string &sOutFileName, int iPrecision, doublereal dShift)
Definition: streamdrive.cc:208
size_t GetSize(void) const
Definition: streamdrive.cc:153
struct mbrtai_msg_t msg
std::string sOutFileName
Definition: streamdrive.h:93
StreamDriveCopyCast(size_t size, const std::vector< BufCast * > &data)
Definition: streamdrive.cc:136
StreamDrive::Modifier * ReadStreamDriveModifier(MBDynParser &HP, integer nDrives)
Definition: streamdrive.cc:169
doublereal dShift
Definition: streamdrive.h:97
bool bIsEcho(void) const
void SetModifier(const Modifier *p)
Definition: streamdrive.cc:70
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
const Modifier * pMod
Definition: streamdrive.h:69
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
StreamDrive(unsigned int uL, const DriveHandler *pDH, const std::string &sFileName, integer nd, const std::vector< doublereal > &v0, bool c, StreamDrive::Modifier *pmod)
Definition: streamdrive.cc:42