Data Class Reference
[Data]

#include <data.h>

Collaboration diagram for Data:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Data ()
 Data (const Data &data)
 Data (const DataClass &blah)
Dataoperator= (const Data &from)
 ~Data ()
QString type () const
bool isNull () const
 operator Symbol () const
 operator Token () const
 operator String () const
Dataoperator+= (const Data &)
Dataoperator-= (const Data &)
Dataoperator/= (const Data &)
Dataoperator*= (const Data &)
bool & operator!= (const Data &)
Data getField (QString s)
void setField (QString s, Data v)
bool & operator== (const Data &)

Public Attributes

 BASIC_TYPES
 ARRAY_TYPES

Protected Member Functions

void type_error (QString expected) const
void visit (DataVisitor &v)

Protected Attributes

DataClasscontent

Friends

class DataClass
class DataVisitor


Detailed Description

The class 'Data' represents a generic dataclass. It will take care to count the references of the content it refers to and will deallocate when the reference counter reaches zero. It will also automatically copy local allocated objects towards the heap when necessary.

All data is shared explicitly, thus a dataclass can be passed along as if it were a pointer itself. The content will be explicitly shared. Data should never be assigned in such a way that loops occur.

The dataclass provides functions for easy downcasting, with automatically included runtime type-check.

The data class is not supposed to have subclasses since it merely forms a wrapper around the actual content, which should be subclassed from the class 'DataClass'

Definition at line 202 of file data.h.


Constructor & Destructor Documentation

Data::Data (  ) 

Will create a data object with Null as contents

Definition at line 95 of file data.cpp.

Data::Data ( const Data data  ) 

Will copy the data by taking a memory copy of the content. If the content is not yet allocated on the heap it will be copied as well. The copy is only of the internal references. The data objects behave explicitly shared.

Definition at line 101 of file data.cpp.

Data::Data ( const DataClass blah  ) 

Will take a copy of the given class, which can be anything, ranging from Null, Numbers, Floats, Arrays to Tokens... The copy is only of the internal references. The data objects behave explicitly shared.

Definition at line 107 of file data.cpp.

Data::~Data (  ) 

Will decrease the reference count.

Definition at line 112 of file data.cpp.


Member Function Documentation

Data Data::getField ( QString  s  ) 

Value retrieval by string reference

Definition at line 180 of file data.cpp.

Here is the call graph for this function:

bool Data::isNull (  )  const

true if the type of the content is Null false otherwise

Definition at line 130 of file data.cpp.

Data::operator String (  )  const

Converts the data to a String by passing it back as a String value. If the type is not a symbol a type_error is cast

Definition at line 162 of file data.cpp.

Data::operator Symbol (  )  const

Converts the data to a Symbol by passing it back as a Symbol value. If the type is not a symbol a type_error is cast

Definition at line 155 of file data.cpp.

Here is the call graph for this function:

Data::operator Token (  )  const

Converts the data to a Token by passing it back as a Token value. If the type is not a symbol a type_error is cast

Definition at line 168 of file data.cpp.

Here is the call graph for this function:

bool& Data::operator!= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 341 of file data.h.

Data& Data::operator*= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 331 of file data.h.

Data& Data::operator+= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 304 of file data.h.

Data& Data::operator-= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 313 of file data.h.

Data& Data::operator/= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 322 of file data.h.

Data & Data::operator= ( const Data from  ) 

Will assign to this class by releasing the old content and refitting it with a pointer to the new. Reference counts are updated automatically.

Definition at line 120 of file data.cpp.

bool& Data::operator== ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

Definition at line 361 of file data.h.

void Data::setField ( QString  s,
Data  v 
)

Setting the values

Definition at line 186 of file data.cpp.

Here is the call graph for this function:

QString Data::type (  )  const [inline]

Returns the type string of the data as a QString

Definition at line 258 of file data.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Data::type_error ( QString  expected  )  const [protected]

called when a type error occurs. Currently this function exits the program

Definition at line 79 of file data.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Data::visit ( DataVisitor v  )  [protected]

Definition at line 175 of file data.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class DataClass [friend]

Definition at line 205 of file data.h.

friend class DataVisitor [friend]

Definition at line 364 of file data.h.


Member Data Documentation

Definition at line 297 of file data.h.

Definition at line 292 of file data.h.

DataClass* Data::content [protected]

The actual content of this Data object. This is the only field and is copied along. The Data class has ownership over this pointer and will deallocate it as soon as the content its reference count reaches zero

Definition at line 213 of file data.h.


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

Generated on Sat Feb 20 19:04:27 2010 for Data Objects by  doxygen 1.5.9