Acoustic Research Tool (ART)  v0.10
ARTdataContainer Class Reference

In addition to a value (ARTvariant) of some kind, this class can also contain the formula to (re)calculate its value.

The formula can be a parser expression or a functionoid. The ARTdataContainer also implements the client observer pattern, ensuring that if a value is changed, all values that depend on the changed one are invalidated and subject to recalculation, when their value is queried. Users must be carful to avoid circular references.

Use ARTdataContainer for values which have a small scope and when the name of the value you are processing is unimportant, because you can keep track of it. Use ARTdataProp when you want to add values to an ARTobject, they can then be added to the list of properties of the object. ARTdataProp is also useful when you have several values, and you can not keep track of their names easily without storing them as strings within the object.

Inheritance diagram for ARTdataContainer:
ARTdataProp ARTItimeModule::timeProperty ARTItimeModule::globalParameterType ARTItimeModule::localParameterType ARTItimeModule::PortType ARTItimeModule::IPortType ARTItimeModule::OPortType ARTItimeModule::FPortType

Public Member Functions

void EvaluateIfInvalid ()
void DebugDepTree (const string intend, const string linebreak="\n")
 Just for debugging: to print the dependency tree...
string WriteDepTree (const string intend, const string linebreak="\n")
 ARTdataContainer ()
 default constructor
 ARTdataContainer (const T_ART_Type dtyp, const int dlen, const string varname="")
 ARTdataContainer (std::string name, ARTfunctionoid *func=NULL)
 ARTdataContainer (const int i)
 ARTdataContainer (const double d)
 ARTdataContainer (const float f)
 ARTdataContainer (const char *s)
 ARTdataContainer (const char *s1, const char *s2)
 ARTdataContainer (const char *s1, const char *s2, const char *s3)
 ARTdataContainer (const char *s1, const char *s2, const char *s3, const char *s4)
 ARTdataContainer (const ARTdataContainer &orig)
 copy constructor
ARTdataContainerclone ()
T_ART_Type GetDatatype ()
int GetCount ()
int GetIterationNumber ()
double GetComplexity ()
 This function is not used right now.
T_ART_Var * GetValue ()
bool IsValid ()
int GetInt ()
const string & GetDefinition ()
void SetValue (ARTvariant *var)
 direct change of data value (ignore definition string); set value pointer and force value to be valid.
virtual void SetVal (const int i, const int ind=0)
virtual void SetVal (const double d, const int ind=0)
virtual void SetVal (const float f, const int ind=0)
virtual void SetVal (std::complex< double >, const int ind=0)
virtual void SetVal (const double re, const double im, const int ind=0)
virtual void SetVal (const char *s)
virtual void SetVal (const char *s, int ind)
void Invalidate ()
 mark value as invalid and invalidate all dependent data containers
void NotifyClients ()
 invalidate all dependent data containers
int GetEvaluationCost ()
void AddDependency (ARTdataContainer *dependency)
 Observe AND be notified.
void RemoveAllDependencies ()
void AddPropertiesAsDependency (ARTobject *obj)
 Add all data properties of the ARTobject pointed to by obj as dependencies.
void DoNotNotify (ARTdataContainer *client)
void RemoveDependency (ARTdataContainer *dependency)
void RemoveFromDefinition (ARTdataContainer *dependency)
void SetParser (ParserX *p)
virtual ParserX * GetParser ()
virtual ARTdataContainerGetParent ()
void Rename (const string &newname)
void SetParserVar (const string &varname)
virtual const Variable & GetParserVar () const
virtual const Variable & GetParserVar ()
void DestroyParserVar ()
string GetVarName () const
void SetDefinition (const string &s, ARTsimulator *scope)
void SetDefinition (const string &s)
void RedoDefinitionDependencies ()
void ResetEvaluation ()
 This function sets the flags of this data container and all dependencies to the value indicating that no evaluation is taking place.
void SetScope (ARTsimulator *sim)
ARTsimulatorGetScope ()
void SetFunction (ARTfunctionoid *func)
string DebugInfo ()
list< ARTdataContainer * > GetClientList ()
bool CheckValidity ()
ARTdataContainerGetArrayElement (int idx)
void SetCurrentIndex (int idx)
void SetParentModuleName (const string &name)
const string & GetParentModuleName () const
void deleteVar ()
 Array constructor.
