MeVisLab Toolbox Reference
ml::ListBase Class Referenceabstract

Base object class ListBase managing a number of BaseItem objects. More...

#include <mlListBase.h>

Inheritance diagram for ml::ListBase:
ml::Base ml::ListTemplate< BaseContainerItem > ml::ListTemplate< KeyFrame > ml::ListTemplate< Matrix3 > ml::ListTemplate< Matrix4 > ml::ListTemplate< BaseItem > ml::ListTemplate< Vector3 > ml::ListTemplate< vec3i > ml::ListTemplate< Vector4 > ml::ListTemplate< vec4i > ml::ListTemplate< Vector6 > ml::ListTemplate< vec6i > ml::ListTemplate< XMarker > ml::ListTemplate< T >

Public Member Functions

 ListBase (bool persistance)
 Constructor. Derived class should indicate whether persistence is implemented.
 
 ListBase (const ListBase &other)
 
Abstract list access
virtual size_t getSize () const =0
 Get number of list elements.
 
virtual BaseItemgetItemAt (MLssize_t)
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item at the given index.
 
virtual const BaseItemgetConstItemAt (MLssize_t) const
 Same as getItemAt(MLssize_t index) for constant access.
 
virtual void insertItemAt (MLssize_t, const BaseItem *)
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually inserts the item at the given index.
 
virtual void modifyItemAt (MLssize_t, const BaseItem *)
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually modifies the item at the given index.
 
virtual void deleteItemAt (MLssize_t)
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually deletes the item at the given index.
 
virtual void selectItemAt (MLssize_t)
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually selects the item at the given index.
 
virtual const RuntimeTypegetItemTypeId () const
 This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item class' type id.
 
virtual void clearList ()
 Clear complete list.
 
virtual ListBaseclone () const
 Create a copy of (*this) using the ML runtime system and the '='-operator.
 
ListBasedeepCopy () const override
 Create a deep copy of the list.
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor.
 
virtual ~Base ()
 Destructor.
 
bool isOfAllowedType (const std::vector< const RuntimeType * > &types) const
 Check if this object's type is equal to or derived from one of the types given in the argument.
 
virtual bool isRefCountedBase () const
 Returns if the instance is derived from RefCountedBase.
 
virtual std::string detailString () const
 Return a string describing this object.
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class.
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state.
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState().
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Write the objects state to the data stream object.
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Read the objects state from the data stream object.
 

Protected Member Functions

charnewString (const std::string &str) const
 Convenience method to create a copy of the string str allocated on the heap.
 
void deleteString (char *str) const
 Dispose a string allocated with newString()
 
ListBaseoperator= (const ListBase &list)
 Assignment operator, used in derived list classes.
 

Last action performed on list

When different modules share a common list object, they can use a description of the last action performed on the list to synchronize themselves.

Such a description consists of an action class, the id and the list index of the affected list item. The id can store a constant value uniquely identifying an item within a list. Some actions do not refer to a single list item, in which case id and index should be set to -1. In addition, the list maintains the index of the currently selected item, which can be set by setAction(ActSelect, ...) and which is updated when other operations are performed on the list.

enum  ActionClass {
  ActNone = 0 , ActUnknown , ActNew , ActSelect ,
  ActModify , ActDelete , ActInsert , ActInsertOvw ,
  ActNumActions
}
 Constants to describe the type of action most recently performed. More...
 
static const char *const ActionClassNames [ActNumActions]
 Action class name constants.
 
virtual void setAction (ActionClass actionClass, MLssize_t id, MLssize_t index)
 Set actionClass, affected item id and index.
 
virtual void setAction (ActionClass actionClass)
 Set actionClass for actions affecting the whole list.
 
virtual void getAction (ActionClass &actionClass, MLssize_t &id, MLssize_t &index) const
 Get actionClass, affected item id and index.
 
virtual ActionClass getActionClass () const
 Get actionClass of last action.
 
virtual MLssize_t getActionId () const
 Get id of item affected by last action.
 
virtual MLssize_t getActionIndex () const
 Get index of item affected by last action.
 
virtual MLssize_t getCurrentIndex () const
 Get index of currently selected item, or -1 if no item selected.
 
virtual bool isModified () const
 Tests, if the last action has been an action that has modified the content of the list.
 

Persistence enable/disable and stream output

If persistence is enabled, the get/setPersistantState() methods of the derived ListTemplate classes iterate through all list items to get/set their state.

