MeVisLab Toolbox Reference
ml::Base Class Reference

Class representing general ML objects that support import/export via strings (setPersistentState() and getPersistentState()), arbitrary tree structures (using addStateToTree() and readStateFromTree()) or a data stream (using writeTo() and readFrom()). More...

#include <mlBase.h>

Inheritance diagram for ml::Base:
ml::ArrowHeadSettings ml::BaseItem ml::BaseWithParameterInfo ml::BitImage ml::CSOProcessorData ml::CSOVisualizationSettings ml::CSOVoxelSetList ml::CurveData ml::CurveList ml::DataCompressor ml::DataCompressorFactory ml::DicomModifyList ml::DiscList ml::EventSource ml::FieldContainer ml::ITKWrapperBase ml::LUTFunction ml::ListBase ml::MarkerList ml::MultiBaseType ml::ParameterInfo ml::PointList ml::PresentationState ml::PrivateDICOMTagDecoderPluginBase ml::RasterFunction ml::RasterFunctionList ml::SRDoc ml::SphereList ml::StylePalette ml::VTKWrapperBase ml::VectorList ml::omObjMgrConnection ml::omObject ml::omObjectContainer

Classes

struct  StateDeleter
 

Public Member Functions

 Base ()
 Constructor. More...
 
virtual ~Base ()
 Destructor. More...
 
virtual BasedeepCopy () const
 Set addStateToTree version number that can be accessed via getAddStateVersion() 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...
 

Persistence interfaces

enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. 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 addStateToTree (TreeNode *) const
 Attaches the object state as children of the given parent node. More...
 
virtual void readStateFromTree (TreeNode *)
 Reads the object state from the children of the given parent node. 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...
 
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...
 

Detailed Description

Class representing general ML objects that support import/export via strings (setPersistentState() and getPersistentState()), arbitrary tree structures (using addStateToTree() and readStateFromTree()) or a data stream (using writeTo() and readFrom()).

Objects of class Base

  • can be represented using the field concept (class BaseField)
  • provide an interface to allow the import/export of a persistent representation of an object's internal state.

Remark: This class is base class for Module and all derived modules.

Definition at line 61 of file mlBase.h.

Member Enumeration Documentation

◆ PersistenceInterface

This enum describes the different persistence interfaces available.

can be implemented in derived classes:

Enumerator
PersistenceByString 
PersistenceByTreeNode 
PersistenceByStream 

Definition at line 89 of file mlBase.h.

Constructor & Destructor Documentation

◆ Base()

ml::Base::Base ( )

Constructor.

◆ ~Base()

virtual ml::Base::~Base ( )
virtual

Destructor.

Member Function Documentation

◆ addStateToTree()

◆ clearPersistentState()

virtual void ml::Base::clearPersistentState ( char *  ) const
inlineprotectedvirtual

Disposes a string previously allocated by getPersistentState().

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

Definition at line 123 of file mlBase.h.

◆ deepCopy()

virtual Base* ml::Base::deepCopy ( ) const
inlinevirtual

Set addStateToTree version number that can be accessed via getAddStateVersion()

Creates a deep copy of the given object. The default implementation returns a NULL pointer and has to be overloaded by derived classes. It can be used to clone Base objects without knowledge of the exact type of object.

Reimplemented in ml::WEM, ml::CSOList, ml::StylePalette, ml::ListTemplate< T >, ml::ListTemplate< KeyFrame >, ml::ListTemplate< Matrix4 >, ml::ListTemplate< Matrix3 >, ml::ListBase, ml::CurveList, ml::CurveData, ml::BaseList, and ml::BaseItem.

Definition at line 163 of file mlBase.h.

◆ detailString()

virtual std::string ml::Base::detailString ( ) const
inlinevirtual

Return a string describing this object.

This is mainly meant to return the sub-type of wrapped objects, which are not reflected in the Base type system.

Definition at line 175 of file mlBase.h.

◆ getPersistentState()

virtual char* ml::Base::getPersistentState ( ) const
inlineprotectedvirtual

Returns a C string describing the object's internal state.

The memory for the string will be allocated here and has to be deallocated using clearPersistentState().

Deprecated:

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

Definition at line 115 of file mlBase.h.

◆ implementsPersistence()

virtual bool ml::Base::implementsPersistence ( PersistenceInterface  ) const
inlinevirtual

Override this method to declare which persistence interfaces are implemented by your derived class.

Reimplemented in ml::StandardItemModel.

Definition at line 97 of file mlBase.h.

◆ isOfAllowedType()

bool ml::Base::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.

This method will also return true if the vector is empty, since this denotes that any type is allowed.

◆ isRefCountedBase()

virtual bool ml::Base::isRefCountedBase ( ) const
inlinevirtual

Returns if the instance is derived from RefCountedBase.

Reimplemented in ml::RefCountedBase.

Definition at line 171 of file mlBase.h.

◆ persistentState()

virtual std::string ml::Base::persistentState ( ) const
virtual

◆ readFrom()

virtual void ml::Base::readFrom ( AbstractPersistenceInputStream ,
int   
)
inlinevirtual

Read the objects state from the data stream object.

version is the version number given through ML_PERSISTENCE_VERSION at the time the object was written to the AbstractPersistenceOutStream.

Include mlAbstractPersistenceStream.h for the implementation of this method.

If you are sub-classing from another Base class that implements persistence, use the macro ML_READFROM_SUPER() to load the super-class data, because this takes care of reading and checking the version number of the super class.

Reimplemented in ml::StandardItemModel, and ml::BaseItem.

Definition at line 153 of file mlBase.h.

◆ readStateFromTree()

◆ setPersistentState() [1/2]

virtual void ml::Base::setPersistentState ( const char *  )
inlineprotectedvirtual

Restores the object's internal state from a string that had been previously generated using getPersistentState().

Deprecated:

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

Definition at line 120 of file mlBase.h.

◆ setPersistentState() [2/2]

virtual void ml::Base::setPersistentState ( const std::string &  state)
virtual

◆ writeTo()

virtual void ml::Base::writeTo ( AbstractPersistenceOutputStream ) const
inlinevirtual

Write the objects state to the data stream object.

Include mlAbstractPersistenceStream.h for the implementation of this method.

If you are sub-classing from another Base class that implements persistence, use the macro ML_WRITETO_SUPER() to save the super-class data, because this takes care of writing the version number of the super class.

Reimplemented in ml::StandardItemModel, and ml::BaseItem.

Definition at line 142 of file mlBase.h.


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