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

#include <table.h>

Collaboration diagram for Table:

Classes

class  ErrNameAlreadyDefined
 

Public Types

typedef std::map< std::string,
NamedValue * > 
VM
 

Public Member Functions

 Table (bool bSetConstants)
 
virtual ~Table (void)
 
VarPut (const std::string &name, const TypedValue &v)
 
const NamedValuePut (NamedValue *p)
 
NamedValueGet (const std::string &name) const
 
VM::const_iterator begin (void) const
 
VM::const_iterator end (void) const
 

Private Attributes

VM vm
 

Friends

std::ostream & operator<< (std::ostream &out, const Table &T)
 

Detailed Description

Definition at line 43 of file table.h.

Member Typedef Documentation

typedef std::map<std::string, NamedValue *> Table::VM

Definition at line 53 of file table.h.

Constructor & Destructor Documentation

Table::Table ( bool  bSetConstants)

Definition at line 82 of file table.cc.

References consts, DEBUGCOUT, MBDYN_EXCEPT_ARGS, tmp_sym::name, Put(), TypedValue::SetConst(), and tmp_sym::val.

83 : vm()
84 {
85  DEBUGCOUT("Table::Table" << std::endl);
86 
87  if (bSetConstants) {
88  tmp_sym* p = consts;
89  while (p->name != 0) {
90  p->val.SetConst();
91  NamedValue* n = Put(p->name, p->val);
92  if (n == 0) {
93  silent_cerr("Table: unable to insert const \"" << p->name << "\""
94  << std::endl);
96  }
97  p++;
98  }
99  }
100 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Var * Put(const std::string &name, const TypedValue &v)
Definition: table.cc:110
tmp_sym consts[]
Definition: table.cc:49
TypedValue val
Definition: table.cc:46
Definition: table.cc:44
#define DEBUGCOUT(msg)
Definition: myassert.h:232
void SetConst(bool isConst=true, bool bForce=false)
Definition: mathp.cc:1275
const char * name
Definition: table.cc:45
VM vm
Definition: table.h:56

Here is the call graph for this function:

Table::~Table ( void  )
virtual

Definition at line 102 of file table.cc.

References vm.

103 {
104  for (VM::iterator i = vm.begin(); i != vm.end(); ++i) {
105  delete i->second;
106  }
107 }
VM vm
Definition: table.h:56

Member Function Documentation

VM::const_iterator Table::begin ( void  ) const
inline

Definition at line 64 of file table.h.

References vm.

64 { return vm.begin(); };
VM vm
Definition: table.h:56
VM::const_iterator Table::end ( void  ) const
inline

Definition at line 65 of file table.h.

References vm.

65 { return vm.end(); };
VM vm
Definition: table.h:56
NamedValue * Table::Get ( const std::string &  name) const

Definition at line 150 of file table.cc.

References vm.

Referenced by DriveHandler::DriveHandler(), MathParser::expr(), GetEnviron(), MathParser::InsertSym(), Put(), MathParser::readplugin(), and MathParser::stmt().

151 {
152  VM::const_iterator i = vm.find(name);
153  if (i == vm.end()) {
154  return 0;
155  }
156  return i->second;
157 }
VM vm
Definition: table.h:56
Var * Table::Put ( const std::string &  name,
const TypedValue v 
)

Definition at line 110 of file table.cc.

References Get(), MBDYN_EXCEPT_ARGS, and vm.

Referenced by DriveHandler::DriveHandler(), GetEnviron(), MathParser::InsertSym(), MathParser::readplugin(), MathParser::stmt(), and Table().

111 {
112  NamedValue* pNV = Get(name);
113  if (pNV != 0) {
114  silent_cerr("Table::Put(): name \"" << name << "\" "
115  "already defined" << std::endl);
117  }
118 
119  Var *pVar = new Var(name.c_str(), x);
120 
121  if (!vm.insert(VM::value_type(name, pVar)).second) {
122  silent_cerr("Table::Put(): unable to insert variable "
123  "\"" << name << "\"" << std::endl);
125  }
126 
127  return pVar;
128 }
Definition: mathtyp.h:175
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
NamedValue * Get(const std::string &name) const
Definition: table.cc:150
VM vm
Definition: table.h:56

Here is the call graph for this function:

const NamedValue * Table::Put ( NamedValue p)

Definition at line 131 of file table.cc.

References Get(), NamedValue::GetName(), MBDYN_EXCEPT_ARGS, and vm.

132 {
133  const NamedValue* pNV = Get(p->GetName());
134  if (pNV != 0) {
135  silent_cerr("Table::Put(): name \"" << p->GetName()
136  << "\" already defined" << std::endl);
138  }
139 
140  if (!vm.insert(VM::value_type(p->GetName(), p)).second) {
141  silent_cerr("Table::Put(): unable to insert named value "
142  "\"" << p->GetName() << "\"" << std::endl);
144  }
145 
146  return p;
147 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
NamedValue * Get(const std::string &name) const
Definition: table.cc:150
const char * GetName(void) const
Definition: mathp.cc:1751
VM vm
Definition: table.h:56

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const Table T 
)
friend

Definition at line 160 of file table.cc.

161 {
162  for (Table::VM::const_iterator i = T.vm.begin(); i != T.vm.end(); ++i) {
163  out << " ";
164  if (i->second->Const()) {
165  out << "const ";
166  }
167  out << i->second->GetTypeName()
168  << " " << i->second->GetName()
169  << " = " << i->second->GetVal() << std::endl;
170  }
171 
172  return out;
173 }
VM vm
Definition: table.h:56

Member Data Documentation

VM Table::vm
private

Definition at line 56 of file table.h.

Referenced by begin(), end(), Get(), operator<<(), Put(), and ~Table().


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