ML Reference
MeVis/Foundation/Sources/ML/include/mlTreeNode.h File Reference

This abstract class defines an interface to allow the storing and restoring of complex objects. More...

#include "mlInitSystemML.h"
#include "mlBasics.h"
#include "mlRuntimeType.h"
#include "mlRuntimeSubClass.h"

Go to the source code of this file.

Classes

class  ml::TreeNodeException
 The class TreeNodeException is the base class for all exceptions thrown by the class TreeNode and all derived classes. More...
class  ml::TreeNode
 The class TreeNode is the abstract base class for the import/export of ML objects. More...

Namespaces

namespace  ml
 

Define the namespace name like in the ML. Default is ml.


Defines

#define VOID_IMPLEMENTATION(which)   { throw TreeNodeException(TNE_VoidImplementation, which); }
 Standard body for a method in this interface class.
#define VOID_IMPLEMENTATION_RET(which, R)   { if (MLAlwaysTrue){ throw TreeNodeException(TNE_VoidImplementation, which); } return R; }
 Standard body for a method in this interface class.
#define ADD_LONG_CHILD   { addChild(static_cast<long>(val), name); }
 For each signed integer type, addChild(long) is called by default.
#define ADD_ULONG_CHILD   { addChild(static_cast<unsigned long>(val), name); }
 For each unsigned integer type, addChild(ulong) is called by default.
#define ADD_LDOUBLE_CHILD   { addChild(static_cast<long double>(val), name); }
 For each floating point type, addChild(LDouble) is called by default.
#define READ_LONG_CHILD   { long lval=0; readChild(lval, name); val = lval; }
 For each signed integer type, readChild(Long) is called by default and the results is simply casted to the original type.
#define READ_ULONG_CHILD   { unsigned long lval=0; readChild(lval, name); val = lval; }
 For each unsigned integer type, readChild(ULong) is called by default and the results is simply casted to the original type.
#define READ_LDOUBLE_CHILD   { long double ldval=0; readChild(ldval, name); val = ldval; }
 For each floating point type, readChild(LDouble) is called by default and the results is simply casted to the original type.
#define READ_LONG_CHILD_FOR_BOOL   { long lval=0; readChild(lval, name); val = (lval!=0); }
 For each signed integer type, readChild(Long) is called by default and the results is simply casted to the original type.
Macros
#define ML_READCHILD_OPTIONAL(obj, tagName, defaultVal)
 Convenience macro that can be used to read an optional child with name tagName into obj and assign a default value defaultVal if it is not found.
#define ML_ADDSTATE_VERSION(ThisClass)   parent->setVersion("#ThisClass#", ThisClass::getAddStateVersion());
 Use this macro in addStateToTree() for classes that might need versioning in the future.
#define ML_ADDSTATE_SUPER(SuperClass)
 Use this macro if you would like to store your super class members as well.
#define ML_READSTATE_SUPER(SuperClass)
 Use this macro if you would like to store your super class members as well.
#define ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE
 This macro can be useful when you already implemented the get/setPersistentState() methods but you would also like to support for the TreeNode import/export methods without any extra efforts.

Enumerations

enum  {
  ml::TNE_VoidImplementation, ml::TNE_NotSupported, ml::TNE_ChildNotFound, ml::TNE_AddingBase,
  ml::TNE_ReadingBase, ml::TNE_ReadingUChar, ml::TNE_ReadingChar, ml::TNE_ReadingUShort,
  ml::TNE_ReadingShort, ml::TNE_ReadingUInt, ml::TNE_ReadingInt, ml::TNE_ReadingULong,
  ml::TNE_ReadingLong, ml::TNE_ReadingFloat, ml::TNE_ReadingDouble, ml::TNE_ReadingLDouble,
  ml::TNE_ReadingString, ml::TNE_ReadingVec2, ml::TNE_ReadingVec3, ml::TNE_ReadingVec4,
  ml::TNE_ReadingVec6, ml::TNE_ReadingVector, ml::TNE_ReadingMat3, ml::TNE_ReadingMat4,
  ml::TNE_ReadingSubImgBox, ml::TNE_ReadingSubImgBoxf, ml::TNE_InvalidReadNext, ml::TNE_InvalidParentNode,
  ml::TNE_FileNotFound, ml::TNE_ReadingFile, ml::TNE_WritingFile, ml::TNE_UnsupportedClassVersion,
  ml::TNE_UserDefined, ml::TNE_Unknown, ml::TNE_ReadingMLint64, ml::TNE_ReadingMLuint64,
  ml::TNE_COUNT
}
 TreeNode exceptions. More...

Detailed Description

This abstract class defines an interface to allow the storing and restoring of complex objects.

Author:
Jan-Martin Kuhnigk
Date:
09/2002

Definition in file mlTreeNode.h.


