MeVisLabToolboxReference
ml::ListContainerTemplate< T > Class Template Reference

Template module class ListContainerTemplate for a specific list class. More...

#include <mlListContainer.h>

Inheritance diagram for ml::ListContainerTemplate< T >:
ml::ListContainerBase ml::Module ml::FieldContainer ml::Base

List of all members.

Public Member Functions

 ListContainerTemplate (int inputNum, int outputNum)
 Constructor The values inputNum and outputNum specify the number of input and output image fields, resp.
virtual ~ListContainerTemplate ()
 Destructor.
virtual T * getList ()
 Get pointer to the active list object Use this pointer for list access after testing that it is != 0.

Public Attributes

T::itemType _currentItem
 List item object used by insertItem() and modifyItem().

Protected Member Functions

List object access
virtual bool setActiveList (Base *basePtr)
 Set the active list pointer _listPtr to basePtr, provided that it is of the correct type.
virtual ListBasegetInternalList ()
 Return address of internal list object.
virtual MLssize_t getId (MLssize_t index)
 Return the item id of the item index.
Handle item property fields
virtual void updatePropertyFields ()
 Update property fields from the current list item.
List modifications
virtual void deleteItems (MLssize_t index, MLssize_t num)
 Remove num items, starting at item index.
virtual void insertItem (MLssize_t index, bool fromCurrentItem)
 Insert an item at position index.
virtual bool modifyItem (MLssize_t index, Field *field, bool fromCurrentItem)
 Modify item at position index.
virtual void copyItemToTemplate (MLssize_t index)
 Copy values from item at position index to the template fields.
virtual void copyTemplateToCurrent ()
 Copy the values of the templates fields to _currentItem.
virtual void initItem (MLssize_t index)
 Initialize the list item at position index.

Protected Attributes

T * _listPtr
 Pointer to the active list object Use this pointer for list access after testing that it is != 0.

Detailed Description

template<class T>
class ml::ListContainerTemplate< T >

Template module class ListContainerTemplate for a specific list class.

Class template for container modules for a specific list class. Contains a list object storing the internal list and implements the method to access this object.

To implement an instance of ListContainerTemplate with a given list type T (where T must be a subclass of BaseListTemplate), the following steps are necessary:

  • Derive a subclass from the template instance class ListContainerTemplate<T>
  • Use the ML_MODULE_CLASS_HEADER and ML_CLASS_SOURCE macros to implement the runtime type system for this class. In the ML_CLASS_SOURCE macro, use ListContainerBase in the base class argument.
  • Add field members to reflect additional list item properties (other than item id and name, which are handled by the base class).
  • Set _lockNotification = 1 in the constructor of the derived class while initializing field members to suppress handleNotification().
  • Overload the item property fields methods: isPropertyField() resetPropertyFields() updatePropertyFields()
  • Overload the list item operation methods: modifyItem() initItem()
  • If the derived class should be notified on changes to the active list (e.g. for graphical viewer or editor modules), overload the touchList() method.

Definition at line 379 of file mlListContainer.h.


Constructor & Destructor Documentation

template<class T>
virtual ml::ListContainerTemplate< T >::~ListContainerTemplate ( ) [inline, virtual]

Destructor.

Definition at line 389 of file mlListContainer.h.


Member Function Documentation

template<class T >
void ml::ListContainerTemplate< T >::copyItemToTemplate ( MLssize_t  index) [protected, virtual]

Copy values from item at position index to the template fields.

Implements ml::ListContainerBase.

Reimplemented in ml::XMarkerListContainer.

Definition at line 696 of file mlListContainer.h.

References ML_TRACE_IN, and mlrange_cast().

template<class T >
void ml::ListContainerTemplate< T >::copyTemplateToCurrent ( ) [protected, virtual]

Copy the values of the templates fields to _currentItem.

Implements ml::ListContainerBase.

Reimplemented in ml::XMarkerListContainer.

Definition at line 709 of file mlListContainer.h.

References ML_TRACE_IN.

template<class T >
void ml::ListContainerTemplate< T >::deleteItems ( MLssize_t  index,
MLssize_t  num 
) [protected, virtual]

Remove num items, starting at item index.

Implements ml::ListContainerBase.

