Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends
FilePersistence::GenericNode Class Reference

Public Types

enum  ValueType { NO_VALUE , STRING_VALUE , INT_VALUE , DOUBLE_VALUE }
 

Public Member Functions

bool areAllChildrenLoaded () const
 Returns true if the return value of this.children() is valid. More...
 
GenericNodeattachChild (GenericNode *child)
 
void attachToParent ()
 Links this node to the parent according to the parentId if the parent is loaded. More...
 
GenericNodechild (const QString &label)
 
const QList< GenericNode * > & children () const
 
void copy (const GenericNode *other)
 Sets id, parentId, label, value and type of this node equal to other. More...
 
void detachFromParent ()
 
bool equalTo (const GenericNode *other)
 
bool hasDoubleValue () const
 
bool hasIntValue () const
 
bool hasStringValue () const
 
bool hasValue () const
 
Model::NodeIdType id () const
 
const QString & label () const
 
void linkNode (bool recursiveLink=false)
 
GenericNodeparent () const
 
Model::NodeIdType parentId () const
 
GenericPersistentUnitpersistentUnit () const
 
const QString & rawValue () const
 
void remove (bool recursive=false)
 Removes the node from the tree. More...
 
void resetValue (ValueType type, const QString &value)
 
void setChildren (QList< GenericNode * > children)
 
void setId (Model::NodeIdType id)
 
void setLabel (const QString &label)
 
void setParent (GenericNode *parent)
 
void setParentId (Model::NodeIdType parentId)
 
void setType (const QString &type)
 
void setValue (const QString &value)
 
void setValue (double value)
 
void setValue (long value)
 
void setValue (ValueType type, const QString &value)
 This method must only be called if no value has been set yet. More...
 
const QString & type () const
 
double valueAsDouble () const
 
long valueAsLong () const
 
const QString & valueAsString () const
 
ValueType valueType () const
 

Static Public Attributes

static const QString PERSISTENT_UNIT_TYPE = "persistencenewunit"
 

Private Member Functions

 GenericNode ()
 
void ensureDataRead () const
 
void reset (GenericPersistentUnit *persistentUnit)
 
void reset (GenericPersistentUnit *persistentUnit, const char *dataLine, int dataLineLength, bool lazy)
 Loads all the properties of this node using the provided dataLine. More...
 
void reset (GenericPersistentUnit *persistentUnit, const GenericNode *nodeToCopy)
 
void reset (GenericPersistentUnit *persistentUnit, Model::NodeIdType id, Model::NodeIdType parentId, const QString &label, const QString &type, const QString &value, ValueType valueType)
 
bool sameTree (const GenericNode *other)
 
GenericTreetree () const
 

Private Attributes

bool areAllChildrenLoaded_ = false
 
QList< GenericNode * > children_
 
const char * dataLine_ {}
 The text line from which this node should be created. More...
 
int dataLineLength_ {}
 
Model::NodeIdType id_ {}
 
QString label_
 !!! When adding new members, make sure to reset them in the various reset() methods !!! More...
 
GenericNodeparent_ {}
 
Model::NodeIdType parentId_ {}
 
GenericPersistentUnitpersistentUnit_ {}
 
QString type_
 
QString value_
 
ValueType valueType_ {}
 

Friends

class GenericPersistentUnit
 
class GenericTree
 
class PiecewiseLoader
 

Member Enumeration Documentation

◆ ValueType

Enumerator
NO_VALUE 
STRING_VALUE 
INT_VALUE 
DOUBLE_VALUE 

Constructor & Destructor Documentation

◆ GenericNode()

FilePersistence::GenericNode::GenericNode ( )
private

Member Function Documentation

◆ areAllChildrenLoaded()

bool FilePersistence::GenericNode::areAllChildrenLoaded ( ) const
inline

Returns true if the return value of this.children() is valid.

◆ attachChild()

GenericNode * FilePersistence::GenericNode::attachChild ( GenericNode child)

◆ attachToParent()

void FilePersistence::GenericNode::attachToParent ( )

Links this node to the parent according to the parentId if the parent is loaded.

◆ child()

GenericNode * FilePersistence::GenericNode::child ( const QString &  label)

◆ children()

const QList< GenericNode * > & FilePersistence::GenericNode::children ( ) const

◆ copy()

void FilePersistence::GenericNode::copy ( const GenericNode other)

Sets id, parentId, label, value and type of this node equal to other.

If the parent changes, this node must first be detached from its parent.

◆ detachFromParent()

void FilePersistence::GenericNode::detachFromParent ( )

◆ ensureDataRead()

void FilePersistence::GenericNode::ensureDataRead ( ) const
private

◆ equalTo()

bool FilePersistence::GenericNode::equalTo ( const GenericNode other)
inline

◆ hasDoubleValue()

bool FilePersistence::GenericNode::hasDoubleValue ( ) const
inline

◆ hasIntValue()

bool FilePersistence::GenericNode::hasIntValue ( ) const
inline

◆ hasStringValue()

bool FilePersistence::GenericNode::hasStringValue ( ) const
inline

◆ hasValue()

bool FilePersistence::GenericNode::hasValue ( ) const
inline

◆ id()

Model::NodeIdType FilePersistence::GenericNode::id ( ) const
inline

◆ label()

const QString & FilePersistence::GenericNode::label ( ) const
inline

◆ linkNode()

void FilePersistence::GenericNode::linkNode ( bool  recursiveLink = false)

