MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
BufferStreamDrive_base Class Referenceabstract

#include <bufferstreamdrive.h>

Inheritance diagram for BufferStreamDrive_base:
Collaboration diagram for BufferStreamDrive_base:

Public Member Functions

 BufferStreamDrive_base (unsigned int uL, const DriveHandler *pDH, integer nd, const std::vector< doublereal > &v0, StreamDrive::Modifier *pMod, unsigned int ie, StreamDriveEcho *pSDE)
 
virtual ~BufferStreamDrive_base (void)
 
const integer GetBufSize (void) const
 
virtual const doublerealGetBufRaw (void)=0
 
virtual void ServePending (const doublereal &t)
 
- Public Member Functions inherited from StreamDrive
 StreamDrive (unsigned int uL, const DriveHandler *pDH, const std::string &sFileName, integer nd, const std::vector< doublereal > &v0, bool c, StreamDrive::Modifier *pmod)
 
virtual ~StreamDrive (void)
 
void SetModifier (const Modifier *p)
 
const StreamDrive::ModifierpGetModifier (void) const
 
- Public Member Functions inherited from FileDrive
 FileDrive (unsigned int uL, const DriveHandler *pDH, const std::string &s, integer nd, const std::vector< doublereal > &v0)
 
virtual ~FileDrive (void)
 
virtual Drive::Type GetDriveType (void) const
 
virtual std::ostream & Restart (std::ostream &out) const =0
 
virtual integer iGetNumDrives (void) const
 
virtual doublereal dGet (const doublereal &t, int i=1) const
 
- Public Member Functions inherited from Drive
 Drive (unsigned int uL, const DriveHandler *pDH)
 
virtual ~Drive (void)
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 

Protected Attributes

unsigned int InputEvery
 
unsigned int InputCounter
 
StreamDriveEchopSDE
 
- Protected Attributes inherited from StreamDrive
int size
 
std::vector< char > buf
 
bool create
 
const ModifierpMod
 
- Protected Attributes inherited from FileDrive
std::string sFileName
 
integer iNumDrives
 
doublerealpdVal
 
- Protected Attributes inherited from Drive
const DriveHandlerpDrvHdl
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 

Additional Inherited Members

- Public Types inherited from Drive
enum  Type { UNKNOWN = -1, FILEDRIVE = 0, LASTDRIVETYPE }
 
enum  Bailout { BO_NONE = 0x0, BO_UPPER = 0x1, BO_LOWER = 0x2, BO_ANY = (BO_UPPER | BO_LOWER) }
 
- Static Protected Attributes inherited from Drive
static doublereal dReturnValue = 0.
 

Detailed Description

Definition at line 41 of file bufferstreamdrive.h.

Constructor & Destructor Documentation

BufferStreamDrive_base::BufferStreamDrive_base ( unsigned int  uL,
const DriveHandler pDH,
integer  nd,
const std::vector< doublereal > &  v0,
StreamDrive::Modifier pMod,
unsigned int  ie,
StreamDriveEcho pSDE 
)

Definition at line 41 of file bufferstreamdrive.cc.

References ASSERT, StreamDriveEcho::Init(), InputCounter, InputEvery, and WithLabel::uLabel.

47 : StreamDrive(uL, pDH, "buffer", nd, v0, true, pMod),
48 InputEvery(ie), InputCounter(ie - 1),
49 pSDE(pSDE)
50 {
51  // NOTE: InputCounter is set to InputEvery - 1 so that input
52  // is expected at initialization (initial time) and then every
53  // InputEvery steps; for example, for InputEvery == 4, input
54  // is expected at:
55  // initial time
56  // initial time + 4 * timestep
57  // initial time + 8 * timestep
58  ASSERT(InputEvery > 0);
59 
61 
62  if (pSDE != 0) {
63  pSDE->Init("BufferStreamDrive_base", uLabel, nd);
64  }
65 }
StreamDriveEcho * pSDE
unsigned int uLabel
Definition: withlab.h:44
#define ASSERT(expression)
Definition: colamd.c:977
bool Init(const std::string &msg, unsigned uLabel, unsigned nChannels)
Definition: streamdrive.cc:223
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
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

Here is the call graph for this function:

BufferStreamDrive_base::~BufferStreamDrive_base ( void  )
virtual

Definition at line 67 of file bufferstreamdrive.cc.

References pSDE.

68 {
69  if (pSDE != 0) {
70  delete pSDE;
71  }
72 }
StreamDriveEcho * pSDE

Member Function Documentation

virtual const doublereal* BufferStreamDrive_base::GetBufRaw ( void  )
pure virtual
const integer BufferStreamDrive_base::GetBufSize ( void  ) const

Definition at line 75 of file bufferstreamdrive.cc.

References FileDrive::iNumDrives.

76 {
77  return iNumDrives;
78 }
integer iNumDrives
Definition: filedrv.h:47
void BufferStreamDrive_base::ServePending ( const doublereal t)
virtual

Implements Drive.

Definition at line 81 of file bufferstreamdrive.cc.

References StreamDriveEcho::Echo(), StreamDriveEcho::EchoPrepare(), GetBufRaw(), InputCounter, InputEvery, FileDrive::iNumDrives, StreamDrive::Modifier::Modify(), FileDrive::pdVal, StreamDrive::pMod, and pSDE.

82 {
83  /* read only every InputEvery steps */
84  InputCounter++;
85  if (InputCounter != InputEvery) {
86  return;
87  }
88  InputCounter = 0;
89 
90  if (pSDE != 0) {
92  }
93 
94  // copy values from buffer
95  pMod->Modify(&pdVal[1], GetBufRaw());
96 
97  if (pSDE != 0) {
98  pSDE->Echo(&pdVal[1], iNumDrives);
99  }
100 }
StreamDriveEcho * pSDE
integer iNumDrives
Definition: filedrv.h:47
void Echo(const doublereal *pbuf, unsigned nChannels)
Definition: streamdrive.cc:264
doublereal * pdVal
Definition: filedrv.h:48
virtual void Modify(doublereal *out, const void *in) const =0
void EchoPrepare(const doublereal *pbuf, unsigned nChannels)
Definition: streamdrive.cc:256
virtual const doublereal * GetBufRaw(void)=0
const Modifier * pMod
Definition: streamdrive.h:69

Here is the call graph for this function:

Member Data Documentation

unsigned int BufferStreamDrive_base::InputCounter
protected

Definition at line 44 of file bufferstreamdrive.h.

Referenced by BufferStreamDrive_base(), and ServePending().

unsigned int BufferStreamDrive_base::InputEvery
protected

Definition at line 43 of file bufferstreamdrive.h.

Referenced by BufferStreamDrive_base(), and ServePending().

StreamDriveEcho* BufferStreamDrive_base::pSDE
protected

Definition at line 46 of file bufferstreamdrive.h.

Referenced by ServePending(), and ~BufferStreamDrive_base().


The documentation for this class was generated from the following files: