MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
bufferstreamdrive.cc File Reference
#include "mbconfig.h"
#include <sstream>
#include "dataman.h"
#include "filedrv.h"
#include "streamdrive.h"
#include "bufferstreamdrive.h"
Include dependency graph for bufferstreamdrive.cc:

Go to the source code of this file.

Functions

static DriveReadBufferStreamDrive (const DataManager *pDM, MBDynParser &HP, unsigned uLabel)
 

Function Documentation

static Drive* ReadBufferStreamDrive ( const DataManager pDM,
MBDynParser HP,
unsigned  uLabel 
)
static

Definition at line 221 of file bufferstreamdrive.cc.

References ASSERT, HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::GetReal(), HighParser::GetYesNoOrBool(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, DataManager::pGetDrvHdl(), ReadStreamDriveEcho(), ReadStreamDriveModifier(), SAFENEWWITHCONSTRUCTOR, and v0.

Referenced by BufferStreamDR::Read().

222 {
223  enum {
224  STL,
225  RAW
226  } eType = STL;
227  bool bOwnsMemory(true);
228 
229  if (HP.IsKeyWord("type")) {
230  if (HP.IsKeyWord("raw")) {
231  eType = RAW;
232  if (HP.IsKeyWord("owns" "memory")) {
233  bOwnsMemory = HP.GetYesNoOrBool();
234  }
235 
236  } else if (!HP.IsKeyWord("stl")) {
237  silent_cerr("BufferStreamDrive"
238  "(" << uLabel << "\"): "
239  "invalid type at line " << HP.GetLineData()
240  << std::endl);
242  }
243  }
244 
245  unsigned int InputEvery = 1;
246  if (HP.IsKeyWord("input" "every")) {
247  int i = HP.GetInt();
248  if (i <= 0) {
249  silent_cerr("BufferStreamDrive"
250  "(" << uLabel << "\"): "
251  "invalid \"input every\" value " << i
252  << " at line " << HP.GetLineData()
253  << std::endl);
255  }
256  InputEvery = (unsigned int)i;
257  }
258 
259  StreamDriveEcho *pSDE = ReadStreamDriveEcho(pDM, HP);
260 
261  int idrives = HP.GetInt();
262  if (idrives <= 0) {
263  silent_cerr("BufferStreamDrive"
264  "(" << uLabel << "\"): "
265  "illegal number of channels " << idrives
266  << " at line " << HP.GetLineData()
267  << std::endl);
269  }
270 
271  std::vector<doublereal> v0;
272  if (HP.IsKeyWord("initial" "values")) {
273  v0.resize(idrives);
274  for (int i = 0; i < idrives; i++) {
275  v0[i] = HP.GetReal();
276  }
277  }
278 
279  StreamDrive::Modifier *pMod(0);
280  if (HP.IsKeyWord("modifier")) {
281  pMod = ReadStreamDriveModifier(HP, idrives);
282  }
283 
284  Drive* pDr = 0;
285  switch (eType) {
286  case STL:
288  BufferStreamDrive(uLabel,
289  pDM->pGetDrvHdl(),
290  idrives, v0, pMod,
291  InputEvery, pSDE));
292  break;
293 
294  case RAW:
296  BufferStreamDriveRaw(uLabel,
297  pDM->pGetDrvHdl(),
298  idrives, v0, pMod,
299  InputEvery, pSDE, bOwnsMemory));
300  break;
301 
302  default:
303  ASSERT(0);
304  break;
305  }
306 
307  return pDr;
308 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
Definition: drive.h:89
StreamDriveEcho * ReadStreamDriveEcho(const DataManager *pDM, MBDynParser &HP)
Definition: streamdrive.cc:280
StreamDrive::Modifier * ReadStreamDriveModifier(MBDynParser &HP, integer nDrives)
Definition: streamdrive.cc:169
const DriveHandler * pGetDrvHdl(void) const
Definition: dataman.h:340
virtual bool GetYesNoOrBool(bool bDefval=false)
Definition: parser.cc:1038
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function: