49class ListContainerBase;
69 : _hasPersistence(persistence),
164 [[deprecated(
"Use hasPersistence() instead.")]]
168 [[deprecated(
"Use setPersistence(bool persistence) instead.")]]
234 {
return _actionClass; }
238 {
return _actionId; }
244 {
return _actionIndex; }
248 {
return _currentIndex; }
276 bool _hasPersistence;
354 {
using namespace std;
return vector<T>::size(); }
366 ListBase::operator =(list);
367 vector<T>::operator =(list);
421 virtual std::string
itemState([[maybe_unused]]
typename ListTemplate<T>::const_iterator it)
const
427 virtual void setItemState(
typename ListTemplate<T>::iterator ,
const std::string& ) {}
449 for (
auto it = vector<T>::begin(); it != vector<T>::end(); ++it)
452 if (it != vector<T>::begin()) {
458 if (!itemStr.empty())
492 auto parserResult = parser.
init(state.c_str());
494 while (!parserResult)
497 std::string itemString;
498 std::tie(parserResult, itemString) = parser.
nextItem();
502 vector<T>::insert(vector<T>::end(),
T());
543 for (
auto it = vector<T>::cbegin(); it != vector<T>::cend(); ++it)
559 int version = parent->getVersion(
"ListTemplate");
572 bool endLoop =
false;
582 vector<T>::reserve( loadedSize );
584 TreeNode* items = parent->readContainerChild(
"ListItems");
589 if (items->hasChild()) {
590 items->readChild(currStr);
597 vector<T>::insert(vector<T>::end(),
T());
634 (*newList) = (*this);
743 return T::getClassTypeId();
836 std::string
itemState(
typename ListTemplate<T>::const_iterator it)
const override
838 return it->persistentState();
842 void setItemState(
typename ListTemplate<T>::iterator it,
const std::string& state)
override
844 it->setPersistentState(state);
885 (*this)[
static_cast<size_t>(index)].setId(
id);
906 const size_t idx_size_t =
static_cast<size_t>(index);
907 const MLssize_t id = (*this)[idx_size_t].getId();
908 (*this)[idx_size_t] = item;
909 (*this)[idx_size_t].setId(
id);
924 else if (index == -1)
943 typename BaseListTemplate<T>::const_iterator it;
954 items->
addChild(&(*it),
"Item",
false);
963 int version = parent->getVersion(
"BaseListTemplate");
975 bool endLoop =
false;
987 TreeNode* items = parent->readContainerChild(
"ListItems");
991 if (items->hasChild()) {
General Base object class for list items that have an id and a name.
void deleteItemAt(MLssize_t index) override
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
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
virtual void doInsertItem(MLssize_t index, const T &item)
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)
BaseItem * getItemAt(MLssize_t index) override
BaseListTemplate(bool persistence)
Special constructor to explicitly enable/disable persistence.
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
void insertItemAt(MLssize_t index, const BaseItem *item) override
virtual void doSelectItem(MLssize_t index)
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
virtual void doModifyItem(MLssize_t index, const T &item)
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.
virtual void setPersistence(bool persistence)
Enable/disable persistence functionality.
char * newString(const std::string &str) const
virtual MLssize_t getActionIndex() const
ListBase(bool persistence)
Constructor. Derived class should indicate whether persistence is implemented.
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
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.
@ ActNumActions
Number of action classes, not to be used as valid enumerator!
virtual void selectItemAt(MLssize_t)
virtual MLssize_t getCurrentIndex() const
Get index of currently selected item, or -1 if no item selected.
ListContainerBase * getContainer() const
virtual void deleteItemAt(MLssize_t)
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.
static const char *const ActionClassNames[ActNumActions]
Action class name constants.
void setPersistance(bool persistence)
virtual void setAction(ActionClass actionClass)
Set actionClass for actions affecting the whole list.
virtual BaseItem * getItemAt(MLssize_t)
virtual ListBase * clone() const
void deleteString(char *str) const
Dispose a string allocated with newString().
ListBase(const ListBase &other)
void setContainer(ListContainerBase *container)
virtual void modifyItemAt(MLssize_t, const BaseItem *)
virtual void insertItemAt(MLssize_t, const BaseItem *)
virtual bool hasPersistence() const
Test if persistence is available and enabled.
bool hasPersistance() const
Abstract module class ListContainerBase implementing basic functionality for a list container module.
Parser class for parsing persistent state strings of list objects.
const char * getErrorMessage(int errorCode) override
Get error string for errorCode.
static bool needsQuote(const char *itemStr)
Return true if itemStr needs to be quoted.
static std::string quoteString(const std::string &itemStr)
std::pair< int, std::string > nextItem()
int init(const char *source) override
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
void clearList() override
Clear complete list.
virtual std::string itemState(typename ListTemplate< T >::const_iterator it) const
void addStateToTree(TreeNode *parent) const override
Attaches the state as children of the given parent node.
ListTemplate(bool persistence)
Special constructor to explicitly enable/disable persistence.
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
static char * newString(const std::string &str)
static void deleteString(char *str)
Dispose a string allocated with newString().
@ kEndOfSource
End of source reached.
@ kEmptyString
Source string null or empty.
bool canCreateInstance() const
Returns true if this (runtime) type knows how to create an instance of the class.
void * createInstance() const
virtual void addChild(bool val, const char *name) ADD_ULONG_CHILD
Factory method for adding a child encapsulating a variable of type bool.
#define ML_ABSTRACT_CLASS_HEADER(className)
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
#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)
#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)
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
SSIZE_T MLssize_t
The signed ML size type that is a signed 32-bit size_t on 32-bit platforms and 64-bit one on 64-bit p...
@ TNE_UnsupportedClassVersion
std::ostream & operator<<(std::ostream &out, const KeyFrame &frame)
KeyFrame stream output.