130 std::string _message;
134 static const char* _stdErrorMsg[];
143#define TREE_NODE_CHECK_THROW(x) \
146 throw TreeNodeException(TNE_UserDefined, #x); \
167#define VOID_IMPLEMENTATION(which) \
169 throw TreeNodeException(TNE_VoidImplementation, which); \
176#define VOID_IMPLEMENTATION_RET(which, R) \
178 if (MLAlwaysTrue) { \
179 throw TreeNodeException(TNE_VoidImplementation, which); \
185#define ADD_LONG_CHILD \
187 addChild(static_cast<long>(val), name); \
191#define ADD_ULONG_CHILD \
193 addChild(static_cast<unsigned long>(val), name); \
197#define ADD_LDOUBLE_CHILD \
199 addChild(static_cast<long double>(val), name); \
204#define READ_LONG_CHILD(DST_TYPE) \
207 readChild(lval, name); \
208 val = static_cast<DST_TYPE>(lval); \
213#define READ_ULONG_CHILD(DST_TYPE) \
215 unsigned long lval = 0; \
216 readChild(lval, name); \
217 val = static_cast<DST_TYPE>(lval); \
222#define READ_LDOUBLE_CHILD(DST_TYPE) \
224 long double ldval = 0; \
225 readChild(ldval, name); \
226 val = static_cast<DST_TYPE>(ldval); \
231#define READ_LONG_CHILD_FOR_BOOL \
234 readChild(lval, name); \
344 virtual void addChild(
const std::string& ,
const char* )
372 virtual void addChild(
const SubImageBoxd& ,
const char* )
377 virtual void addChild(
const void*
const ,
size_t ,
const char* )
384 virtual void addChild(
const Base*
const ,
const char* ,
bool =
true)
438 virtual void readChild(
unsigned long& ,
const char* =
nullptr)
454 virtual void readChild(
long double& ,
const char* =
nullptr)
490 virtual void readChild(
void*& ,
unsigned long& ,
const char* =
nullptr)
515 if (hasChild(name)) {
516 readChild(value, name);
549 TreeNode* node =
nullptr;
550 readChild(node, name);
565 Base*
objP =
nullptr;
566 readChild(
objP, name);
579 virtual void setVersion(
const char* ,
int )
585 virtual int getVersion(
const char* )
591 virtual const char* getLastReadChildName()
const
618 virtual void deleteMemory(
void* ) {};
633 TreeNode(ConstructionMode )
696#undef VOID_IMPLEMENTATION
697#undef ADD_ULONG_CHILD
699#undef ADD_LDOUBLE_CHILD
700#undef READ_ULONG_CHILD
701#undef READ_LONG_CHILD
702#undef READ_LDOUBLE_CHILD
703#undef READ_LONG_CHILD_FOR_BOOL
717#define ML_READCHILD_OPTIONAL(obj, tagName, defaultVal) \
718 if (parent->hasChild(tagName)) { \
719 parent->readChild(obj, tagName); \
727#define ML_ADDSTATE_VERSION(ThisClass) parent->setVersion("#ThisClass#", ThisClass::getAddStateVersion());
731#define ML_ADDSTATE_SUPER(SuperClass) \
733 TreeNode* superClassNode = parent->addChild("_" #SuperClass); \
734 SuperClass::addStateToTree(superClassNode); \
739#define ML_READSTATE_SUPER(SuperClass) \
741 TreeNode* superClassNode = parent->readContainerChild("_" #SuperClass); \
742 SuperClass::readStateFromTree(superClassNode); \
753#define ML_TREE_NODE_SUPPORT_VIA_PERSISTENT_STATE \
754 virtual void addStateToTree(TreeNode* parent) const \
756 auto state = persistentState(); \
757 if (state.empty()) { \
758 state = "Could not read object state."; \
760 parent->addChild(state, "State"); \
763 virtual void readStateFromTree(TreeNode* parent) \
766 parent->readChild(state, "State"); \
767 setPersistentState(state); \
Class representing general ML objects that support import/export via strings (setPersistentState() an...
SubImageBoxd - SubImageBox with coordinates of float data type.
The class TreeNodeException is the base class for all exceptions thrown by the class TreeNode and all...
virtual ~TreeNodeException()
Destructor.
int getCode() const
Returns the error code.
int _errorCode
The error code of the exception.
TreeNodeException(int errorCode=0, const char *msg=nullptr)
Creates a new exception object with code errorCode and an optional error message.
virtual const char * getMessage() const
Returns the error string.
The class TreeNode is the abstract base class for the import/export of ML objects.
virtual void addChild(char val, const char *name) ADD_LONG_CHILD
Factory method for adding a child encapsulating a variable of type char.
@ CM_readerRoot
Construct as root node for reading.
@ CM_writerRoot
Construct as root node for writing.
virtual ~TreeNode()
Destructor deleting all children of this node.
virtual void addChild(int val, const char *name) ADD_LONG_CHILD
Factory method for adding a child encapsulating a variable of type int.
virtual void addChild(MLint64, const char *) VOID_IMPLEMENTATION("addChild(MLint64)")
Factory method for adding a child encapsulating a variable of type MLint64.
virtual void addChild(unsigned short val, const char *name) ADD_ULONG_CHILD
Factory method for adding a child encapsulating a variable of type unsigned short.
virtual void addChild(double val, const char *name) ADD_LDOUBLE_CHILD
Factory method for adding a child encapsulating a variable of type double.
virtual void addChild(short val, const char *name) ADD_LONG_CHILD
Factory method for adding a child encapsulating a variable of type short.
virtual void writeToString(std::string &) VOID_IMPLEMENTATION("writeToString")
Generates a string representation of the subtree represented by this node to a file.
virtual void writeToFile(const char *) VOID_IMPLEMENTATION("writeToFile")
Writes the subtree represented by this node to a file.
virtual void addChild(unsigned int val, const char *name) ADD_ULONG_CHILD
Factory method for adding a child encapsulating a variable of type unsigned int.
virtual void addChild(unsigned char val, const char *name) ADD_ULONG_CHILD
Factory method for adding a child encapsulating a variable of type unsigned char.
virtual void addChild(long, const char *) VOID_IMPLEMENTATION("addChild(long)")
Factory method for adding a child encapsulating a variable of type long.
virtual void addChild(bool val, const char *name) ADD_ULONG_CHILD
Factory method for adding a child encapsulating a variable of type bool.
virtual void addChild(unsigned long, const char *) VOID_IMPLEMENTATION("addChild(unsigned long)")
Factory method for adding a child encapsulating a variable of type long.
virtual void addChild(MLuint64, const char *) VOID_IMPLEMENTATION("addChild(MLuint64)")
Factory method for adding a child encapsulating a variable of type MLuint64.
virtual void readFromFile(const char *) VOID_IMPLEMENTATION("readFromFile")
Reads the subtree represented by this node from a file.
virtual void addChild(float val, const char *name) ADD_LDOUBLE_CHILD
Factory method for adding a child encapsulating a variable of type float.
virtual void addChild(long double, const char *) VOID_IMPLEMENTATION("addChild(long double)")
Factory method for adding a child encapsulating a variable of type long double.
virtual void readFromString(const std::string &) VOID_IMPLEMENTATION("readFromString")
Reads the subtree represented by this node from a string.
#define MLEXPORT
To export symbols from a DLL/shared object, we need to mark them with the MLEXPORT symbol.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define ML_ABSTRACT_ROOT_CLASS_HEADER(className)
#define ML_ROOT_CLASS_HEADER(className)
#define ADD_LONG_CHILD
For each signed integer type, addChild(long) is called by default.
#define READ_LDOUBLE_CHILD(DST_TYPE)
For each floating point type, readChild(LDouble) is called by default and the results is simply cast ...
#define VOID_IMPLEMENTATION(which)
Standard body for a method in this interface class.
#define VOID_IMPLEMENTATION_RET(which, R)
Standard body for a method in this interface class.
#define READ_LONG_CHILD_FOR_BOOL
For each signed integer type, readChild(Long) is called by default and the results is simply cast to ...
#define ADD_LDOUBLE_CHILD
For each floating point type, addChild(LDouble) is called by default.
#define READ_LONG_CHILD(DST_TYPE)
For each signed integer type, readChild(Long) is called by default and the results is simply cast to ...
#define READ_ULONG_CHILD(DST_TYPE)
For each unsigned integer type, readChild(ULong) is called by default and the results is simply cast ...
#define ADD_ULONG_CHILD
For each unsigned integer type, addChild(ulong) is called by default.
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
@ TNE_UnsupportedClassVersion
@ TNE_ReadingSubImageBoxd