If no persistence is implemented for the item class, persistence should be disabled to increase performance.

virtual bool hasPersistance () const
 Test if persistence is available and enabled.
 
virtual void setPersistance (bool persistance)
 Enable/disable persistence functionality.
 
void addStateToTree (TreeNode *parent) const override
 Attaches the state as children of the given parent node.
 
 ML_SET_ADDSTATE_VERSION (0)
 Set addState version number.
 
void readStateFromTree (TreeNode *parent) override
 Reads the object state from the children of the given parent node.
 
MLBASEEXPORT friend std::ostream & operator<< (std::ostream &s, const ListBase &list)
 Output persistent state to stream.
 

Additional Inherited Members

- Public Types inherited from ml::Base
enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. More...
 

Detailed Description

Base object class ListBase managing a number of BaseItem objects.

Basic list class with functionality to

  • obtain the number of list elements
  • clear the list
  • enable/disable persistence
  • output persistent state to a stream
  • maintain a last action member variable, describing the most recent action performed on the list

Definition at line 62 of file mlListBase.h.

Member Enumeration Documentation

◆ ActionClass

Constants to describe the type of action most recently performed.

Enumerator
ActNone 

No action.

ActUnknown 

Unknown action.

ActNew 

New list generated.

ActSelect 

Changed the selection of the current list item.

Deselect is represented by index == -1.

ActModify 

Current list item modified.

ActDelete 

List item deleted, _actionIndex contains index formerly occupied by deleted item.

ActInsert 

List item inserted.

ActInsertOvw 

List item inserted, first or last item deleted due to maximum list size restriction.

_actionIndex contains index of inserted item, _actionId contains id of deleted item. NOTE: _actionId and _actionIndex refer to different items!

ActNumActions 

Number of action classes, not to be used as valid enumerator!

Definition at line 187 of file mlListBase.h.

Constructor & Destructor Documentation

◆ ListBase() [1/2]

ml::ListBase::ListBase ( bool persistance)
inline

Constructor. Derived class should indicate whether persistence is implemented.

Definition at line 67 of file mlListBase.h.

◆ ListBase() [2/2]

ml::ListBase::ListBase ( const ListBase & other)
inline

Definition at line 75 of file mlListBase.h.

Member Function Documentation

◆ addStateToTree()

◆ clearList()

◆ clone()

virtual ListBase * ml::ListBase::clone ( ) const
inlinevirtual

Create a copy of (*this) using the ML runtime system and the '='-operator.

Overwrite in derived classes if copying the list is not equivalent to copying the object (for instance, if the derived class has a global list description member). Returns NULL if a copy could not be created, or the cloned list otherwise. This function should not be called since it is overwritten by the clone()-method of ListTemplate<T>

Reimplemented in ml::ListTemplate< T >, ml::ListTemplate< BaseContainerItem >, ml::ListTemplate< BaseItem >, ml::ListTemplate< KeyFrame >, ml::ListTemplate< Matrix3 >, ml::ListTemplate< Matrix4 >, ml::ListTemplate< vec3i >, ml::ListTemplate< vec4i >, ml::ListTemplate< vec6i >, ml::ListTemplate< Vector3 >, ml::ListTemplate< Vector4 >, ml::ListTemplate< Vector6 >, and ml::ListTemplate< XMarker >.

Definition at line 134 of file mlListBase.h.

◆ deepCopy()

◆ deleteItemAt()

virtual void ml::ListBase::deleteItemAt ( MLssize_t )
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually deletes the item at the given index.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, nothing is done.

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 112 of file mlListBase.h.

◆ deleteString()

void ml::ListBase::deleteString ( char * str) const
inlineprotected

Dispose a string allocated with newString()

Definition at line 253 of file mlListBase.h.

References ml::ParserBase::deleteString(), and mlrange_cast().

◆ getAction()

virtual void ml::ListBase::getAction ( ActionClass & actionClass,
MLssize_t & id,
MLssize_t & index ) const
virtual

Get actionClass, affected item id and index.

◆ getActionClass()

virtual ActionClass ml::ListBase::getActionClass ( ) const
inlinevirtual

Get actionClass of last action.

Definition at line 219 of file mlListBase.h.

◆ getActionId()

virtual MLssize_t ml::ListBase::getActionId ( ) const
inlinevirtual

Get id of item affected by last action.

