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

#include <privpgin.h>

Inheritance diagram for PrivPlugIn:
Collaboration diagram for PrivPlugIn:

Public Member Functions

 PrivPlugIn (MathParser &mp, DataManager *pDM)
 
virtual ~PrivPlugIn (void)
 
virtual const char * sName (void) const =0
 
int Read (int argc, char *argv[])
 
TypedValue::Type GetType (void) const
 
TypedValue GetVal (void) const
 
- Public Member Functions inherited from MathParser::PlugIn
 PlugIn (MathParser &mp)
 
virtual ~PlugIn ()
 

Protected Member Functions

unsigned int ReadLabel (const char *s)
 
virtual void ReadSE (unsigned int uLabel, const char *s)=0
 
void ReadIndex (unsigned int iMaxIndex, const char *s)
 
virtual std::ostream & Err (std::ostream &out) const =0
 

Protected Attributes

SimulationEntitypSE
 
unsigned int iIndex
 
std::string sIndexName
 
DataManagerpDM
 
- Protected Attributes inherited from MathParser::PlugIn
MathParsermp
 

Friends

std::ostream & operator<< (std::ostream &out, const PrivPlugIn &p)
 

Detailed Description

Definition at line 38 of file privpgin.h.

Constructor & Destructor Documentation

PrivPlugIn::PrivPlugIn ( MathParser mp,
DataManager pDM 
)

Definition at line 37 of file privpgin.cc.

References ASSERT.

38 : MathParser::PlugIn(mp), pSE(0), iIndex(0), pDM(pDM)
39 {
40  ASSERT(pDM != 0);
41 }
unsigned int iIndex
Definition: privpgin.h:43
#define ASSERT(expression)
Definition: colamd.c:977
DataManager * pDM
Definition: privpgin.h:45
SimulationEntity * pSE
Definition: privpgin.h:42
PrivPlugIn::~PrivPlugIn ( void  )
virtual

Definition at line 43 of file privpgin.cc.

References NO_OP.

