76 : _hasPersistance(
other.hasPersistance()),
77 _actionClass(
other.getActionClass()),
78 _actionId(
other.getActionId()),
79 _actionIndex(
other.getActionIndex()),
80 _currentIndex(
other.getCurrentIndex())
126 { setAction(ActNew); }
206 static const char *
const ActionClassNames[ActNumActions];
220 {
return _actionClass; }
224 {
return _actionId; }
230 {
return _actionIndex; }
234 {
return _currentIndex; }
238 {
return (ActSelect != _actionClass && ActNone != _actionClass); }
262 bool _hasPersistance;
339 {
using namespace std;
return vector<T>::size(); }
343 { ListBase::clearList();
using namespace std; vector<T>::clear(); }
351 ListBase::operator =(list);
352 vector<T>::operator =(list);
412 virtual void setItemState(
typename ListTemplate<T>::iterator ,
const std::string& ) {}
428 if (hasPersistance())
434 for (
auto it = vector<T>::begin();
it != vector<T>::end(); ++
it)
437 if (
it != vector<T>::begin()) {
445 if (ListParser::needsQuote(
itemStr))
469 if (hasPersistance())
487 vector<T>::insert(vector<T>::end(),
T());
490 setItemState(vector<T>::end() - 1,
itemString);
495 setAction(ListBase::ActNew);
528 for (
auto it = vector<T>::cbegin();
it != vector<T>::cend(); ++
it)
530 auto state = itemState(
it);
531 items->addChild(state,
"Item");
542 if (!hasPersistance()) {
return; }
544 int version = parent->getVersion(
"ListTemplate");
574 if (
items->hasChild()) {
582 vector<T>::insert(vector<T>::end(),
T());
585 setItemState(vector<T>::end()-1,
currStr);
592 setAction(ListBase::ActNew);
619 (*newList) = (*this);
692 if (
item && (getItemTypeId() ==
item->getTypeId())) {
693 doInsertItem(index, *
static_cast<const T*
>(
item) );
703 if (
item && (getItemTypeId() ==
item->getTypeId())) {
704 doModifyItem(index, *
static_cast<const T*
>(
item) );
728 return T::getClassTypeId();
821 std::string
itemState(
typename ListTemplate<T>::const_iterator
it)
const override
823 return it->persistentState();
827 void setItemState(
typename ListTemplate<T>::iterator
it,
const std::string& state)
override
829 it->setPersistentState(state);
870 (*this)[
static_cast<size_t>(index)].setId(
id);
891 const size_t idx_size_t =
static_cast<size_t>(index);
909 else if (index == -1)
928 typename BaseListTemplate<T>::const_iterator
it;
939 items->addChild(&(*
it),
"Item",
false);
948 int version = parent->getVersion(
"BaseListTemplate");
976 if (
items->hasChild()) {
General Base object class for list items that have an id and a name.
Base object template list class for list item classes derived from BaseItem.
void deleteItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
virtual MLssize_t newId()
Get new unused id.
void setItemState(typename ListTemplate< T >::iterator it, const std::string &state) override
Initialize the item object from the string state.
BaseListTemplate()
Standard constructor, disables persistence.
void addStateToTree(TreeNode *parent) const override
Attaches the object state as children of the given parent node.
void modifyItemAt(MLssize_t index, const BaseItem *item) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
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.
std::string itemState(typename ListTemplate< T >::const_iterator it) const override
Return a string representation of the item object.
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...
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
BaseListTemplate< T > & operator=(const BaseListTemplate &other)=default
explicitly create default assignment operator
virtual void appendItem(const T &item)
Appends an item to the list.
BaseItem * getItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it returns 0 in any case (also in ListTem...
const BaseItem * getConstItemAt(MLssize_t index) const override
Same as getItemAt(MLssize_t index) for constant access.
BaseListTemplate(const BaseListTemplate &other)
void selectItemAt(MLssize_t index) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
void insertItemAt(MLssize_t index, const BaseItem *item) override
This virtual function is reimplemented from ListBase, where it does nothing at all.
virtual void doSelectItem(MLssize_t index)
Select item at position index, or deselect if item == -1, and set the corresponding ActSelect action.
BaseListTemplate(bool persistance)
Special constructor to explicitly enable/disable persistence.
virtual void usedId(MLssize_t id)
Notify list that id is used.
void clearList() override
Clear complete list.
virtual void resetId()
Reset next id.
const RuntimeType * getItemTypeId() const override
This virtual function is reimplemented from ListBase, where it returns 0 in any case (also in ListTem...
virtual void doModifyItem(MLssize_t index, const T &item)
Store item at position index and set the corresponding ActModify action.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Base object class ListBase managing a number of BaseItem objects.
virtual void clearList()
Clear complete list.
virtual MLssize_t getActionId() const
Get id of item affected by last action.
char * newString(const std::string &str) const
Convenience method to create a copy of the string str allocated on the heap.
virtual MLssize_t getActionIndex() const
Get index of item affected by last action.
ListBase * deepCopy() const override
Create a deep copy of the list.
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...
ActionClass
Constants to describe the type of action most recently performed.
@ ActInsert
List item inserted.
@ ActModify
Current list item modified.
@ ActNew
New list generated.
@ ActUnknown
Unknown action.
virtual void selectItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually selects the item at ...
virtual MLssize_t getCurrentIndex() const
Get index of currently selected item, or -1 if no item selected.
virtual bool hasPersistance() const
Test if persistence is available and enabled.
virtual void deleteItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually deletes the item at ...
virtual bool isModified() const
Tests, if the last action has been an action that has modified the content of the list.
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.
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.
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.
virtual void setAction(ActionClass actionClass)
Set actionClass for actions affecting the whole list.
virtual BaseItem * getItemAt(MLssize_t)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item at ...
virtual ListBase * clone() const
Create a copy of (*this) using the ML runtime system and the '='-operator.
void deleteString(char *str) const
Dispose a string allocated with newString()
ListBase(const ListBase &other)
virtual void modifyItemAt(MLssize_t, const BaseItem *)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually modifies the item at...
virtual void insertItemAt(MLssize_t, const BaseItem *)
This virtual function is reimplemented in BaseListTemplate<T>, where it actually inserts the item at ...
ListBase(bool persistance)
Constructor. Derived class should indicate whether persistence is implemented.
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...
virtual void setItemState(typename ListTemplate< T >::iterator, const std::string &)
Initialize the item object from the string state.
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.
ListTemplate()
Standard constructor, disables persistence.
size_t getSize() const override
Get number of list elements.
ListTemplate< T > * clone() const override
Create a copy of (*this) using the ML runtime system and the '='-operator.
ListTemplate(bool persistance)
Special constructor to explicitly enable/disable persistence.
T itemType
Declare type name for item type (this allows declarations like: ObjectList::itemType obj)
void clearList() override
Clear complete list.
virtual std::string itemState(typename ListTemplate< T >::const_iterator it) const
Return a string representation of the item object.
void addStateToTree(TreeNode *parent) const override
Attaches the state as children of the given parent node.
ListTemplate(const ListTemplate &other)
void setPersistentState(const std::string &state) override
Initialize the list object from the string state.
ListTemplate< T > * deepCopy() const override
Create a deep copy of the list.
std::string persistentState() const override
Returns a string describing the object's internal state.
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...
The class TreeNode is the abstract base class for the import/export of ML objects.
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...
#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
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 ...
#define ML_ADDSTATE_VERSION(ThisClass)
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.
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
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 ...
std::ostream & operator<<(std::ostream &out, const KeyFrame &frame)
KeyFrame stream output.
@ TNE_UnsupportedClassVersion