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< KeyFrame > ml::ListTemplate< Matrix4 > ml::ListTemplate< Matrix3 > ml::ListTemplate< T > ml::KeyFrameList ml::Mat4List ml::Mat3List ml::BaseListTemplate< BaseItem > ml::BaseListTemplate< BaseContainerItem > ml::BaseListTemplate< XMarker > ml::VecListTemplate< Vector6 > ml::VecListTemplate< Vector3 > ml::VecListTemplate< vec6i > ml::VecListTemplate< Vector4 > ml::VecListTemplate< vec3i > ml::VecListTemplate< vec4i > ml::BaseListTemplate< T > ml::VecListTemplate< T >

Public Member Functions

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

Protected Member Functions

char * newString (const std::string &str) const
 Convenience method to create a copy of the string str allocated on the heap. More...
 
void deleteString (char *str) const
 Dispose a string allocated with newString() More...
 
ListBaseoperator= (const ListBase &list)
 Assignment operator, used in derived list classes. More...
 
- Protected Member Functions inherited from ml::Base
virtual char * getPersistentState () const
 Returns a C string describing the object's internal state. More...
 
virtual void setPersistentState (const char *)
 Restores the object's internal state from a string that had been previously generated using getPersistentState(). More...
 
virtual void clearPersistentState (char *) const
 Disposes a string previously allocated by getPersistentState(). More...
 

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. More...
 
virtual void setAction (ActionClass actionClass, MLssize_t id, MLssize_t index)
 Set actionClass, affected item id and index. More...
 
virtual void setAction (ActionClass actionClass)
 Set actionClass for actions affecting the whole list. More...
 
virtual void getAction (ActionClass &actionClass, MLssize_t &id, MLssize_t &index) const
 Get actionClass, affected item id and index. More...
 
virtual ActionClass getActionClass () const
 Get actionClass of last action. More...
 
virtual MLssize_t getActionId () const
 Get id of item affected by last action. More...
 
virtual MLssize_t getActionIndex () const
 Get index of item affected by last action. More...
 
virtual MLssize_t getCurrentIndex () const
 Get index of currently selected item, or -1 if no item selected. More...
 
virtual bool isModified () const
 Tests, if the last action has been an action that has modified the content of the list. More...
 

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. More...
 
virtual void setPersistance (bool persistance)
 Enable/disable persistence functionality. More...
 
void addStateToTree (TreeNode *parent) const override
 Attaches the state as children of the given parent node. More...
 
 ML_SET_ADDSTATE_VERSION (0)
 Set addState version number. More...
 
void readStateFromTree (TreeNode *parent) override
 Reads the object state from the children of the given parent node. More...
 
MLBASEEXPORT friend std::ostream & operator<< (std::ostream &s, const ListBase &list)
 Output persistent state to stream. More...
 

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()

void ml::ListBase::addStateToTree ( TreeNode parent) const
overridevirtual

◆ clearList()

◆ clone()

virtual ListBase* ml::ListBase::clone ( void  ) 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< KeyFrame >, ml::ListTemplate< Matrix4 >, and ml::ListTemplate< Matrix3 >.

Definition at line 134 of file mlListBase.h.

◆ deepCopy()

ListBase* ml::ListBase::deepCopy ( ) const
inlineoverridevirtual

Create a deep copy of the list.

Reimplemented from ml::Base.

Reimplemented in ml::ListTemplate< T >, ml::ListTemplate< KeyFrame >, ml::ListTemplate< Matrix4 >, and ml::ListTemplate< Matrix3 >.

Definition at line 137 of file mlListBase.h.

◆ 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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, 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().

◆ 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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, 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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, and ml::BaseListTemplate< XMarker >.

Definition at line 122 of file mlListBase.h.

◆ getSize()

virtual size_t ml::ListBase::getSize ( ) const
pure virtual

◆ 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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, 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 ( )

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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, 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 ml::ParserBase::newString().

◆ operator=()

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

Assignment operator, used in derived list classes.

◆ readStateFromTree()

void ml::ListBase::readStateFromTree ( TreeNode parent)
overridevirtual

◆ 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< BaseItem >, ml::BaseListTemplate< BaseContainerItem >, 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.

◆ 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.

Friends And Related Function 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: