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

Public Member Functions

 UDUnitsNameSpace (const char *path)
 
 ~UDUnitsNameSpace (void)
 
bool IsFunc (const std::string &fname) const
 
MathParser::MathFunc_tGetFunc (const std::string &fname) const
 
TypedValue EvalFunc (MathParser::MathFunc_t *f) const
 
virtual TableGetTable (void)
 
- Public Member Functions inherited from MathParser::NameSpace
 NameSpace (const std::string &name)
 
virtual ~NameSpace (void)
 
virtual const std::string & sGetName (void) const
 

Protected Attributes

MathParser::MathFunc_t f
 

Detailed Description

Definition at line 47 of file module-udunits.cc.

Constructor & Destructor Documentation

UDUnitsNameSpace::UDUnitsNameSpace ( const char *  path)

Definition at line 139 of file module-udunits.cc.

References MathParser::AF_OPTIONAL, MathParser::MathFunc_t::args, f, MathParser::MathFunc_t::f, MathParser::MathFunc_t::fname, MBDYN_EXCEPT_ARGS, MathParser::MathFunc_t::ns, MathParser::MathFunc_t::t, and unit_convert().

140 : MathParser::NameSpace("units")
141 {
142  int rc = utInit(path);
143 
144  if (path == 0) {
145  path = "<unspecified>";
146  }
147 
148  switch (rc) {
149  case 0:
150  // success
151  break;
152 
153  case UT_ENOFILE:
154  silent_cerr("utUnit could not find file \"" << path << "\""
155  << std::endl);
157 
158  case UT_ESYNTAX:
159  silent_cerr("utUnit found a syntax error "
160  "in file \"" << path << "\"" << std::endl);
162 
163  case UT_EUNKNOWN:
164  silent_cerr("utUnit found an unknown specification "
165  "in file \"" << path << "\"" << std::endl);
167 
168  case UT_EIO:
169  silent_cerr("utUnit hit an I/O error while reading "
170  "file \"" << path << "\"" << std::endl);
172 
173  case UT_EALLOC:
174  silent_cerr("utUnit ran out of memory while reading "
175  "file \"" << path << "\"" << std::endl);
177  }
178 
179  f.fname = "convert";
180  f.ns = this;
181  f.args.resize(1 + 3);
186  f.f = unit_convert;
187  f.t = 0;
188 }
MathArgPriv_t< Real, AT_REAL > MathArgReal_t
Definition: mathp.h:155
MathParser::MathFunc_t f
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MathFunc_f f
Definition: mathp.h:170
MathFuncTest_f t
Definition: mathp.h:171
MathArgPriv_t< std::string, AT_STRING > MathArgString_t
Definition: mathp.h:156
NameSpace * ns
Definition: mathp.h:168
static int unit_convert(const MathParser::MathArgs &args)
std::string fname
Definition: mathp.h:167
const char * path
Definition: autopilot.c:141

Here is the call graph for this function:

UDUnitsNameSpace::~UDUnitsNameSpace ( void  )

Definition at line 190 of file module-udunits.cc.

191 {
192  utTerm();
193 }

Member Function Documentation

TypedValue UDUnitsNameSpace::EvalFunc ( MathParser::MathFunc_t f) const
virtual

Implements MathParser::NameSpace.

Definition at line 212 of file module-udunits.cc.

References MathParser::MathFunc_t::args, and MathParser::MathFunc_t::f.

213 {
214  f->f(f->args);
215 
216  return TypedValue((*dynamic_cast<MathParser::MathArgReal_t*>(f->args[0]))());
217 }
MathFunc_f f
Definition: mathp.h:170
MathParser::MathFunc_t * UDUnitsNameSpace::GetFunc ( const std::string &  fname) const
virtual

Implements MathParser::NameSpace.

Definition at line 202 of file module-udunits.cc.

References f, and MathParser::MathFunc_t::fname.

203 {
204  if (fname.compare(f.fname) == 0) {
205  return new MathParser::MathFunc_t(f);
206  }
207 
208  return 0;
209 }
MathParser::MathFunc_t f
std::string fname
Definition: mathp.h:167
Table * UDUnitsNameSpace::GetTable ( void  )
virtual

Implements MathParser::NameSpace.

Definition at line 220 of file module-udunits.cc.

221 {
222  return 0;
223 }
bool UDUnitsNameSpace::IsFunc ( const std::string &  fname) const
virtual

Implements MathParser::NameSpace.

Definition at line 196 of file module-udunits.cc.

References f, and MathParser::MathFunc_t::fname.

197 {
198  return (fname.compare(f.fname) == 0);
199 }
MathParser::MathFunc_t f
std::string fname
Definition: mathp.h:167

Member Data Documentation

MathParser::MathFunc_t UDUnitsNameSpace::f
protected

Definition at line 49 of file module-udunits.cc.

Referenced by GetFunc(), IsFunc(), and UDUnitsNameSpace().


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