MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
SwitchDriveCaller Class Reference
Inheritance diagram for SwitchDriveCaller:
Collaboration diagram for SwitchDriveCaller:

Public Types

enum  Type { SDC_FLOOR, SDC_CEIL, SDC_NEAREST }
 
- Public Types inherited from DriveCaller
enum  OutputFlags { OUTPUT_VALUE = OUTPUT_PRIVATE << 0, OUTPUT_DERIVATIVE = OUTPUT_PRIVATE << 1 }
 
enum  TraceFlags { TRACE_VALUE = TRACE_PRIVATE << 0, TRACE_DERIVATIVE = TRACE_PRIVATE << 1 }
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from Traceable
enum  { TRACE = 0x01U, TRACE_PUBLIC_MASK = 0x0FU, TRACE_PRIVATE = 0x10U, TRACE_PRIVATE_MASK = ~TRACE_PUBLIC_MASK }
 

Public Member Functions

 SwitchDriveCaller (const DriveHandler *pDH, const DriveOwner &oSwitch, Type eType, const std::vector< DriveOwner > &drives)
 
virtual ~SwitchDriveCaller ()
 
bool bIsDifferentiable (void) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
doublereal dGet (const doublereal &dVar) const
 
virtual doublereal dGetP (const doublereal &dVar) const
 
DriveCallerpCopy (void) const
 
- Public Member Functions inherited from DriveCaller
 DriveCaller (const DriveHandler *pDH)
 
virtual ~DriveCaller (void)
 
virtual doublereal dGet (void) const
 
virtual doublereal dGetP (void) const
 
virtual void SetDrvHdl (const DriveHandler *pDH)
 
virtual const DriveHandlerpGetDrvHdl (void) const
 
virtual void Output (OutputHandler &OH) const
 
virtual void Trace (OutputHandler &OH) const
 
- 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
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from Traceable
 Traceable (flag fTrace=0)
 
virtual ~Traceable (void)
 
virtual flag fToBeTraced (void) const
 
virtual void SetTraceFlag (flag f=TRACE)
 

Private Types

typedef std::vector
< DriveOwner >::const_iterator 
iterator
 

Private Member Functions

const DriveCallerpGetDrive () const
 

Private Attributes

DriveOwner oSwitch
 
Type eType
 
const std::vector< DriveOwnerrgDrives
 

Additional Inherited Members

- Protected Attributes inherited from DriveCaller
DriveHandlerpDrvHdl
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 

Detailed Description

Definition at line 56 of file module-switch_drive.cc.

Member Typedef Documentation

typedef std::vector<DriveOwner>::const_iterator SwitchDriveCaller::iterator
private

Definition at line 81 of file module-switch_drive.cc.

Member Enumeration Documentation

Enumerator
SDC_FLOOR 
SDC_CEIL 
SDC_NEAREST 

Definition at line 59 of file module-switch_drive.cc.

Constructor & Destructor Documentation

SwitchDriveCaller::SwitchDriveCaller ( const DriveHandler pDH,
const DriveOwner oSwitch,
Type  eType,
const std::vector< DriveOwner > &  drives 
)
explicit

Definition at line 90 of file module-switch_drive.cc.

References NO_OP.

Referenced by pCopy().

94 : DriveCaller(pDH),
95  oSwitch(oSwitch),
96  eType(eType),
97  rgDrives(drives)
98 {
99  NO_OP;
100 }
#define NO_OP
Definition: myassert.h:74
DriveCaller(const DriveHandler *pDH)
Definition: drive.cc:475
const std::vector< DriveOwner > rgDrives
SwitchDriveCaller::~SwitchDriveCaller ( )
virtual

Definition at line 102 of file module-switch_drive.cc.

References NO_OP.

