ML 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
class  ml::TreeNode

Namespaces

namespace  ml
 Defines the class GetTileJob.

Macros

#define TREE_NODE_CHECK_THROW(x)
 Macro to throw a TreeNodeException from reading/writing if a condition has not been satisfied.
#define VOID_IMPLEMENTATION(which)
 Standard body for a method in this interface class.
#define VOID_IMPLEMENTATION_RET(which, R)
#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(DST_TYPE)
#define READ_ULONG_CHILD(DST_TYPE)
#define READ_LDOUBLE_CHILD(DST_TYPE)
#define READ_LONG_CHILD_FOR_BOOL   { long lval=0; readChild(lval, name); val = (lval!=0); }
Macros
#define ML_READCHILD_OPTIONAL(obj, tagName, defaultVal)
#define ML_ADDSTATE_VERSION(ThisClass)
 Use this macro in addStateToTree() for classes that might need versioning in the future.
#define ML_ADDSTATE_SUPER(SuperClass)
#define ML_READSTATE_SUPER(SuperClass)
#define ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE

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
}

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

Referenced by ml::TreeNode::addChild(), and ml::TreeNode::addChild().

◆ 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 171 of file mlTreeNode.h.

Referenced by ml::TreeNode::addChild(), ml::TreeNode::addChild(), and ml::TreeNode::addChild().

◆ 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 174 of file mlTreeNode.h.

Referenced by ml::TreeNode::addChild(), ml::TreeNode::addChild(), ml::TreeNode::addChild(), and ml::TreeNode::addChild().

◆ 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 superclass members as well. Mandatory if the superclass uses versioning.

Definition at line 664 of file mlTreeNode.h.

◆ ML_ADDSTATE_VERSION

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

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

Definition at line 660 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 651 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 superclass members as well. Mandatory if the superclass uses versioning.

Definition at line 671 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 if you already implemented the get/setPersistentState() methods but you would also like to support for the TreeNode import/export methods without any extra efforts. However, it is 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 684 of file mlTreeNode.h.

◆ READ_LDOUBLE_CHILD

#define READ_LDOUBLE_CHILD ( DST_TYPE)
Value:
{ 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 cast to the original type.

Definition at line 189 of file mlTreeNode.h.

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

◆ READ_LONG_CHILD

#define READ_LONG_CHILD ( DST_TYPE)
Value:
{ 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 cast to the original type.

Definition at line 181 of file mlTreeNode.h.

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

◆ 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 cast to the original type.

Definition at line 193 of file mlTreeNode.h.

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

◆ READ_ULONG_CHILD

#define READ_ULONG_CHILD ( DST_TYPE)
Value:
{ 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 cast to the original type.

Definition at line 185 of file mlTreeNode.h.

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

◆ TREE_NODE_CHECK_THROW

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

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

Definition at line 142 of file mlTreeNode.h.

◆ VOID_IMPLEMENTATION

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

Standard body for a method in this interface class.

Definition at line 162 of file mlTreeNode.h.

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

◆ VOID_IMPLEMENTATION_RET

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

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 compilers warnings that warn about unreachable code if return is specified after throw, but also warn about missing returns in functions if return is not specified.

Definition at line 168 of file mlTreeNode.h.

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