Definition at line 595 of file mlListContainer.h.

References ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

template<class T >
MLssize_t ml::ListContainerTemplate< T >::getId ( MLssize_t  index) [protected, virtual]

Return the item id of the item index.

Implements ml::ListContainerBase.

Definition at line 560 of file mlListContainer.h.

References ML_TRACE_IN, and mlrange_cast().

template<class T>
virtual ListBase* ml::ListContainerTemplate< T >::getInternalList ( ) [inline, protected, virtual]

Return address of internal list object.

Implements ml::ListContainerBase.

Definition at line 416 of file mlListContainer.h.

template<class T>
virtual T* ml::ListContainerTemplate< T >::getList ( ) [inline, virtual]

Get pointer to the active list object Use this pointer for list access after testing that it is != 0.

If the pointer is 0, an external object of a wrong type is connected to the input base field, in which case the module should be completely deactivated.

Definition at line 396 of file mlListContainer.h.

Referenced by ml::ITKNodeContainerFromBasePointer(), ml::ITKPointSetFromBasePointer(), and ml::ITKPolylineFromBasePointer().

template<class T >
void ml::ListContainerTemplate< T >::initItem ( MLssize_t  index) [protected, virtual]

Initialize the list item at position index.

This method is called by insertItem() if the fromCurrentItem argument is false. Moreover it is called when fldInit is touched.

This method is called by insertItem() if the fromCurrentItem argument is false. Moreover it is called when _fldClearItem is touched.

Implements ml::ListContainerBase.

Reimplemented in ml::XMarkerListContainer.

Definition at line 722 of file mlListContainer.h.

References ML_TRACE_IN, and mlrange_cast().

template<class T >
void ml::ListContainerTemplate< T >::insertItem ( MLssize_t  index,
bool  fromCurrentItem 
) [protected, virtual]

Insert an item at position index.

If fromCurrentItem is true, the new item is initialized from _currentItem.

Implements ml::ListContainerBase.

Definition at line 619 of file mlListContainer.h.

References ML_CATCH_RETHROW, ML_TRACE_IN, ML_TRY, and mlrange_cast().

template<class T >
bool ml::ListContainerTemplate< T >::modifyItem ( MLssize_t  index,
Field field,
bool  fromCurrentItem 
) [protected, virtual]

Modify item at position index.

If fromCurrentItem is true, the item is copied from _currentItem, otherwise the item property corresponding to the property field field is modified. Return true if item has been modified.

Implements ml::ListContainerBase.

Reimplemented in ml::XMarkerListContainer.

Definition at line 657 of file mlListContainer.h.

References ML_CATCH_RETHROW, ML_TRACE_IN, ML_TRY, and mlrange_cast().

template<class T >
bool ml::ListContainerTemplate< T >::setActiveList ( Base basePtr) [protected, virtual]

Set the active list pointer _listPtr to basePtr, provided that it is of the correct type.

Otherwise the _listPtr is set to zero. Returns true if object is of correct type.

Implements ml::ListContainerBase.

Definition at line 539 of file mlListContainer.h.

References ML_BASE_IS_A, ML_TRACE_IN, and T.

template<class T >
void ml::ListContainerTemplate< T >::updatePropertyFields ( ) [protected, virtual]

Update property fields from the current list item.

Implements ml::ListContainerBase.

Reimplemented in ml::XMarkerListContainer.

Definition at line 572 of file mlListContainer.h.

References ml::BaseItem::getId(), ML_TRACE_IN, mlrange_cast(), and ml::BaseItem::name().


Member Data Documentation

template<class T>
T::itemType ml::ListContainerTemplate< T >::_currentItem

List item object used by insertItem() and modifyItem().

A derived editor module should use this variable to store a new or modified item and then call doInsertItem() or doModifyItem() with fromCurrentItem = true.

Definition at line 402 of file mlListContainer.h.

template<class T>
T* ml::ListContainerTemplate< T >::_listPtr [protected]

Pointer to the active list object Use this pointer for list access after testing that it is != 0.

If the pointer is 0, an external object of a wrong type is connected to the input base field, in which case the module should be completely deactivated.

Definition at line 466 of file mlListContainer.h.

Referenced by ml::ListContainerTemplate< T >::ListContainerTemplate().


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