MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
streamoutelem.cc File Reference
#include "mbconfig.h"
#include "dataman.h"
#include "streamoutelem.h"
#include "geomdata.h"
#include "socketstream_out_elem.h"
#include "bufferstream_out_elem.h"
#include "socketstreammotionelem.h"
#include "bufmod.h"
Include dependency graph for streamoutelem.cc:

Go to the source code of this file.

Functions

StreamContent::ModifierReadStreamContentModifier (MBDynParser &HP, integer nCh)
 
StreamOutEchoReadStreamOutEcho (MBDynParser &HP)
 
ElemReadOutputElem (DataManager *pDM, MBDynParser &HP, unsigned int uLabel, StreamOutElem::Type eType, StreamContent::Type sType)
 
StreamContentReadStreamContent (DataManager *pDM, MBDynParser &HP, StreamContent::Type type)
 
bool SetStreamOutputContentType (const char *name, StreamOutputContentTypeReader *rf)
 
void InitStreamOutputContentTypes (void)
 
void DestroyStreamOutputContentTypes (void)
 

Variables

StreamOutputContentTypeMap streamOutputContentTypeMap
 
StreamOutputContentTypeWordSetType streamOutputContentTypeWordSet
 
unsigned streamOutputInitFunctionCalls = 0
 

Function Documentation

void DestroyStreamOutputContentTypes ( void  )

Definition at line 762 of file streamoutelem.cc.

References MBDYN_EXCEPT_ARGS.

Referenced by MBDynParser::~MBDynParser().

762  {
764  silent_cerr("DestroyStreamOutputContentTypes() called once too many" << std::endl);
766  }
767 
768  if (--streamOutputInitFunctionCalls > 0) {
769  return;
770  }
771 
772  /* empties all of the content types contained in streamOutputContentTypeMap*/
773  for (StreamOutputContentTypeMap::iterator i = streamOutputContentTypeMap.begin(); i != streamOutputContentTypeMap.end(); ++i) {
774  delete i->second;
775  }
777  }
unsigned streamOutputInitFunctionCalls
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
StreamOutputContentTypeMap streamOutputContentTypeMap
void InitStreamOutputContentTypes ( void  )

Definition at line 753 of file streamoutelem.cc.

References SetStreamOutputContentType().

Referenced by MBDynParser::MBDynParser().

753  {
755  return;
756 
757  /* loads default content types */
760  }
unsigned streamOutputInitFunctionCalls
bool SetStreamOutputContentType(const char *name, StreamOutputContentTypeReader *rf)

Here is the call graph for this function:

Elem* ReadOutputElem ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel,
StreamOutElem::Type  eType,
StreamContent::Type  sType 
)

Definition at line 562 of file streamoutelem.cc.

References StreamOutElem::BUFFERSTREAM, IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, ReadBufferStreamElem(), ReadSocketStreamElem(), StreamOutElem::SOCKETSTREAM, StreamOutElem::UNDEFINED, and StreamContent::UNKNOWN.

Referenced by DataManager::ReadOneElem().

563 {
564  Elem *pE(0);
565 
566  if (eType == StreamOutElem::UNDEFINED) {
567  sType = StreamContent::UNKNOWN;
568 
569  if (HP.IsKeyWord("socket" "stream")) {
571 
572  } else if (HP.IsKeyWord("buffer" "stream")) {
574 
575  } else {
576  silent_cerr("ReadOutputElem(" << uLabel << "): "
577  "unknown \"type\" at line " << HP.GetLineData() << std::endl);
579  }
580  }
581 
582  switch (eType) {
584  pE = ReadSocketStreamElem(pDM, HP, uLabel, sType);
585  break;
586 
588  pE = ReadBufferStreamElem(pDM, HP, uLabel, sType);
589  break;
590 
591  default:
593  }
594 
595  return pE;
596 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
Elem * ReadSocketStreamElem(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, StreamContent::Type type)
Definition: elem.h:75
Elem * ReadBufferStreamElem(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, StreamContent::Type type)
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

StreamContent* ReadStreamContent ( DataManager pDM,
MBDynParser HP,
StreamContent::Type  type 
)

Definition at line 614 of file streamoutelem.cc.

References IncludeParser::GetLineData(), HighParser::IsWord(), and MBDYN_EXCEPT_ARGS.

Referenced by ReadBufferStreamElem(), and ReadSocketStreamElem().

614  {
615  //searches in the bag the content type found in MBDyn input file
616  const char *s = HP.IsWord(streamOutputContentTypeWordSet);
617 
618  StreamOutputContentTypeMap::iterator it = streamOutputContentTypeMap.find(std::string(s));
619  if (it == streamOutputContentTypeMap.end()) {
620  silent_cerr("[streamoutelem.cc] ReadStreamContent:unknown stream output content type "
621  "\"" << s << "\" "
622  "at line " << HP.GetLineData() << std::endl);
624  }
625  return it->second->Read(pDM, HP);
626 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual const char * IsWord(const HighParser::WordSet &ws)
Definition: parser.cc:977
StreamOutputContentTypeMap streamOutputContentTypeMap
StreamOutputContentTypeWordSetType streamOutputContentTypeWordSet
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

StreamContent::Modifier* ReadStreamContentModifier ( MBDynParser HP,
integer  nCh 
)

Definition at line 274 of file streamoutelem.cc.

References HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, and ReadBufCast().

Referenced by ValuesContentTypeReader::Read().

275 {
276  StreamContent::Modifier *pSCM(0);
277 
278  if (HP.IsKeyWord("copy" "cast")) {
279  std::vector<BufCast *> data(nCh);
280  ReadBufCast(HP, data);
281  size_t minsize = data[data.size() - 1]->offset() + data[data.size() - 1]->size();
282  size_t size = minsize;
283  if (HP.IsKeyWord("size")) {
284  integer i = HP.GetInt();
285  if (i <= 0) {
286  silent_cerr("ReadStreamContentModifier: invalid size " << i
287  << " at line " << HP.GetLineData() << std::endl);
289  }
290 
291  size = size_t(i);
292  if (size < minsize) {
293  silent_cerr("ReadStreamContentModifier: size " << size
294  << " is less than min size " << minsize
295  << " at line " << HP.GetLineData() << std::endl);
297  }
298  }
299 
300  pSCM = new StreamContentCopyCast(0, 0, size, data);
301 
302  } else if (!HP.IsKeyWord("copy")) {
303  silent_cerr("ReadStreamContentModifier: unknown modifier type at line " << HP.GetLineData() << std::endl);
305  }
306 
307  return pSCM;
308 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
void ReadBufCast(HighParser &HP, std::vector< BufCast * > &data)
Definition: bufmod.cc:287
long int integer
Definition: colamd.c:51
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

StreamOutEcho* ReadStreamOutEcho ( MBDynParser HP)

Definition at line 518 of file streamoutelem.cc.

References IncludeParser::GetFileName(), HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::GetReal(), HighParser::IsKeyWord(), and MBDYN_EXCEPT_ARGS.

Referenced by ReadBufferStreamElem(), and ReadSocketStreamElem().

519 {
520  StreamOutEcho *pSOE(0);
521 
522  std::string sOutFileName;
523  int iPrecision = -1;
524  doublereal dShift = 0.;
525 
526  if (HP.IsKeyWord("echo")) {
527  const char *s = HP.GetFileName();
528  if (s == NULL) {
529  silent_cerr("ReadStreamOutEcho: "
530  "unable to parse echo file name "
531  "at line " << HP.GetLineData()
532  << std::endl);
534  }
535 
536  sOutFileName = s;
537 
538  if (HP.IsKeyWord("precision")) {
539  iPrecision = HP.GetInt();
540  if (iPrecision <= 0) {
541  silent_cerr("ReadStreamOutEcho: "
542  "invalid echo precision " << iPrecision
543  << " at line " << HP.GetLineData()
544  << std::endl);
546  }
547  }
548 
549  if (HP.IsKeyWord("shift")) {
550  dShift = HP.GetReal();
551  }
552 
553  pSOE = new StreamOutEcho(sOutFileName, iPrecision, dShift);
554  }
555 
556  return pSOE;
557 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Definition: parsinc.cc:673
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
double doublereal
Definition: colamd.c:52
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:

bool SetStreamOutputContentType ( const char *  name,
StreamOutputContentTypeReader rf 
)

Definition at line 746 of file streamoutelem.cc.

Referenced by InitStreamOutputContentTypes(), and module_init().

746  {
747  pedantic_cout("registering stream output content type \"" << name << "\""
748  << std::endl );
749  return streamOutputContentTypeMap.insert(StreamOutputContentTypeMap::value_type(name, rf)).second;
750  }
StreamOutputContentTypeMap streamOutputContentTypeMap

Variable Documentation

StreamOutputContentTypeMap streamOutputContentTypeMap

Definition at line 609 of file streamoutelem.cc.

StreamOutputContentTypeWordSetType streamOutputContentTypeWordSet

Definition at line 610 of file streamoutelem.cc.

unsigned streamOutputInitFunctionCalls = 0

Definition at line 611 of file streamoutelem.cc.