Define Documentation

#define ADD_LDOUBLE_CHILD   { addChild(static_cast<long double>(val), name); }

For each floating point type, addChild(LDouble) is called by default.

Definition at line 180 of file mlTreeNode.h.

#define ADD_LONG_CHILD   { addChild(static_cast<long>(val), name); }

For each signed integer type, addChild(long) is called by default.

Definition at line 174 of file mlTreeNode.h.

#define ADD_ULONG_CHILD   { addChild(static_cast<unsigned long>(val), name); }

For each unsigned integer type, addChild(ulong) is called by default.

Definition at line 177 of file mlTreeNode.h.

#define ML_ADDSTATE_SUPER (   SuperClass)
Value:
{ \
TreeNode* superClassNode = parent->addChild("_" #SuperClass); \
SuperClass::addStateToTree(superClassNode); \
}

Use this macro if you would like to store your super class members as well.

Mandatory if the superclass uses versioning.

Definition at line 710 of file mlTreeNode.h.

#define ML_ADDSTATE_VERSION (   ThisClass)    parent->setVersion("#ThisClass#", ThisClass::getAddStateVersion());

Use this macro in addStateToTree() for classes that might need versioning in the future.

Definition at line 706 of file mlTreeNode.h.

#define ML_READCHILD_OPTIONAL (   obj,
  tagName,
  defaultVal 
)
Value:
if (parent->hasChild(tagName)) { \
  parent->readChild(obj, tagName); \
} else { \
  obj = defaultVal; \
}

Convenience macro that can be used to read an optional child with name tagName into obj and assign a default value defaultVal if it is not found.

Definition at line 697 of file mlTreeNode.h.

#define ML_READSTATE_SUPER (   SuperClass)
Value:
{ \
TreeNode* superClassNode = parent->readContainerChild("_" #SuperClass); \
SuperClass::readStateFromTree(superClassNode); \
}

Use this macro if you would like to store your super class members as well.

Mandatory if the superclass uses versionig.

Definition at line 717 of file mlTreeNode.h.

#define ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE
Value:
virtual void addStateToTree(TreeNode* parent) const \
{ \
char* state = getPersistentState(); \
if (!state){ state = "Could not read object state."; } \
parent->addChild(state, "State"); \
clearPersistentState(state); \
} \
\
virtual void readStateFromTree(TreeNode* parent) \
{ \
char* state; \
parent->readChild(state, "State"); \
setPersistentState(state); \
parent->deleteString(state); \
}

This macro can be useful when you already implemented the get/setPersistentState() methods but you would also like to support for the TreeNode import/export methods without any extra efforts.

It is however recommended that you implement those methods specifically for your class (adding all class members as children of the parent node) instead of using this macro.

addStateToTree() simply attaches the persistent state returned by getPersistentState() as a string child node, while readStateFromTree() allows reading of such a child.

Definition at line 730 of file mlTreeNode.h.

#define READ_LDOUBLE_CHILD   { long double ldval=0; readChild(ldval, name); val = ldval; }

For each floating point type, readChild(LDouble) is called by default and the results is simply casted to the original type.

Definition at line 206 of file mlTreeNode.h.

#define READ_LONG_CHILD   { long lval=0; readChild(lval, name); val = lval; }

For each signed integer type, readChild(Long) is called by default and the results is simply casted to the original type.

Definition at line 198 of file mlTreeNode.h.

#define READ_LONG_CHILD_FOR_BOOL   { long lval=0; readChild(lval, name); val = (lval!=0); }

For each signed integer type, readChild(Long) is called by default and the results is simply casted to the original type.

Definition at line 211 of file mlTreeNode.h.

#define READ_ULONG_CHILD   { unsigned long lval=0; readChild(lval, name); val = lval; }

For each unsigned integer type, readChild(ULong) is called by default and the results is simply casted to the original type.

Definition at line 202 of file mlTreeNode.h.

#define VOID_IMPLEMENTATION (   which)    { throw TreeNodeException(TNE_VoidImplementation, which); }

Standard body for a method in this interface class.

Definition at line 165 of file mlTreeNode.h.

Referenced by ml::TreeNode::setVersion().

#define VOID_IMPLEMENTATION_RET (   which,
 
)    { if (MLAlwaysTrue){ throw TreeNodeException(TNE_VoidImplementation, which); } return R; }

Standard body for a method in this interface class.

The implementation also returns NULL to avoid compiler warnings. Use "if (MLIsAlwaysTrue)" and "return R;" to avoid silly compilers which warn unreachable code if return is written after throw but also missing returns in functions if return is not written.

Definition at line 171 of file mlTreeNode.h.

Referenced by ml::TreeNode::correctName(), ml::TreeNode::getLastReadChildName(), ml::TreeNode::getVersion(), and ml::TreeNode::isCorrectName().