88 return const_cast<const Base*
>(_baseObjectP);
220 bool operator()(
const ML_NAMESPACE::BaseContainerItem &x,
const ML_NAMESPACE::BaseContainerItem &y)
const
223 if (!x.getConstObjectPointer()) {
return false; }
224 if (!y.getConstObjectPointer()) {
return true; }
226 if (!_sortParams) {
return false; }
229 return _sortParams->isLessThan(*x.getConstObjectPointer(), *y.getConstObjectPointer());
Base object class BaseContainerItem encapsulates a pointer to a Base object as a list item.
void _setObjectPointer(Base *objectP, bool isOwner=true)
Sets a new object by pointer.
BaseContainerItem & operator=(const BaseContainerItem &other)
Assignment operator, performing a shallow copy as far as the contained base object is concerned.
bool _ownsBaseObject
Flag remembering if the contained base object is owned.
~BaseContainerItem() override
static BaseContainerItem * toBaseContainerItem(Base &baseObj, MLssize_t id=0, const char *name=nullptr)
Returns baseObj, if baseObj already is a BaseContainerItem.
void setPersistentState(const std::string &state) override
Initialize the item object from the string state.
bool _baseObjectIsRefCounted
Flag remembering if the contained base object is ref-counted This flag is not strictly necessary,...
virtual Base * getObjectPointer() const
Returns a pointer to the contained base object.
virtual Base * removeObjectPointer()
Removes the contained object (deletes if owned and not ref-counted).
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
void addStateToTree(TreeNode *parent) const override
Attaches the object state as children of the given parent node.
Base * _baseObjectP
Pointer to the actual object:
ML_SET_ADDSTATE_VERSION(0)
Set addState version number.
virtual const Base * getConstObjectPointer() const
Returns a const pointer to the contained base object.
BaseContainerItem(MLssize_t idParam, const char *nameParam=nullptr, Base *baseP=nullptr)
When assigning a base object, you should also provide a name.
BaseContainerItem(const BaseContainerItem &other, bool useDeepCopy=false)
BaseContainerItem(BaseContainerItem &&other) noexcept
virtual void setObject(Base &object)
Sets a new object.
virtual BaseContainerItem & copyFrom(const BaseContainerItem &other, bool performDeepCopy=true)
Copies from other BaseContainerItem.
std::string persistentState() const override
Returns a string describing the object's internal state.
General Base object class for list items that have an id and a name.
Class that is designed to hold custom list sorting parameters (such as sort mode)
virtual bool isLessThan(const Base &, const Base &)=0
Pure virtual comparison function.
virtual ~BaseListSortParameters()
virtual destructor
Base object template list class for list item classes derived from BaseItem.
Base object class BaseList which stores a list of BaseContainerItem entries.
BaseList(const BaseList &other)
BaseList()
Constructor, enables persistence.
BaseList * deepCopy() const override
Create a deep copy of the list.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
The class TreeNode is the abstract base class for the import/export of ML objects.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non existing export symbol.
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 ...
bool operator()(const ml::BaseContainerItem &x, const ml::BaseContainerItem &y) const
comparison operator
ml::BaseListSortParameters * _sortParams
sort mode
less(ml::BaseListSortParameters *sortParams)