44 {
45  NO_OP;
46 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

virtual std::ostream& PrivPlugIn::Err ( std::ostream &  out) const
protectedpure virtual

Implemented in ElemPrivPlugIn, and NodePrivPlugIn.

Referenced by operator<<().

TypedValue::Type PrivPlugIn::GetType ( void  ) const
virtual

Implements MathParser::PlugIn.

Definition at line 97 of file privpgin.cc.

References TypedValue::VAR_REAL.

98 {
99  return TypedValue::VAR_REAL;
100 }
TypedValue PrivPlugIn::GetVal ( void  ) const
virtual

Implements MathParser::PlugIn.

Definition at line 103 of file privpgin.cc.

References SimulationEntity::dGetPrivData(), iIndex, and pSE.

104 {
105  return TypedValue(pSE->dGetPrivData(iIndex));
106 }
unsigned int iIndex
Definition: privpgin.h:43
virtual doublereal dGetPrivData(unsigned int i) const
Definition: simentity.cc:149
SimulationEntity * pSE
Definition: privpgin.h:42

Here is the call graph for this function:

int PrivPlugIn::Read ( int  argc,
char *  argv[] 
)
virtual

Implements MathParser::PlugIn.

Definition at line 49 of file privpgin.cc.

References SimulationEntity::iGetNumPrivData(), iIndex, MBDYN_EXCEPT_ARGS, pSE, ReadIndex(), ReadLabel(), and ReadSE().

50 {
51  unsigned int uLabel;
52 
53  if (argc < 1 || argv[0] == 0) {
54  silent_cerr("PrivPlugIn::Read(): "
55  "illegal number of parameters " << argc
56  << std::endl);
58  }
59  uLabel = ReadLabel(argv[0]);
60 
61  if (argc < 2 || argv[1] == 0) {
62  silent_cerr("PrivPlugIn::Read(" << argv[0] << "): "
63  << "illegal number of parameters " << argc
64  << std::endl);
66  }
67  ReadSE(uLabel, argv[1]);
68 
69  unsigned int iMaxIndex = pSE->iGetNumPrivData();
70  switch (iMaxIndex) {
71  case 0:
72  silent_cerr(*this << "allows no private data" << std::endl);
74 
75  case 1:
76  iIndex = 1;
77  if (argc < 3) {
78  break;
79  }
80  /* continue to next case */
81 
82  default:
83  if (argc > 3) {
84  silent_cerr("PrivPlugIn::Read(" << argv[0] << "): "
85  << "illegal number of parameters " << argc
86  << std::endl);
88  }
89  ReadIndex(iMaxIndex, argv[2]);
90  break;
91  }
92 
93  return 0;
94 }
virtual void ReadSE(unsigned int uLabel, const char *s)=0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
void ReadIndex(unsigned int iMaxIndex, const char *s)
Definition: privpgin.cc:124
unsigned int iIndex
Definition: privpgin.h:43
unsigned int ReadLabel(const char *s)
Definition: privpgin.cc:109
virtual unsigned int iGetNumPrivData(void) const
Definition: simentity.cc:136
SimulationEntity * pSE
Definition: privpgin.h:42

Here is the call graph for this function:

void PrivPlugIn::ReadIndex ( unsigned int  iMaxIndex,
const char *  s 
)
protected

Definition at line 124 of file privpgin.cc.

References SimulationEntity::iGetNumPrivData(), SimulationEntity::iGetPrivDataIdx(), iIndex, MBDYN_EXCEPT_ARGS, pSE, ReadLabel(), sIndexName, and STRLENOF.

Referenced by Read().

125 {
126  bool bRefresh(false);
127  if (strncasecmp(s, "string=", STRLENOF("string=")) == 0) {
128  sIndexName = &s[STRLENOF("string=")];
129  iIndex = pSE->iGetPrivDataIdx(sIndexName.c_str());
130  bRefresh = true;
131 
132  } else if (strncasecmp(s, "name=", STRLENOF("name=")) == 0) {
133  sIndexName = &s[STRLENOF("name=")];
134  iIndex = pSE->iGetPrivDataIdx(sIndexName.c_str());
135  bRefresh = true;
136 
137  silent_cerr("PrivPlugIn: "
138  "\"name=" << sIndexName << "\" is deprecated; "
139  "use \"string=" << sIndexName << "\" instead" << std::endl);
140 
141  } else if (strncasecmp(s, "index=", STRLENOF("index=")) == 0) {
142  s = &s[STRLENOF("index=")];
143  iIndex = ReadLabel(s);
144 
145  } else {
146  silent_cerr("PrivPlugIn: "
147  "index name without qualifier is deprecated; "
148  "use \"string=" << sIndexName << "\" instead" << std::endl);
149 
150  iIndex = pSE->iGetPrivDataIdx(s);
151  if (iIndex > 0) {
152  bRefresh = true;
153  } else {
154  iIndex = ReadLabel(s);
155  }
156  }
157 
158  if (bRefresh) {
159  // refresh, as iGetPrivDataIdx could have changed it
160  iMaxIndex = pSE->iGetNumPrivData();
161  }
162 
163  if (iIndex == 0 || iIndex > iMaxIndex) {
164  silent_cerr("illegal index " << iIndex << " for "
165  << *this << std::endl);
167  }
168 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: simentity.cc:142
unsigned int iIndex
Definition: privpgin.h:43
unsigned int ReadLabel(const char *s)
Definition: privpgin.cc:109
std::string sIndexName
Definition: privpgin.h:44
virtual unsigned int iGetNumPrivData(void) const
Definition: simentity.cc:136
#define STRLENOF(s)
Definition: mbdyn.h:166
SimulationEntity * pSE
Definition: privpgin.h:42

Here is the call graph for this function:

unsigned int PrivPlugIn::ReadLabel ( const char *  s)
protected

Definition at line 109 of file privpgin.cc.

References MathParser::Get(), and MathParser::PlugIn::mp.

Referenced by Read(), and ReadIndex().

110 {
111  unsigned int rc;
112 
113  /*
114  * deve essere terminato da ';' per essere letto da math parser :(
115  */
116  std::istringstream in(std::string(s) + ";");
117  InputStream In(in);
118  rc = (unsigned int)mp.Get(In);
119 
120  return rc;
121 }
Real Get(Real d=0.)
Definition: mathp.cc:4496
MathParser & mp
Definition: mathp.h:224

Here is the call graph for this function:

virtual void PrivPlugIn::ReadSE ( unsigned int  uLabel,
const char *  s 
)
protectedpure virtual

Implemented in ElemPrivPlugIn, and NodePrivPlugIn.

Referenced by Read().

virtual const char* PrivPlugIn::sName ( void  ) const
pure virtual

Implements MathParser::PlugIn.

Implemented in ElemPrivPlugIn, and NodePrivPlugIn.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PrivPlugIn p 
)
friend

Definition at line 293 of file privpgin.cc.

294 {
295  return p.Err(out);
296 }
virtual std::ostream & Err(std::ostream &out) const =0

Member Data Documentation

unsigned int PrivPlugIn::iIndex
protected

Definition at line 43 of file privpgin.h.

Referenced by GetVal(), Read(), and ReadIndex().

DataManager* PrivPlugIn::pDM
protected

Definition at line 45 of file privpgin.h.

Referenced by NodePrivPlugIn::ReadSE(), and ElemPrivPlugIn::ReadSE().

std::string PrivPlugIn::sIndexName
protected

Definition at line 44 of file privpgin.h.

Referenced by ReadIndex().


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