MeVisLab Toolbox Reference
ml::BaseItem Class Reference

General Base object class for list items that have an id and a name. More...

#include <mlBaseItem.h>

Inheritance diagram for ml::BaseItem:
ml::Base ml::BaseContainerItem ml::XMarker

Public Member Functions

void setId (MLssize_t id)
 Sets the id of the item. More...
 
MLssize_t getId () const
 Sets the id of the item. More...
 
 ~BaseItem () override
 Destructor. More...
 
BaseItemoperator= (const BaseItem &item)
 Assignment operator. More...
 
const char * name () const
 Get name. More...
 
void setName (const char *newName)
 Set name, object stores a copy. More...
 
BaseItemdeepCopy () const override
 Create a deep copy of the BaseItem. More...
 
Constructors
 BaseItem ()
 Default constructor. More...
 
 BaseItem (MLssize_t id, const char *nameStr=nullptr)
 ID and name. More...
 
 BaseItem (const BaseItem &item)
 Copy constructor. 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...
 

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...
 
- Protected Member Functions inherited from ml::Base

Persistence

std::string persistentState () const override
 Return a string representation of the item object. More...
 
void setPersistentState (const std::string &state) override
 Initialize the item object from the string state. More...
 
void clearPersistentState (char *state) const override
 Dispose the string state, which has been previously obtained by getPersistentState() More...
 
void addStateToTree (TreeNode *parent) const override
 Attaches the object 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...
 
void writeTo (AbstractPersistenceOutputStream *stream) const override
 write state to stream More...
 
void readFrom (AbstractPersistenceInputStream *stream, int version) override
 read state from stream More...
 
char * getPersistentState () const override
 Return a string representation of the item object. More...
 
void setPersistentState (const char *state) override
 Initialize the item object from the string state. 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

General Base object class for list items that have an id and a name.

Definition at line 37 of file mlBaseItem.h.

Constructor & Destructor Documentation

◆ BaseItem() [1/3]

ml::BaseItem::BaseItem ( )
inline

Default constructor.

Definition at line 45 of file mlBaseItem.h.

◆ BaseItem() [2/3]

ml::BaseItem::BaseItem ( MLssize_t  id,
const char *  nameStr = nullptr 
)
inline

ID and name.

Definition at line 48 of file mlBaseItem.h.

◆ BaseItem() [3/3]

ml::BaseItem::BaseItem ( const BaseItem item)
inline

Copy constructor.

Definition at line 51 of file mlBaseItem.h.

◆ ~BaseItem()

ml::BaseItem::~BaseItem ( )
inlineoverride

Destructor.

Definition at line 62 of file mlBaseItem.h.

Member Function Documentation

◆ addStateToTree()

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

Attaches the object state as children of the given parent node.

Reimplemented from ml::Base.

Reimplemented in ml::XMarker, and ml::BaseContainerItem.

◆ clearPersistentState()

void ml::BaseItem::clearPersistentState ( char *  state) const
overridevirtual

Dispose the string state, which has been previously obtained by getPersistentState()

Reimplemented from ml::Base.

Reimplemented in ml::BaseContainerItem.

◆ deepCopy()

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

Create a deep copy of the BaseItem.

Reimplemented from ml::Base.

Definition at line 129 of file mlBaseItem.h.

◆ deleteString()

void ml::BaseItem::deleteString ( char *  str) const
protected

Dispose a string allocated with newString()

◆ getId()

MLssize_t ml::BaseItem::getId ( void  ) const
inline

Sets the id of the item.

Definition at line 59 of file mlBaseItem.h.

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

◆ getPersistentState()

char* ml::BaseItem::getPersistentState ( ) const
overrideprotectedvirtual

Return a string representation of the item object.

The string is allocated on the heap and is later disposed by clearPersistentState().

Deprecated:

Reimplemented from ml::Base.

Reimplemented in ml::XMarker.

◆ ML_SET_ADDSTATE_VERSION()

ml::BaseItem::ML_SET_ADDSTATE_VERSION ( )

Set addState version number.

Version History: 0 : adding size and items only 1 : also adding ListBase members (hasPersistence, currentItem);

◆ name()

const char* ml::BaseItem::name ( ) const
inline

Get name.

Definition at line 70 of file mlBaseItem.h.

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

◆ newString()

char* ml::BaseItem::newString ( const std::string &  str) const
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.

◆ operator=()

BaseItem& ml::BaseItem::operator= ( const BaseItem item)

Assignment operator.

◆ persistentState()

std::string ml::BaseItem::persistentState ( ) const
overridevirtual

Return a string representation of the item object.

Reimplemented from ml::Base.

Reimplemented in ml::XMarker, and ml::BaseContainerItem.

◆ readFrom()

void ml::BaseItem::readFrom ( AbstractPersistenceInputStream stream,
int  version 
)
overridevirtual

read state from stream

Reimplemented from ml::Base.

◆ readStateFromTree()

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

Reads the object state from the children of the given parent node.

Reimplemented from ml::Base.

Reimplemented in ml::XMarker, and ml::BaseContainerItem.

◆ setId()

void ml::BaseItem::setId ( MLssize_t  id)
inline

Sets the id of the item.

Definition at line 56 of file mlBaseItem.h.

◆ setName()

void ml::BaseItem::setName ( const char *  newName)

Set name, object stores a copy.

Referenced by ml::XMarker::XMarker().

◆ setPersistentState() [1/2]

void ml::BaseItem::setPersistentState ( const char *  state)
overrideprotectedvirtual

Initialize the item object from the string state.

Deprecated:

Reimplemented from ml::Base.

Reimplemented in ml::XMarker.

◆ setPersistentState() [2/2]

void ml::BaseItem::setPersistentState ( const std::string &  state)
overridevirtual

Initialize the item object from the string state.

Reimplemented from ml::Base.

Reimplemented in ml::XMarker, and ml::BaseContainerItem.

◆ writeTo()

void ml::BaseItem::writeTo ( AbstractPersistenceOutputStream stream) const
overridevirtual

write state to stream

Reimplemented from ml::Base.


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