MeVisLabToolboxReference
ml::ListBase Class Reference

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< 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 > ml::ListTemplate< XMarker > ml::ListTemplate< T >

List of all members.

Public Member Functions

 ListBase (bool persistance)
 Constructor. Derived class should indicate whether persistence is implemented.
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.
virtual ListBasedeepCopy () const
 Create a deep copy of the list.

Protected Member Functions

char * newString (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.

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.
virtual void addStateToTree (TreeNode *parent) const
 Attaches the state as children of the given parent node.
 ML_SET_ADDSTATE_VERSION (0)
 Set addState version number.
virtual void readStateFromTree (TreeNode *parent)
 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.

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.

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 70 of file mlListBase.h.


Member Enumeration Documentation

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 188 of file mlListBase.h.


Constructor & Destructor Documentation

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

Constructor. Derived class should indicate whether persistence is implemented.

Definition at line 75 of file mlListBase.h.


Member Function Documentation

virtual ListBase* ml::ListBase::clone ( void  ) const [inline, virtual]

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< Vector6 >, ml::ListTemplate< BaseItem >, ml::ListTemplate< KeyFrame >, ml::ListTemplate< BaseContainerItem >, ml::ListTemplate< Vector3 >, ml::ListTemplate< Matrix4 >, ml::ListTemplate< Vector4 >, ml::ListTemplate< vec6i >, ml::ListTemplate< Matrix3 >, ml::ListTemplate< XMarker >, ml::ListTemplate< vec3i >, and ml::ListTemplate< vec4i >.

Definition at line 135 of file mlListBase.h.

virtual void ml::ListBase::deleteItemAt ( MLssize_t  ) [inline, virtual]

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 113 of file mlListBase.h.

void ml::ListBase::deleteString ( char *  str) const [inline, protected]

Dispose a string allocated with newString()

Definition at line 254 of file mlListBase.h.

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

Get actionClass, affected item id and index.

virtual ActionClass ml::ListBase::getActionClass ( ) const [inline, virtual]

Get actionClass of last action.

Definition at line 220 of file mlListBase.h.

virtual MLssize_t ml::ListBase::getActionId ( ) const [inline, virtual]

Get id of item affected by last action.

Definition at line 224 of file mlListBase.h.

virtual MLssize_t ml::ListBase::getActionIndex ( ) const [inline, virtual]

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 230 of file mlListBase.h.

virtual const BaseItem* ml::ListBase::getConstItemAt ( MLssize_t  ) const [inline, virtual]
virtual MLssize_t ml::ListBase::getCurrentIndex ( ) const [inline, virtual]

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

Definition at line 234 of file mlListBase.h.

virtual BaseItem* ml::ListBase::getItemAt ( MLssize_t  ) [inline, virtual]

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 95 of file mlListBase.h.

virtual const RuntimeType* ml::ListBase::getItemTypeId ( ) const [inline, virtual]

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 123 of file mlListBase.h.

virtual bool ml::ListBase::hasPersistance ( ) const [inline, virtual]

Test if persistence is available and enabled.

Definition at line 153 of file mlListBase.h.

virtual void ml::ListBase::insertItemAt ( MLssize_t  ,
const BaseItem  
) [inline, virtual]

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 103 of file mlListBase.h.

virtual bool ml::ListBase::isModified ( ) const [inline, virtual]

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

Definition at line 238 of file mlListBase.h.

ml::ListBase::ML_SET_ADDSTATE_VERSION ( )

Set addState version number.

virtual void ml::ListBase::modifyItemAt ( MLssize_t  ,
const BaseItem  
) [inline, virtual]

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 108 of file mlListBase.h.

char* ml::ListBase::newString ( const std::string &  str) const [inline, protected]

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 250 of file mlListBase.h.

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

Assignment operator, used in derived list classes.

virtual void ml::ListBase::selectItemAt ( MLssize_t  ) [inline, virtual]

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 118 of file mlListBase.h.

virtual void ml::ListBase::setAction ( ActionClass  actionClass) [inline, virtual]

Set actionClass for actions affecting the whole list.

Definition at line 213 of file mlListBase.h.

References setAction().

Referenced by setAction().

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

Set actionClass, affected item id and index.

virtual void ml::ListBase::setPersistance ( bool  persistance) [inline, virtual]

Enable/disable persistence functionality.

Definition at line 156 of file mlListBase.h.


Friends And Related Function Documentation

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

Output persistent state to stream.


Member Data Documentation

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

Action class name constants.

Definition at line 207 of file mlListBase.h.


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