◆ parent()

GenericNode * FilePersistence::GenericNode::parent ( ) const

◆ parentId()

Model::NodeIdType FilePersistence::GenericNode::parentId ( ) const
inline

◆ persistentUnit()

GenericPersistentUnit * FilePersistence::GenericNode::persistentUnit ( ) const
inline

◆ rawValue()

const QString & FilePersistence::GenericNode::rawValue ( ) const
inline

◆ remove()

void FilePersistence::GenericNode::remove ( bool  recursive = false)

Removes the node from the tree.

If recursive is false, this node must not have any children. If recursive is true, all children of this node are also removed.

◆ reset() [1/4]

void FilePersistence::GenericNode::reset ( GenericPersistentUnit persistentUnit)
private

◆ reset() [2/4]

void FilePersistence::GenericNode::reset ( GenericPersistentUnit persistentUnit,
const char *  dataLine,
int  dataLineLength,
bool  lazy 
)
private

Loads all the properties of this node using the provided dataLine.

Any old content of this node will be removed. If this node did not belong to an allocator, it's children will be deleted.

dataLine should start with the indenting tabs and should end with the last content character of the node. The line should not include the final line break characters.

Set lazy to true when loading with an allocator. In this case dataLine will be saved and only parsed on demand. If lazy is false, then the node will be immediately initialized with the provided data.

Balz writes: This method should only be called from a persistent unit and that persistent unit should pass itself as the persistenUnit argument. Before it is called, the values of the members of this are undefined.

◆ reset() [3/4]

void FilePersistence::GenericNode::reset ( GenericPersistentUnit persistentUnit,
const GenericNode nodeToCopy 
)
private

◆ reset() [4/4]

void FilePersistence::GenericNode::reset ( GenericPersistentUnit persistentUnit,
Model::NodeIdType  id,
Model::NodeIdType  parentId,
const QString &  label,
const QString &  type,
const QString &  value,
ValueType  valueType 
)
private

◆ resetValue()

void FilePersistence::GenericNode::resetValue ( ValueType  type,
const QString &  value 
)

◆ sameTree()

bool FilePersistence::GenericNode::sameTree ( const GenericNode other)
private

◆ setChildren()

void FilePersistence::GenericNode::setChildren ( QList< GenericNode * >  children)
inline

◆ setId()

void FilePersistence::GenericNode::setId ( Model::NodeIdType  id)
inline

◆ setLabel()

void FilePersistence::GenericNode::setLabel ( const QString &  label)
inline

◆ setParent()

void FilePersistence::GenericNode::setParent ( GenericNode parent)

◆ setParentId()

void FilePersistence::GenericNode::setParentId ( Model::NodeIdType  parentId)

◆ setType()

void FilePersistence::GenericNode::setType ( const QString &  type)
inline

◆ setValue() [1/4]

void FilePersistence::GenericNode::setValue ( const QString &  value)

◆ setValue() [2/4]

void FilePersistence::GenericNode::setValue ( double  value)

◆ setValue() [3/4]

void FilePersistence::GenericNode::setValue ( long  value)

◆ setValue() [4/4]

void FilePersistence::GenericNode::setValue ( ValueType  type,
const QString &  value 
)

This method must only be called if no value has been set yet.

◆ tree()

GenericTree * FilePersistence::GenericNode::tree ( ) const
private

◆ type()

const QString & FilePersistence::GenericNode::type ( ) const
inline

◆ valueAsDouble()

double FilePersistence::GenericNode::valueAsDouble ( ) const

◆ valueAsLong()

long FilePersistence::GenericNode::valueAsLong ( ) const

◆ valueAsString()

const QString & FilePersistence::GenericNode::valueAsString ( ) const

◆ valueType()

GenericNode::ValueType FilePersistence::GenericNode::valueType ( ) const
inline

Friends And Related Function Documentation

◆ GenericPersistentUnit

friend class GenericPersistentUnit
friend

◆ GenericTree

friend class GenericTree
friend

◆ PiecewiseLoader

friend class PiecewiseLoader
friend

Member Data Documentation

◆ areAllChildrenLoaded_

bool FilePersistence::GenericNode::areAllChildrenLoaded_ = false
private

◆ children_

QList<GenericNode*> FilePersistence::GenericNode::children_
private

◆ dataLine_

const char* FilePersistence::GenericNode::dataLine_ {}
private

The text line from which this node should be created.

◆ dataLineLength_

int FilePersistence::GenericNode::dataLineLength_ {}
private

◆ id_

Model::NodeIdType FilePersistence::GenericNode::id_ {}
private

◆ label_

QString FilePersistence::GenericNode::label_
private

!!! When adding new members, make sure to reset them in the various reset() methods !!!

◆ parent_

GenericNode* FilePersistence::GenericNode::parent_ {}
private

◆ parentId_

Model::NodeIdType FilePersistence::GenericNode::parentId_ {}
private

◆ PERSISTENT_UNIT_TYPE

const QString FilePersistence::GenericNode::PERSISTENT_UNIT_TYPE = "persistencenewunit"
static

◆ persistentUnit_

GenericPersistentUnit* FilePersistence::GenericNode::persistentUnit_ {}
private

◆ type_

QString FilePersistence::GenericNode::type_
private

◆ value_

QString FilePersistence::GenericNode::value_
private

◆ valueType_

ValueType FilePersistence::GenericNode::valueType_ {}
private