virtual IValue & operator[] (std::size_t idx)
virtual IValue & operator[] (int idx)
virtual IValue & operator= (int_type a_iVal)
virtual IValue & operator= (float_type a_fVal)
virtual IValue & operator= (string_type a_sVal)
virtual IValue & operator= (bool val)
virtual IValue & operator= (const array_type &a_vVal)
virtual IValue & operator= (const cmplx_type &val)
virtual IValue & operator= (const char_type *a_szVal)
virtual char_type GetType () const
virtual float_type GetFloat () const
virtual float_type GetImag () const
virtual bool GetBool () const
virtual const cmplx_type & GetComplex () const
virtual const string_type & GetString () const
virtual const array_type & GetArray () const
virtual bool IsVolatile () const
virtual IToken * Clone () const
virtual Value * AsValue ()
virtual IValue * AsIValue ()

Static Public Attributes

static ARTprogressIndicator progressIndicator = ARTprogressIndicator(NULL,0)

Protected Member Functions

void SetCountedFlag (bool b)
virtual int EvaluationCost ()
virtual void Evaluate () const
void AddNotify (ARTdataContainer *client)
 Add a new client to this dataContainer.
virtual void resizeArray (int newSize)
 Resizes the used array in case the current data container is of type C_ART_na.

Protected Attributes

bool valid_
 true if value is consistent with definition
bool counted_
bool eval_started
list< ARTdataContainer * > clientList_
 other dataContainers depending on this one (need invalidation when value changes)
list< ARTdataContainer * >
list< ARTdataContainer * > dependencyList_
 other dataContainers this one depends on (variables in expression): need lookup whenever value is evaluated
list< ARTdataContainer * >
string definition_
 textual representation of property value (symbolic expression)
ParserX * parser_
 expression parser instance
 scope of variable names
string varname_
 name of corresponding variable in parser
mup::ARTValue * aval_
mup::Variable * avar_
bool parserVarDefined_
string tempDef_
string parentModuleName_

Member Function Documentation

void ARTdataContainer::AddDependency ( ARTdataContainer dependency)

Observe AND be notified.

Since most dependency relations are mutual, this function will write the dataContainer pointed to by dependency to its list of dependencies (ie. the dataContainers that need to be evaluated before this one can be evaluated) and adds itself as a client to the dataContainer specified by dependency, so it will be notified wenn the value of the latter changes.

void ARTdataContainer::AddNotify ( ARTdataContainer client)

Add a new client to this dataContainer.

Enter client into clientList if it is not already there. If the dependency relation is mutual (as in most cases) consider using AddDependency.

void ARTdataContainer::deleteVar ( )

Array constructor.

Matrix constructor

double ARTdataContainer::GetComplexity ( )

This function is not used right now.

the complexity of the calculation of this data container as was determined in previous calculations
int ARTdataContainer::GetCount ( )
variant vector length
T_ART_Type ARTdataContainer::GetDatatype ( )
variant data type
int ARTdataContainer::GetIterationNumber ( )
number of necessary iterations over formula to calculate (eg. the number of frq-indices we need to make the calculation for)
T_ART_Var* ARTdataContainer::GetValue ( )
data pointer, re-evaluates parser expression or functionoid if necessary (but only when numeric value)
void ARTdataContainer::ResetEvaluation ( )

This function sets the flags of this data container and all dependencies to the value indicating that no evaluation is taking place.

This function must be called when evaluation is aborted, since some datacontainers will be marked as evaluating, when the process jumps out of the evaluation cycle. IMPORTANT: This function must only be called when the data container is known to contain no circular dependencies, such as after aborting an evaluation, since before evaluations circular dependencies always generate an error.

void ARTdataContainer::resizeArray ( int  newSize)

Resizes the used array in case the current data container is of type C_ART_na.

[in]newSizeNew size of the array.
void ARTdataContainer::SetCountedFlag ( bool  b)