Definition at line 223 of file mlListBase.h.

◆ getActionIndex()

virtual MLssize_t ml::ListBase::getActionIndex ( ) const
inlinevirtual

Get index of item affected by last action.

If last action was ActDelete, index refers to position before deleted item, or equals -1 if first item was deleted.

Definition at line 229 of file mlListBase.h.

◆ getConstItemAt()

virtual const BaseItem * ml::ListBase::getConstItemAt ( MLssize_t ) const
inlinevirtual

◆ getCurrentIndex()

virtual MLssize_t ml::ListBase::getCurrentIndex ( ) const
inlinevirtual

Get index of currently selected item, or -1 if no item selected.

Definition at line 233 of file mlListBase.h.

◆ getItemAt()

virtual BaseItem * ml::ListBase::getItemAt ( MLssize_t )
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item at the given index.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, 0 is to be returned. Thus, this function can also be used to determine whether the list is actually derived from BaseListTemplate<T> (the runtime system can't help you with that because of the template).

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 94 of file mlListBase.h.

◆ getItemTypeId()

virtual const RuntimeType * ml::ListBase::getItemTypeId ( ) const
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually returns the item class' type id.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, NULL is returned.

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 122 of file mlListBase.h.

◆ getSize()

◆ hasPersistance()

virtual bool ml::ListBase::hasPersistance ( ) const
inlinevirtual

Test if persistence is available and enabled.

Definition at line 152 of file mlListBase.h.

◆ insertItemAt()

virtual void ml::ListBase::insertItemAt ( MLssize_t ,
const BaseItem *  )
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually inserts the item at the given index.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, nothing is done.

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 102 of file mlListBase.h.

◆ isModified()

virtual bool ml::ListBase::isModified ( ) const
inlinevirtual

Tests, if the last action has been an action that has modified the content of the list.

Definition at line 237 of file mlListBase.h.

◆ ML_SET_ADDSTATE_VERSION()

ml::ListBase::ML_SET_ADDSTATE_VERSION ( 0 )

Set addState version number.

◆ modifyItemAt()

virtual void ml::ListBase::modifyItemAt ( MLssize_t ,
const BaseItem *  )
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually modifies the item at the given index.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, nothing is done.

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 107 of file mlListBase.h.

◆ newString()

char * ml::ListBase::newString ( const std::string & str) const
inlineprotected

Convenience method to create a copy of the string str allocated on the heap.

This avoids passing STL strings between modules, which fails in Windows due to a bug in the VC++ implementation of the STL.

Definition at line 249 of file mlListBase.h.

References mlrange_cast(), and ml::ParserBase::newString().

◆ operator=()

ListBase & ml::ListBase::operator= ( const ListBase & list)
protected

Assignment operator, used in derived list classes.

◆ readStateFromTree()

◆ selectItemAt()

virtual void ml::ListBase::selectItemAt ( MLssize_t )
inlinevirtual

This virtual function is reimplemented in BaseListTemplate<T>, where it actually selects the item at the given index.

For list types that are NOT derived from BaseListTemplate<T>, and thus do not have BaseItem's as list items, nothing is done.

Reimplemented in ml::BaseListTemplate< T >, ml::BaseListTemplate< BaseContainerItem >, ml::BaseListTemplate< BaseItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 117 of file mlListBase.h.

◆ setAction() [1/2]

virtual void ml::ListBase::setAction ( ActionClass actionClass)
inlinevirtual

Set actionClass for actions affecting the whole list.

Definition at line 212 of file mlListBase.h.

References mlrange_cast().

◆ setAction() [2/2]

virtual void ml::ListBase::setAction ( ActionClass actionClass,
MLssize_t id,
MLssize_t index )
virtual

Set actionClass, affected item id and index.

◆ setPersistance()

virtual void ml::ListBase::setPersistance ( bool persistance)
inlinevirtual

Enable/disable persistence functionality.

Definition at line 155 of file mlListBase.h.

References mlrange_cast().

Friends And Related Symbol Documentation

◆ operator<<

MLBASEEXPORT friend std::ostream & operator<< ( std::ostream & s,
const ListBase & list )
friend

Output persistent state to stream.

Member Data Documentation

◆ ActionClassNames

const char* const ml::ListBase::ActionClassNames[ActNumActions]
static

Action class name constants.

Definition at line 206 of file mlListBase.h.


The documentation for this class was generated from the following file: