MeVisLab Toolbox Reference
mlListBase.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_LIST_BASE_H
14#define ML_LIST_BASE_H
15
16
18
19// Defines the following classes:
20// - ListBase: An abstract class derived from Base providing methods available
21// for all list classes.
22// - ListTemplate: A class template derived from ListBase and std::vector.
23// It implements the persistence functionality of a list.
24// - BaseListTemplate: A class template derived from ListTemplate. It should be
25// used for item classes that are subclasses of BaseItem.
26// - For class BaseItem see mlBaseItem.h.
27
28// ML-includes
29#include "mlBaseInit.h"
30#include "mlModuleIncludes.h"
31#include "mlTreeNode.h"
32#include "mlStringConversion.h"
33
34
35
36#include "mlListParser.h"
37
38// Also include BaseItem although it is not needed here; however many derived classes still expect it.
39#include "mlBaseItem.h"
40
41// Safe casts.
42#include "mlRangeCasts.h"
43
44#include <algorithm>
45
47
48class BaseItem;
49
50// ------------------------------------------------------------------
52// ------------------------------------------------------------------
53
63{
64public:
65
68 : _hasPersistance(persistance),
69 _actionClass(ActNew),
70 _actionId(-1),
71 _actionIndex(-1),
72 _currentIndex(-1)
73 {}
74
76 : _hasPersistance(other.hasPersistance()),
77 _actionClass(other.getActionClass()),
78 _actionId(other.getActionId()),
79 _actionIndex(other.getActionIndex()),
80 _currentIndex(other.getCurrentIndex())
81 {}
82
85
87 virtual size_t getSize () const = 0;
88
94 virtual BaseItem* getItemAt(MLssize_t /*index*/) { return nullptr; };
95
97 virtual const BaseItem* getConstItemAt(MLssize_t /*index*/) const { return nullptr; };
98
102 virtual void insertItemAt(MLssize_t /*index*/, const BaseItem* /*item*/) {};
103
107 virtual void modifyItemAt(MLssize_t /*index*/, const BaseItem* /*item*/) {};
108
112 virtual void deleteItemAt(MLssize_t /*index*/) {};
113
117 virtual void selectItemAt(MLssize_t /*index*/) {};
118
122 virtual const RuntimeType* getItemTypeId() const { return nullptr; };
123
125 virtual void clearList ()
126 { setAction(ActNew); }
127
134 virtual ListBase* clone() const { return nullptr; };
135
137 ListBase* deepCopy() const override { return clone(); };
138
140
141
150
152 virtual bool hasPersistance () const { return _hasPersistance; }
153
155 virtual void setPersistance (bool persistance) { _hasPersistance = persistance; }
156
158 MLBASEEXPORT friend std::ostream& operator << (std::ostream &s, const ListBase &list);
159
161 void addStateToTree(TreeNode* parent) const override;
162
165
167 void readStateFromTree(TreeNode* parent) override;
168
170
171
185
188 {
189 ActNone = 0,
192 ActSelect,
195 ActDelete,
198 ActInsertOvw,
202 ActNumActions
203 };
204
206 static const char *const ActionClassNames[ActNumActions];
207
210
213 { setAction(actionClass, -1, -1); }
214
216 virtual void getAction (ActionClass &actionClass, MLssize_t &id, MLssize_t &index) const;
217
220 { return _actionClass; }
221
223 virtual MLssize_t getActionId () const
224 { return _actionId; }
225
229 virtual MLssize_t getActionIndex () const
230 { return _actionIndex; }
231
233 virtual MLssize_t getCurrentIndex () const
234 { return _currentIndex; }
235
237 virtual bool isModified () const
238 { return (ActSelect != _actionClass && ActNone != _actionClass); }
239
240
242
243
244protected:
245
249 char *newString (const std::string &str) const
250 { return ParserBase::newString(str); }
251
253 void deleteString (char *str) const
255
257 ListBase &operator = (const ListBase &list);
258
259private:
260
262 bool _hasPersistance;
263
265 ActionClass _actionClass;
266
268 MLssize_t _actionId;
269
271 MLssize_t _actionIndex;
272
274 MLssize_t _currentIndex;
275
276
278
279};
280
281
282
283// ------------------------------------------------------------------
285// ------------------------------------------------------------------
286
310template <class T>
311class ListTemplate : public ListBase, public std::vector<T>
312{
313public:
314
317 typedef T itemType;
318
319
322
325
328
330
332
333
336
338 size_t getSize () const override
339 { using namespace std; return vector<T>::size(); }
340
342 void clearList () override
343 { ListBase::clearList(); using namespace std; vector<T>::clear(); }
344
345
347 ListTemplate<T> &operator = (const ListTemplate<T> &list)
348 {
349 using namespace std;
350
351 ListBase::operator =(list);
352 vector<T>::operator =(list);
353
354 return *this;
355 }
356
361 ListTemplate<T>* clone() const override;
362
364 ListTemplate<T>* deepCopy() const override { return clone(); };
365
367
368
372 std::string persistentState() const override;
373
375 void setPersistentState(const std::string& state) override;
376
377
378public:
379
381 void addStateToTree(TreeNode* parent) const override;
382
385
387 void readStateFromTree(TreeNode* parent) override;
388
390
391protected:
392
403
406 virtual std::string itemState([[maybe_unused]] typename ListTemplate<T>::const_iterator it) const
407 {
408 return {};
409 }
410
412 virtual void setItemState(typename ListTemplate<T>::iterator /*it*/, const std::string& /*state*/) {}
413};
414
415
416
417// ------------------------------------------------------------------
418// Implementation of ListTemplate
419// ------------------------------------------------------------------
420
421template <class T>
423{
424 std::string listStr;
425
426 using namespace std;
427
428 if (hasPersistance())
429 {
430 // Start list with an opening bracket
431 listStr = "[";
432
433 // Iterate through list
434 for (auto it = vector<T>::begin(); it != vector<T>::end(); ++it)
435 {
436 // Separate items by a comma
437 if (it != vector<T>::begin()) {
438 listStr += ", ";
439 }
440
441 // Get string representation for item object
442 auto itemStr = itemState(it);
443 if (!itemStr.empty())
444 {
445 if (ListParser::needsQuote(itemStr))
446 {
447 listStr += ListParser::quoteString(itemStr);
448 }
449 else {
450 listStr += itemStr;
451 }
452 }
453 else
454 // Empty item string, add "" to list string
455 listStr += "\"\"";
456 }
457
458 // End list with a closing bracket
459 listStr += ']';
460 }
461
462 return listStr;
463}
464
465template <class T> void ListTemplate<T>::setPersistentState(const std::string &state)
466{
467 using namespace std;
468
469 if (hasPersistance())
470 {
472
473 // Start with empty list
474 clearList();
475
476 // Initialize parser
477 auto parserResult = parser.init(state.c_str());
478
479 while (!parserResult)
480 {
481 // Parse next item string
482 std::string itemString;
483 std::tie(parserResult, itemString) = parser.nextItem();
484 if (!itemString.empty() && parserResult != ListParser::kEndOfSource)
485 {
486 // Append new item object at end of list
487 vector<T>::insert(vector<T>::end(), T());
488
489 // Restore item object from item string
490 setItemState(vector<T>::end() - 1, itemString);
491 }
492 }
493
494 // Set list action
495 setAction(ListBase::ActNew);
496
497 // Print error message to console
498 if (parserResult > 0 && parserResult != ParserBase::kEmptyString) {
499 ML_PRINT_ERROR("ListTemplate::setPersistentState()", ML_EMPTY_MESSAGE,
500 parser.getErrorMessage(parserResult));
501 }
502 }
503}
504
505
509template <class T>
511{
512 using namespace std;
513
514 //if (!hasPersistance()) return;
515
517
518 // add listbase members
520
521 // write list size always as unsigned 64 bit integer.
522 parent->addChild(static_cast<MLuint64>(vector<T>::size()), "ListSize");
523
524 // write list items:
525 TreeNode* items = parent->addChild("ListItems");
526
527 // Iterate through list
528 for (auto it = vector<T>::cbegin(); it != vector<T>::cend(); ++it)
529 {
530 auto state = itemState(it);
531 items->addChild(state, "Item");
532 }
533
534}
535
537template <class T>
539{
540 using namespace std;
541
542 if (!hasPersistance()) { return; }
543
544 int version = parent->getVersion("ListTemplate");
545
546 // Currently supporting version <= 2 only, version 2 is saved by 64 bit systems.
547 if (version > 2){
548 // Error, too high version number.
550 }
551
552 if (version >= 1) {
553 // ListBase saves its members since version 1:
555 }
556
557 bool endLoop = false;
558
559 clearList();
560
561 // read size if possible
563 ML_READCHILD_OPTIONAL(loadedSize, "ListSize", 0);
564
565 // reserve some memory for the list. However, we do really want to rely on the ListSize
566 // setting and still read until a child is not found.
567 vector<T>::reserve( loadedSize );
568
569 TreeNode* items = parent->readContainerChild("ListItems");
570
571 std::string currStr;
572 do {
573 // try to read next child:
574 if (items->hasChild()) {
575 items->readChild(currStr);
576 } else {
577 // break free from loop
578 endLoop = true;
579 }
580 if (!endLoop) {
581
582 vector<T>::insert(vector<T>::end(), T());
583
584 // Restore item object from item string
585 setItemState(vector<T>::end()-1, currStr);
586
587 currStr = {};
588 }
589 } while (!endLoop);
590
591 // Set list action
592 setAction(ListBase::ActNew);
593}
594
595
596
601template <class T>
603{
604 // get runtime type of this instance
605 const RuntimeType* thisType = this->getTypeId();
606
607 // valid type?
608 if (!thisType || !thisType->canCreateInstance()) {
609 // invalid type
610 return nullptr;
611 }
612
613 ListTemplate<T>* newList = static_cast<ListTemplate<T>*>(thisType->createInstance());
614 if (!newList) {
615 // object creation failed
616 return nullptr;
617 }
618
619 (*newList) = (*this);
620
621 return newList;
622}
623
624
625
626
627
628// ------------------------------------------------------------------
630// ------------------------------------------------------------------
631
652template <class T>
654{
655public:
656
659
661 BaseListTemplate () : ListTemplate<T>(), _nextId(1) {}
662
665
667
669
672
678 BaseItem* getItemAt(MLssize_t index) override{
679 return &(*this)[mlrange_cast<size_t>(index)];
680 };
681
683 const BaseItem* getConstItemAt(MLssize_t index) const override {
684 return &(*this)[mlrange_cast<size_t>(index)];
685 };
686
691 void insertItemAt(MLssize_t index, const BaseItem* item) override {
692 if (item && (getItemTypeId() == item->getTypeId())) {
693 doInsertItem(index, *static_cast<const T*>(item) );
694 }
695 };
696
697
702 void modifyItemAt(MLssize_t index, const BaseItem* item) override {
703 if (item && (getItemTypeId() == item->getTypeId())) {
704 doModifyItem(index, *static_cast<const T*>(item) );
705 }
706 };
707
712 void deleteItemAt(MLssize_t index) override {
713 doDeleteItem(index);
714 };
715
720 void selectItemAt(MLssize_t index) override {
721 doSelectItem(index);
722 };
723
727 const RuntimeType* getItemTypeId() const override {
728 return T::getClassTypeId();
729 }
730
731
734
736 virtual MLssize_t newId () { return _nextId++; }
737
739 virtual void usedId (MLssize_t id)
740 {
741 if (id >= _nextId) {
742 _nextId = id+1;
743 }
744 }
745
747 virtual void resetId ()
748 {
749 _nextId = 1;
750 for (typename ListTemplate<T>::iterator it = ListTemplate<T>::begin(); it != ListTemplate<T>::end(); it++){
751 usedId(it->getId());
752 }
753 }
754
756
758 void clearList () override
759 {
761 resetId();
762 }
763
764
774
776 virtual void doDeleteItem (MLssize_t index);
777
780 virtual void doInsertItem (MLssize_t index, const T &item);
781
784 virtual void doModifyItem (MLssize_t index, const T &item);
785
788 virtual void doSelectItem (MLssize_t index);
789
792 virtual void appendItem(const T &item);
793
795 void addStateToTree(TreeNode* parent) const override;
796
798
803
805 void readStateFromTree(TreeNode* parent) override;
806
807
808
810
811
812protected:
813
821 std::string itemState(typename ListTemplate<T>::const_iterator it) const override
822 {
823 return it->persistentState();
824 }
825
827 void setItemState(typename ListTemplate<T>::iterator it, const std::string& state) override
828 {
829 it->setPersistentState(state);
830 usedId(it->getId());
831 }
832
833private:
834
836 MLssize_t _nextId;
837
838};
839
840
841
842
843// ------------------------------------------------------------------
844// --- Implementation of BaseListTemplate
845// ------------------------------------------------------------------
846
848template <class T>
850{
851 if ((index >= 0) && (index < static_cast<MLssize_t>(ListTemplate<T>::size())) )
852 {
853 this->setAction(ListTemplate<T>::ActDelete, (*this)[mlrange_cast<size_t>(index)].getId(), index);
855 }
856}
857
858
861template <class T>
863{
864 MLssize_t id=0;
865
866 if ((index >= 0) && (index <= mlrange_cast<MLssize_t>(ListTemplate<T>::size())) )
867 {
869 id = newId();
870 (*this)[static_cast<size_t>(index)].setId(id);
871 this->setAction(ListTemplate<T>::ActInsert, id, index);
872 }
873}
874
877template <class T>
879{
880 doInsertItem(static_cast<MLssize_t>(ListTemplate<T>::size()), item);
881}
882
883
886template <class T>
888{
889 if ((index >= 0) && (index < mlrange_cast<MLssize_t>(ListTemplate<T>::size())) )
890 {
891 const size_t idx_size_t = static_cast<size_t>(index);
892 const MLssize_t id = (*this)[idx_size_t].getId();
893 (*this)[idx_size_t] = item;
894 (*this)[idx_size_t].setId(id);
895 this->setAction(ListTemplate<T>::ActModify, id, index);
896 }
897}
898
899
902template <class T>
904{
905 if ((index >= 0) && (index < mlrange_cast<MLssize_t>(ListTemplate<T>::size())) )
906 {
907 this->setAction(ListTemplate<T>::ActSelect, (*this)[static_cast<size_t>(index)].getId(), index);
908 }
909 else if (index == -1)
910 {
911 // deselect all
912 this->setAction(ListTemplate<T>::ActSelect);
913 }
914}
915
916
920template <class T>
922{
924
925 // add ListBase members
927
928 typename BaseListTemplate<T>::const_iterator it;
929 MLuint64 i = 0;
930
931 // write list size
932 parent->addChild(static_cast<MLuint64>(ListTemplate<T>::size()), "ListSize");
933
934 TreeNode* items = parent->addChild("ListItems");
935
936 // Iterate through list
938 {
939 items->addChild(&(*it), "Item", false);
940 }
941
942}
943
945template <class T>
947{
948 int version = parent->getVersion("BaseListTemplate");
949
950 // Currently supporting version <= 2 only, version 2 is 64 bit version.
951 if (version > 2) {
953 }
954
955 if (version >= 1) {
956 // ListBase saves its members since version 1:
958 }
959
960 bool endLoop = false;
961
962 clearList(); // includes _nextId = 1;
963
964 // read size if possible
966 ML_READCHILD_OPTIONAL(loadedSize, "ListSize", 0);
967
968 // reserve some memory for the list. However, we do not really want to rely on the ListSize
969 // setting and still read until a child is not found.
971
972 TreeNode* items = parent->readContainerChild("ListItems");
973
974 if (items) do {
975 // try to read next child:
976 if (items->hasChild()) {
978 items->readChild(*(ListTemplate<T>::end()-1));
979 } else {
980 // break free from loop
981 endLoop = true;
982 }
983 if (ListTemplate<T>::size() > 0){
984 // update _nextId:
985 _nextId = std::max(_nextId, (ListTemplate<T>::end()-1)->getId() + 1);
986 } else {
987 endLoop = true;
988 }
989 } while (!endLoop);
990
991 // Set list action
992 this->setAction(ListTemplate<T>::ActNew);
993}
994
995
997
998
999#endif
@ T
General Base object class for list items that have an id and a name.
Definition mlBaseItem.h:38
Base object template list class for list item classes derived from BaseItem.
Definition mlListBase.h:654
void deleteItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
Definition mlListBase.h:712
virtual MLssize_t newId()
Get new unused id.
Definition mlListBase.h:736
void setItemState(typename ListTemplate< T >::iterator it, const std::string &state) override
Initialize the item object from the string state.
Definition mlListBase.h:827
BaseListTemplate()
Standard constructor, disables persistence.
Definition mlListBase.h:661
void addStateToTree(TreeNode *parent) const override
Attaches the object state as children of the given parent node.
Definition mlListBase.h:921
void modifyItemAt(MLssize_t index, const BaseItem *item) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
Definition mlListBase.h:702
ML_SET_ADDSTATE_VERSION(1)
Set addState version number.
virtual void doDeleteItem(MLssize_t index)
Delete single item at position index and set the corresponding ActDelete action.
Definition mlListBase.h:849
std::string itemState(typename ListTemplate< T >::const_iterator it) const override
Return a string representation of the item object.
Definition mlListBase.h:821
virtual void doInsertItem(MLssize_t index, const T &item)
Insert item at position index, assign a new id value to the inserted item and set the corresponding A...
Definition mlListBase.h:862
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
Definition mlListBase.h:946
BaseListTemplate< T > & operator=(const BaseListTemplate &other)=default
explicitly create default assignment operator
virtual void appendItem(const T &item)
Appends an item to the list.
Definition mlListBase.h:878
BaseItem * getItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it returns 0 in any case (also in ListTem...
Definition mlListBase.h:678
const BaseItem * getConstItemAt(MLssize_t index) const override
Same as getItemAt(MLssize_t index) for constant access.
Definition mlListBase.h:683
BaseListTemplate(const BaseListTemplate &other)
Definition mlListBase.h:666
void selectItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
Definition mlListBase.h:720
void insertItemAt(MLssize_t index, const BaseItem *item) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
Definition mlListBase.h:691
virtual void doSelectItem(MLssize_t index)
Select item at position index, or deselect if item == -1, and set the corresponding ActSelect action.
Definition mlListBase.h:903
BaseListTemplate(bool persistance)
Special constructor to explicitly enable/disable persistence.
Definition mlListBase.h:664
virtual void usedId(MLssize_t id)
Notify list that id is used.
Definition mlListBase.h:739
void clearList() override
Clear complete list.
Definition mlListBase.h:758
virtual void resetId()
Reset next id.
Definition mlListBase.h:747
const RuntimeType * getItemTypeId() const override
This virtual function is reimplemented from ListBase, where it returns 0 in any case (also in ListTem...
Definition mlListBase.h:727
virtual void doModifyItem(MLssize_t index, const T &item)
Store item at position index and set the corresponding ActModify action.
Definition mlListBase.h:887
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Definition mlBase.h:59
Base object class ListBase managing a number of BaseItem objects.
Definition mlListBase.h:63
virtual void clearList()
Clear complete list.
Definition mlListBase.h:125
virtual MLssize_t getActionId() const
Get id of item affected by last action.
Definition mlListBase.h:223
char * newString(const std::string &str) const
Convenience method to create a copy of the string str allocated on the heap.
Definition mlListBase.h:249
virtual MLssize_t getActionIndex() const
Get index of item affected by last action.
Definition mlListBase.h:229
ListBase * deepCopy() const override
Create a deep copy of the list.
Definition mlListBase.h:137
ML_SET_ADDSTATE_VERSION(0)
Set addState version number.
virtual const RuntimeType * getItemTypeId() const
This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item cla...
Definition mlListBase.h:122
ActionClass
Constants to describe the type of action most recently performed.
Definition mlListBase.h:188
@ ActInsert
List item inserted.
Definition mlListBase.h:197
@ ActModify
Current list item modified.
Definition mlListBase.h:194
@ ActNew
New list generated.
Definition mlListBase.h:191
@ ActUnknown
Unknown action.
Definition mlListBase.h:190
virtual void selectItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually selects the item at ...
Definition mlListBase.h:117
virtual MLssize_t getCurrentIndex() const
Get index of currently selected item, or -1 if no item selected.
Definition mlListBase.h:233
virtual bool hasPersistance() const
Test if persistence is available and enabled.
Definition mlListBase.h:152
virtual void deleteItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually deletes the item at ...
Definition mlListBase.h:112
virtual bool isModified() const
Tests, if the last action has been an action that has modified the content of the list.
Definition mlListBase.h:237
virtual size_t getSize() const =0
Get number of list elements.
virtual const BaseItem * getConstItemAt(MLssize_t) const
Same as getItemAt(MLssize_t index) for constant access.
Definition mlListBase.h:97
void addStateToTree(TreeNode *parent) const override
Attaches the state as children of the given parent node.
virtual ActionClass getActionClass() const
Get actionClass of last action.
Definition mlListBase.h:219
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
virtual void setAction(ActionClass actionClass, MLssize_t id, MLssize_t index)
Set actionClass, affected item id and index.
virtual void getAction(ActionClass &actionClass, MLssize_t &id, MLssize_t &index) const
Get actionClass, affected item id and index.
virtual void setPersistance(bool persistance)
Enable/disable persistence functionality.
Definition mlListBase.h:155
virtual void setAction(ActionClass actionClass)
Set actionClass for actions affecting the whole list.
Definition mlListBase.h:212
virtual BaseItem * getItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item at ...
Definition mlListBase.h:94
virtual ListBase * clone() const
Create a copy of (*this) using the ML runtime system and the '='-operator.
Definition mlListBase.h:134
void deleteString(char *str) const
Dispose a string allocated with newString()
Definition mlListBase.h:253
ListBase(const ListBase &other)
Definition mlListBase.h:75
virtual void modifyItemAt(MLssize_t, const BaseItem *)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually modifies the item at...
Definition mlListBase.h:107
virtual void insertItemAt(MLssize_t, const BaseItem *)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually inserts the item at ...
Definition mlListBase.h:102
ListBase(bool persistance)
Constructor. Derived class should indicate whether persistence is implemented.
Definition mlListBase.h:67
Parser class for parsing persistent state strings of list objects.
Basic list class template combining properties of ListBase and a vector of the template argument type...
Definition mlListBase.h:312
virtual void setItemState(typename ListTemplate< T >::iterator, const std::string &)
Initialize the item object from the string state.
Definition mlListBase.h:412
ML_SET_ADDSTATE_VERSION(2)
Set addState version number, version 2 indicates data saved by a 64 bit version.
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
Definition mlListBase.h:538
ListTemplate()
Standard constructor, disables persistence.
Definition mlListBase.h:324
size_t getSize() const override
Get number of list elements.
Definition mlListBase.h:338
ListTemplate< T > * clone() const override
Create a copy of (*this) using the ML runtime system and the '='-operator.
Definition mlListBase.h:602
ListTemplate(bool persistance)
Special constructor to explicitly enable/disable persistence.
Definition mlListBase.h:327
T itemType
Declare type name for item type (this allows declarations like: ObjectList::itemType obj)
Definition mlListBase.h:317
void clearList() override
Clear complete list.
Definition mlListBase.h:342
virtual std::string itemState(typename ListTemplate< T >::const_iterator it) const
Return a string representation of the item object.
Definition mlListBase.h:406
void addStateToTree(TreeNode *parent) const override
Attaches the state as children of the given parent node.
Definition mlListBase.h:510
ListTemplate(const ListTemplate &other)
Definition mlListBase.h:329
void setPersistentState(const std::string &state) override
Initialize the list object from the string state.
Definition mlListBase.h:465
ListTemplate< T > * deepCopy() const override
Create a deep copy of the list.
Definition mlListBase.h:364
std::string persistentState() const override
Returns a string describing the object's internal state.
Definition mlListBase.h:422
static char * newString(const std::string &str)
Convenience method to create a copy of the string str allocated on the heap.
static void deleteString(char *str)
Dispose a string allocated with newString()
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
bool canCreateInstance() const
Returns true if this (runtime)type knows how to create an instance of the class.
The class TreeNodeException is the base class for all exceptions thrown by the class TreeNode and all...
Definition mlTreeNode.h:95
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition mlTreeNode.h:154
virtual void addChild(bool val, const char *name) ADD_ULONG_CHILD
Factory method adding a child encapsulating a variable of type bool.
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
#define ML_EMPTY_MESSAGE
The following error message describes more precise what has happened; if not then a non registered er...
Definition mlTypeDefs.h:795
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition mlBaseInit.h:22
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#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 ...
Definition mlTreeNode.h:626
#define ML_ADDSTATE_VERSION(ThisClass)
Use this macro in addStateToTree() for classes that might need versioning in the future.
Definition mlTreeNode.h:635
#define ML_ADDSTATE_SUPER(SuperClass)
Use this macro if you would like to store your super class members as well.
Definition mlTreeNode.h:639
#define ML_READSTATE_SUPER(SuperClass)
Use this macro if you would like to store your super class members as well.
Definition mlTreeNode.h:646
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
Definition mlTypeDefs.h:425
SSIZE_T MLssize_t
The signed ML size type which is a signed 32 bit size_t on 32 bit platforms and 64 bit one on 64 bit ...
Definition mlTypeDefs.h:566
std::ostream & operator<<(std::ostream &out, const KeyFrame &frame)
KeyFrame stream output.
@ TNE_UnsupportedClassVersion
Definition mlTreeNode.h:73
STL namespace.