103 {
104  NO_OP;
105 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

bool SwitchDriveCaller::bIsDifferentiable ( void  ) const
virtual

Reimplemented from DriveCaller.

Definition at line 157 of file module-switch_drive.cc.

References rgDrives.

158 {
159  for (iterator i = rgDrives.begin(); i != rgDrives.end(); ++i) {
160  if (!i->bIsDifferentiable()) {
161  return false;
162  }
163  }
164 
165  return true;
166 }
const std::vector< DriveOwner > rgDrives
std::vector< DriveOwner >::const_iterator iterator
doublereal SwitchDriveCaller::dGet ( const doublereal dVar) const
virtual

Implements DriveCaller.

Definition at line 147 of file module-switch_drive.cc.

References DriveCaller::dGet(), and pGetDrive().

148 {
149  return pGetDrive()->dGet(dVar);
150 }
const DriveCaller * pGetDrive() const
virtual doublereal dGet(const doublereal &dVar) const =0

Here is the call graph for this function:

doublereal SwitchDriveCaller::dGetP ( const doublereal dVar) const
virtual

Reimplemented from DriveCaller.

Definition at line 152 of file module-switch_drive.cc.

References DriveCaller::dGetP(), and pGetDrive().

153 {
154  return pGetDrive()->dGetP(dVar);
155 }
const DriveCaller * pGetDrive() const
virtual doublereal dGetP(const doublereal &dVar) const
Definition: drive.cc:499

Here is the call graph for this function:

DriveCaller * SwitchDriveCaller::pCopy ( void  ) const
virtual

Implements DriveCaller.

Definition at line 188 of file module-switch_drive.cc.

References eType, oSwitch, DriveCaller::pGetDrvHdl(), rgDrives, SAFENEWWITHCONSTRUCTOR, and SwitchDriveCaller().

189 {
190  DriveCaller* pDC = 0;
191 
195 
196  return pDC;
197 }
virtual const DriveHandler * pGetDrvHdl(void) const
Definition: drive.cc:493
SwitchDriveCaller(const DriveHandler *pDH, const DriveOwner &oSwitch, Type eType, const std::vector< DriveOwner > &drives)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
const std::vector< DriveOwner > rgDrives

Here is the call graph for this function:

const DriveCaller * SwitchDriveCaller::pGetDrive ( ) const
private

Definition at line 107 of file module-switch_drive.cc.

References ASSERT, DriveOwner::dGet(), eType, WithLabel::GetLabel(), MBDYN_EXCEPT_ARGS, oSwitch, DriveOwner::pGetDriveCaller(), rgDrives, SDC_CEIL, SDC_FLOOR, and SDC_NEAREST.

Referenced by dGet(), and dGetP().

108 {
109  const doublereal dSwitch = oSwitch.dGet();
110 
111  integer iDrive;
112 
113  switch (eType) {
114  case SDC_FLOOR:
115  iDrive = floor(dSwitch);
116  break;
117 
118  case SDC_CEIL:
119  iDrive = ceil(dSwitch);
120  break;
121 
122  case SDC_NEAREST:
123  iDrive = round(dSwitch);
124  break;
125 
126  default:
127  ASSERT(false);
129  }
130 
131  const integer iMaxIndex = rgDrives.size() - 1;
132 
133  if (iDrive < 0 || iDrive > iMaxIndex) {
134  silent_cerr("drive caller(" << GetLabel()
135  << "): argument " << iDrive
136  << " from drive caller " << oSwitch.pGetDriveCaller()->GetLabel()
137  << " is not in range [0:" << iMaxIndex << "]"
138  << std::endl);
139 
140  throw ErrIndexOutOfRange(iDrive, 0, iMaxIndex, MBDYN_EXCEPT_ARGS);
141  }
142 
143  return rgDrives[iDrive].pGetDriveCaller();
144 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define ASSERT(expression)
Definition: colamd.c:977
DriveCaller * pGetDriveCaller(void) const
Definition: drive.cc:658
const std::vector< DriveOwner > rgDrives
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

std::ostream & SwitchDriveCaller::Restart ( std::ostream &  out) const
virtual

Implements DriveCaller.

Definition at line 170 of file module-switch_drive.cc.

References eType, rgDrives, and SDC_FLOOR.

171 {
172  out << "switch, " << (eType == SDC_FLOOR ? "floor, " : "ceil, ")
173  << rgDrives.size() << ", ";
174 
175  for (iterator i = rgDrives.begin(); i != rgDrives.end(); ++i) {
176  i->pGetDriveCaller()->Restart(out);
177 
178  if (rgDrives.end() - i > 1) {
179  out << ", ";
180  }
181  }
182 
183  return out;
184 }
const std::vector< DriveOwner > rgDrives
std::vector< DriveOwner >::const_iterator iterator

Member Data Documentation

Type SwitchDriveCaller::eType
private

Definition at line 80 of file module-switch_drive.cc.

Referenced by pCopy(), pGetDrive(), and Restart().

DriveOwner SwitchDriveCaller::oSwitch
private

Definition at line 79 of file module-switch_drive.cc.

Referenced by pCopy(), and pGetDrive().

const std::vector<DriveOwner> SwitchDriveCaller::rgDrives
private

Definition at line 82 of file module-switch_drive.cc.

Referenced by bIsDifferentiable(), pCopy(), pGetDrive(), and Restart().


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