1 #ifndef __DIADES__SDMDL__VARIABLE__HH 2 #define __DIADES__SDMDL__VARIABLE__HH 15 class VariableFactory;
28 static string typeName() {
return "Diades::Sdmdl::Variable"; }
95 Variable(
VariableFactory &
owner):_name(
"__null__diades__sdmdl_variable"),_id(0),_index(0),_owner(owner),_values(),_domain(),_default(),_current(),_observable(false) {}
105 Variable(
const string &
name,
unsigned id,
VariableFactory &
owner):_name(name),_id(id),_index(0),_owner(owner),_values(),_domain(),_default(),_current(),_observable(false){}
183 return this == &variable;
197 return !(*
this == variable);
280 require(Exception,!val.
isNull(),
"setDefault: the Value is null");
282 Utils::Msg(
"setDefault: the Value %1% does not belong to the domain of the Variable %2%")
285 _default.push_back(val);
374 Utils::Msg(
"assign: the Value %1% is not contained in the Variable %2%")
377 _current.push_back(value);
411 static std::string
typeName() {
return "Diades::Sdmdl::VariableFactory"; }
474 return this == &factory;
483 return _dictionary.size();
493 Variable & newVariable(
const std::string & label);
502 Variable & getVariable(
const std::string & label);
512 return _nullVariable[0];
524 return _nullVariable[0];
const string & name() const
const Value & getValue(const string &label) const
bool operator!=(const Variable &variable) const
Variable(const string &name, unsigned id, VariableFactory &owner)
void assign(const Value &value)
const Value & defaultValue() const
VariableVector _nullVariable
const VariableFactory & owner() const
bool operator==(const VariableFactory &factory) const
std::unordered_map< std::string, Variable::Pointer > _dictionary
bool contains(const Value &val) const
VariableFactory & owner()
Diades::Utils::Exception< VariableFactory > Exception
Variable(VariableFactory &owner)
std::vector< Reference > VariableVector
Utils::Exception< Variable > Exception
#define require(Exception, expr, message)
Namespace of the Diades project.
static std::string typeName()
Variable & nullVariable()
void setIndex(unsigned index)
bool operator==(const Variable &variable) const
Value::ValueVector ValueVector
const Value & value() const
const Value & addValue(const string &label)
const ValueVector & domain() const
std::reference_wrapper< Variable const > ConstReference
std::reference_wrapper< Variable > Reference
bool containsValueOfLabel(const string &label) const
bool isObservable() const
void setDefault(const Value &val)
friend ostream & operator<<(ostream &os, const Variable &variable)
size_t numberOfAllocatedVariables() const
const Variable & nullVariable() const