ML Reference
ml::TreeNode Class Reference

The class TreeNode is the abstract base class for the import/export of ML objects. More...

#include <mlTreeNode.h>

Public Types

enum  ConstructionMode { CM_writerRoot , CM_readerRoot , CM_COUNT }
 TreeNode construction modes: More...
 

Public Member Functions

virtual ~TreeNode ()
 Destructor deleting all children of this node.
 
TREE IMPORT/EXPORT METHODS:

Re-implement in derived classes.

virtual void writeToFile (const char *) VOID_IMPLEMENTATION("writeToFile")
 Writes the subtree represented by this node to a file.
 
virtual void readFromFile (const char *) VOID_IMPLEMENTATION("readFromFile")
 Reads the subtree represented by this node from a file.
 
virtual void writeToString (std::string &) VOID_IMPLEMENTATION("writeToString")
 Generates a string representation of the subtree represented by this node to a file.
 
virtual void readFromString (const std::string &) VOID_IMPLEMENTATION("readFromString")
 Reads the subtree represented by this node from a string.
 
TREE WRITING METHODS:

Each method appends a child representing the variable/object given as first parameter and identified via the second.

You can also add several children with the same name. This feature should be used with care though, because it is not specified here whether the implementation preserves the object order while reading and writing. Those methods with VOID_IMPLEMENTATION must be reimplemented when used in derived classes. The first parameter is the value to be stored and the second holds a name for it (for example a tag name in XML files.

virtual void addChild (bool val, const char *name) ADD_ULONG_CHILD
 Factory method adding a child encapsulating a variable of type bool.
 
virtual void addChild (unsigned char val, const char *name) ADD_ULONG_CHILD
 Factory method adding a child encapsulating a variable of type unsigned char.
 
virtual void addChild (char val, const char *name) ADD_LONG_CHILD
 Factory method adding a child encapsulating a variable of type char.
 
virtual void addChild (unsigned short val, const char *name) ADD_ULONG_CHILD
 Factory method adding a child encapsulating a variable of type unsigned short.
 
virtual void addChild (short val, const char *name) ADD_LONG_CHILD
 Factory method adding a child encapsulating a variable of type short.
 
virtual void addChild (unsigned int val, const char *name) ADD_ULONG_CHILD
 Factory method adding a child encapsulating a variable of type unsigned int.
 
virtual void addChild (int val, const char *name) ADD_LONG_CHILD
 Factory method adding a child encapsulating a variable of type int.
 
virtual void addChild (unsigned long, const char *) VOID_IMPLEMENTATION("addChild(unsigned long)")
 Factory method adding a child encapsulating a variable of type long.
 
virtual void addChild (long, const char *) VOID_IMPLEMENTATION("addChild(long)")
 Factory method adding a child encapsulating a variable of type long.
 
virtual void addChild (MLuint64, const char *) VOID_IMPLEMENTATION("addChild(MLuint64)")
 Factory method adding a child encapsulating a variable of type MLuint64.
 
virtual void addChild (MLint64, const char *) VOID_IMPLEMENTATION("addChild(MLint64)")
 Factory method adding a child encapsulating a variable of type MLint64.
 
virtual void addChild (float val, const char *name) ADD_LDOUBLE_CHILD
 Factory method adding a child encapsulating a variable of type float.
 
virtual void addChild (double val, const char *name) ADD_LDOUBLE_CHILD
 Factory method adding a child encapsulating a variable of type double.
 
virtual void addChild (long double, const char *) VOID_IMPLEMENTATION("addChild(long double)")
 Factory method adding a child encapsulating a variable of type long double.
 

Detailed Description

The class TreeNode is the abstract base class for the import/export of ML objects.

It provides an interface that allows the import/export of standard C types such as int or float, as well as standard ML types like Vector6 or SubImageBox, and last but definitely not least, of complex user defined objects. Polymorphy is supported by allowing the I/E of base objects which can created automatically using the runtime system, and can be initialized using the Base::readStateFromTree method.

Definition at line 154 of file mlTreeNode.h.

Member Enumeration Documentation

◆ ConstructionMode

TreeNode construction modes:

Enumerator
CM_writerRoot 

Construct as root node for writing.

CM_readerRoot 

Construct as root node for reading.

CM_COUNT 

number of construction modes

Definition at line 197 of file mlTreeNode.h.

Constructor & Destructor Documentation

◆ ~TreeNode()

virtual ml::TreeNode::~TreeNode ( )
virtual

Destructor deleting all children of this node.

Member Function Documentation

◆ addChild() [1/14]

virtual void ml::TreeNode::addChild ( bool val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type bool.

◆ addChild() [2/14]

virtual void ml::TreeNode::addChild ( char val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type char.

◆ addChild() [3/14]

virtual void ml::TreeNode::addChild ( double val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type double.

◆ addChild() [4/14]

virtual void ml::TreeNode::addChild ( float val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type float.

◆ addChild() [5/14]

virtual void ml::TreeNode::addChild ( int val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type int.

◆ addChild() [6/14]

virtual void ml::TreeNode::addChild ( long double ,
const char *  )
virtual

Factory method adding a child encapsulating a variable of type long double.

◆ addChild() [7/14]

virtual void ml::TreeNode::addChild ( long ,
const char *  )
virtual

Factory method adding a child encapsulating a variable of type long.

◆ addChild() [8/14]

virtual void ml::TreeNode::addChild ( MLint64 ,
const char *  )
virtual

Factory method adding a child encapsulating a variable of type MLint64.

◆ addChild() [9/14]

virtual void ml::TreeNode::addChild ( MLuint64 ,
const char *  )
virtual

Factory method adding a child encapsulating a variable of type MLuint64.

◆ addChild() [10/14]

virtual void ml::TreeNode::addChild ( short val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type short.

◆ addChild() [11/14]

virtual void ml::TreeNode::addChild ( unsigned char val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type unsigned char.

◆ addChild() [12/14]

virtual void ml::TreeNode::addChild ( unsigned int val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type unsigned int.

◆ addChild() [13/14]

virtual void ml::TreeNode::addChild ( unsigned long ,
const char *  )
virtual

Factory method adding a child encapsulating a variable of type long.

◆ addChild() [14/14]

virtual void ml::TreeNode::addChild ( unsigned short val,
const char * name )
virtual

Factory method adding a child encapsulating a variable of type unsigned short.

◆ readFromFile()

virtual void ml::TreeNode::readFromFile ( const char * )
virtual

Reads the subtree represented by this node from a file.

◆ readFromString()

virtual void ml::TreeNode::readFromString ( const std::string & )
virtual

Reads the subtree represented by this node from a string.

This method can be used to quickly implement setPersistentString() for a class with TreeNode support. It might not make sense in all cases, for example when the derived class performs a binary import/export of the data.

◆ writeToFile()

virtual void ml::TreeNode::writeToFile ( const char * )
virtual

Writes the subtree represented by this node to a file.

◆ writeToString()

virtual void ml::TreeNode::writeToString ( std::string & )
virtual

Generates a string representation of the subtree represented by this node to a file.

This method can be used to quickly implement getPersistentString() for a class with TreeNode support. It might not make sense in all cases, for example when the derived class performs a binary import/export of the data.


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