MeVisLab Toolbox Reference
mlTreeNode.h File Reference
#include "mlImageVector.h"
#include "mlInitSystemML.h"
#include "mlRuntimeType.h"
#include "mlRuntimeSubClass.h"
#include "mlSubImageBox.h"
#include "mlVector2.h"
#include "mlVector3.h"
#include "mlVector4.h"
#include "mlVector6.h"
#include <string>

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

 ml
 Main documentation file for ML users and developers.
 

Macros

#define TREE_NODE_CHECK_THROW(x)   { if (!(x)) throw TreeNodeException(TNE_UserDefined, #x); }
 Macro to throw a TreeNodeException from reading/writing if a condition is not satisfied. More...
 
#define VOID_IMPLEMENTATION(which)   { throw TreeNodeException(TNE_VoidImplementation, which); }
 Standard body for a method in this interface class. More...
 
#define VOID_IMPLEMENTATION_RET(which, R)   { if (MLAlwaysTrue){ throw TreeNodeException(TNE_VoidImplementation, which); } return R; }
 Standard body for a method in this interface class. More...
 
#define ADD_LONG_CHILD   { addChild(static_cast<long>(val), name); }
 For each signed integer type, addChild(long) is called by default. More...
 
#define ADD_ULONG_CHILD   { addChild(static_cast<unsigned long>(val), name); }
 For each unsigned integer type, addChild(ulong) is called by default. More...
 
#define ADD_LDOUBLE_CHILD   { addChild(static_cast<long double>(val), name); }
 For each floating point type, addChild(LDouble) is called by default. More...
 
#define READ_LONG_CHILD(DST_TYPE)   { long lval=0; readChild(lval, name); val = static_cast<DST_TYPE>(lval); }
 For each signed integer type, readChild(Long) is called by default and the results is simply casted to the original type. More...
 
#define READ_ULONG_CHILD(DST_TYPE)   { unsigned long lval=0; readChild(lval, name); val = static_cast<DST_TYPE>(lval); }
 For each unsigned integer type, readChild(ULong) is called by default and the results is simply casted to the original type. More...
 
#define READ_LDOUBLE_CHILD(DST_TYPE)   { long double ldval=0; readChild(ldval, name); val = static_cast<DST_TYPE>(ldval); }
 For each floating point type, readChild(LDouble) is called by default and the results is simply casted to the original type. More...
 
#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. More...
 
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. More...
 
#define ML_ADDSTATE_VERSION(ThisClass)   parent->setVersion("#ThisClass#", ThisClass::getAddStateVersion());
 Use this macro in addStateToTree() for classes that might need versioning in the future. More...
 
#define ML_ADDSTATE_SUPER(SuperClass)
 Use this macro if you would like to store your super class members as well. More...
 
#define ML_READSTATE_SUPER(SuperClass)
 Use this macro if you would like to store your super class members as well. More...
 
#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. More...
 

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_ReadingVector2 , ml::TNE_ReadingVector3 , ml::TNE_ReadingVector4 ,
  ml::TNE_ReadingVector6 , ml::TNE_ReadingImageVector , ml::TNE_ReadingMatrix3 , ml::TNE_ReadingMatrix4 ,
  ml::TNE_ReadingSubImageBox , ml::TNE_ReadingSubImageBoxd , 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...
 

Macro Definition Documentation

◆ ADD_LDOUBLE_CHILD

#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 193 of file mlTreeNode.h.

◆ ADD_LONG_CHILD

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

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

Definition at line 187 of file mlTreeNode.h.

◆ ADD_ULONG_CHILD

#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 190 of file mlTreeNode.h.

◆ ML_ADDSTATE_SUPER

#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 693 of file mlTreeNode.h.

◆ ML_ADDSTATE_VERSION

#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 689 of file mlTreeNode.h.

◆ ML_READCHILD_OPTIONAL

#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 680 of file mlTreeNode.h.

◆ ML_READSTATE_SUPER

#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 versioning.

Definition at line 700 of file mlTreeNode.h.

◆ ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE

#define ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE
Value:
virtual void addStateToTree(TreeNode* parent) const \
{ \
auto state = persistentState(); \
if (state.empty()){ state = "Could not read object state."; } \
parent->addChild(state, "State"); \
} \
\
virtual void readStateFromTree(TreeNode* parent) \
{ \
std::string state; \
parent->readChild(state, "State"); \
setPersistentState(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 713 of file mlTreeNode.h.

◆ READ_LDOUBLE_CHILD

#define READ_LDOUBLE_CHILD (   DST_TYPE)    { long double ldval=0; readChild(ldval, name); val = static_cast<DST_TYPE>(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 205 of file mlTreeNode.h.

◆ READ_LONG_CHILD

#define READ_LONG_CHILD (   DST_TYPE)    { long lval=0; readChild(lval, name); val = static_cast<DST_TYPE>(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 197 of file mlTreeNode.h.

◆ READ_LONG_CHILD_FOR_BOOL

#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 209 of file mlTreeNode.h.

◆ READ_ULONG_CHILD

#define READ_ULONG_CHILD (   DST_TYPE)    { unsigned long lval=0; readChild(lval, name); val = static_cast<DST_TYPE>(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 201 of file mlTreeNode.h.

◆ TREE_NODE_CHECK_THROW

#define TREE_NODE_CHECK_THROW (   x)    { if (!(x)) throw TreeNodeException(TNE_UserDefined, #x); }

Macro to throw a TreeNodeException from reading/writing if a condition is not satisfied.

Definition at line 158 of file mlTreeNode.h.

◆ VOID_IMPLEMENTATION

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

Standard body for a method in this interface class.

Definition at line 178 of file mlTreeNode.h.

◆ VOID_IMPLEMENTATION_RET

#define VOID_IMPLEMENTATION_RET (   which,
  R 
)    { 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 184 of file mlTreeNode.h.