MeVisLab Toolbox Reference
ml::AbstractPersistenceOutputStream Class Referenceabstract

Class for writing object data to a stream. More...

#include <mlAbstractPersistenceStream.h>

Inheritance diagram for ml::AbstractPersistenceOutputStream:
ml::AbstractPersistenceStream ml::XMLPersistenceOutputStream

Public Member Functions

 ~AbstractPersistenceOutputStream () override=default
 
void startStructWithVersion (int version, const char *name=nullptr)
 start a versioned struct More...
 
template<typename T >
void write (const std::vector< T > &values, const char *name=nullptr)
 Write vectors of primitive values to the stream. More...
 
template<typename T , size_t n, class DataContainer >
void write (const FloatingPointVector< T, n, DataContainer > &value, const char *name=nullptr)
 Write float vectors like vec3f to the stream. More...
 
template<typename T , size_t n>
void write (const TVectorNDBase< T, n > &value, const char *name=nullptr)
 Write integer vectors like ImageVector to the stream. More...
 
template<typename T , size_t n>
void write (const FloatingPointMatrix< T, n > &value, const char *name=nullptr)
 Write float matrices like mat4 to the stream. More...
 
virtual void writeObject (const Base *const obj, const char *name=nullptr)
 Write a Base object to the stream. More...
 
virtual void writeData (const void *data, size_t len, const char *name=nullptr)=0
 Write binary data to stream. More...
 
virtual bool isValidElementName (const char *name)
 check if name is valid for use with persistence entries (by default this checks if the name is valid for use as a XML tag, but implementations may relax - or tighten - this check) More...
 
virtual void write (bool value, const char *name=nullptr)
 Write primitive values to the stream. More...
 
void write (MLint32 value, const char *name=nullptr)
 
void write (MLuint32 value, const char *name=nullptr)
 
void write (MLint64 value, const char *name=nullptr)
 
void write (MLuint64 value, const char *name=nullptr)
 
void write (MLfloat value, const char *name=nullptr)
 
void write (MLdouble value, const char *name=nullptr)
 
void write (const std::string &value, const char *name=nullptr)
 
void write (const char *value, const char *name=nullptr)
 
- Public Member Functions inherited from ml::AbstractPersistenceStream
void startList (const char *name=nullptr, const char *xmlItemName="Item", bool xmlSuppressScope=false)
 Start a new list of values in the data stream, must be ended with endList(). More...
 
void endList ()
 End reading/writing of the list. More...
 
void startStruct (const char *name=nullptr)
 Start a new struct of values in the data stream, must be ended with endStruct(). More...
 
void endStruct ()
 End reading/writing of struct values. More...
 
virtual bool isBinary () const =0
 Is the stream in a binary format? (otherwise in a readable text format) More...
 

Protected Member Functions

 AbstractPersistenceOutputStream ()
 
virtual void writeString (const char *name, const std::string &value)=0
 Abstract writing method that needs to be implemented by derived classes. More...
 
void nameCheck (const char *name) override
 overriden to perform additional check in Debug mode if name is suitable for the persistence format (uses isValidElementName), prints an error if not More...
 
virtual void setObjectID (int id)=0
 Implementation of Base object persistence, set attribute on currently open struct (implementation hint: these can be stored unnamed, if they are read or not is always deduced from the current state of the persistence stream)unique id for each pointer value - currently unused. More...
 
virtual void setObjectType (const char *type)=0
 base type name More...
 
virtual void setObjectVersion (int version)=0
 persistence version More...
 
virtual void writeValues (const char *name, const MLint32 *values, size_t n, bool fixedList)=0
 Abstract writing methods that need to be implemented by derived classes. More...
 
virtual void writeValues (const char *name, const MLuint32 *values, size_t n, bool fixedList)=0
 
virtual void writeValues (const char *name, const MLint64 *values, size_t n, bool fixedList)=0
 
virtual void writeValues (const char *name, const MLuint64 *values, size_t n, bool fixedList)=0
 
virtual void writeValues (const char *name, const MLfloat *values, size_t n, bool fixedList)=0
 
virtual void writeValues (const char *name, const MLdouble *values, size_t n, bool fixedList)=0
 
- Protected Member Functions inherited from ml::AbstractPersistenceStream
 AbstractPersistenceStream ()
 
virtual ~AbstractPersistenceStream ()
 
bool isInList () const
 Check if the stream is currently in "list" mode. Otherwise it is in "struct" mode. More...
 
size_t nestingDepth () const
 return depth of nesting stack (created by startList/startStruct), used to check nesting rules More...
 
virtual void internalError (const char *msg, const char *arg=nullptr)
 Log an internal error. Usually called to indicate wrong usage of interface. More...
 
virtual void startListImpl (const char *name, const char *xmlItemName, bool xmlSuppressScope)=0
 Abstract methods called by above methods, need to be implemented in derived classes. More...
 
virtual void endListImpl ()=0
 
virtual void startStructImpl (const char *name)=0
 
virtual void endStructImpl ()=0
 

Detailed Description

Class for writing object data to a stream.

This class has write methods for the types bool, MLint32, MLuint32, MLint64, MLuint64, float, double, std::string and all vector and matrix types from MLLinearAlgebra. You can also write binary data (with writeData()) and Base objects (with writeObject()) to the stream.

Data can be organized in sub-structures or in lists. Data items usually have to be given a name, unless they are list items, in which case it is forbidden to give a name. Have a look at the startStruct()/endStruct() startList()/endList() methods of AbstractPersistenceStream on how to start/end new scopes.

Definition at line 120 of file mlAbstractPersistenceStream.h.

Constructor & Destructor Documentation

◆ ~AbstractPersistenceOutputStream()

ml::AbstractPersistenceOutputStream::~AbstractPersistenceOutputStream ( )
overridedefault

◆ AbstractPersistenceOutputStream()

ml::AbstractPersistenceOutputStream::AbstractPersistenceOutputStream ( )
inlineprotected

Definition at line 192 of file mlAbstractPersistenceStream.h.

Member Function Documentation

◆ isValidElementName()

virtual bool ml::AbstractPersistenceOutputStream::isValidElementName ( const char *  name)
virtual

check if name is valid for use with persistence entries (by default this checks if the name is valid for use as a XML tag, but implementations may relax - or tighten - this check)

◆ nameCheck()

void ml::AbstractPersistenceOutputStream::nameCheck ( const char *  name)
overrideprotectedvirtual

overriden to perform additional check in Debug mode if name is suitable for the persistence format (uses isValidElementName), prints an error if not

Reimplemented from ml::AbstractPersistenceStream.

◆ setObjectID()

virtual void ml::AbstractPersistenceOutputStream::setObjectID ( int  id)
protectedpure virtual

Implementation of Base object persistence, set attribute on currently open struct (implementation hint: these can be stored unnamed, if they are read or not is always deduced from the current state of the persistence stream)unique id for each pointer value - currently unused.

Implemented in ml::XMLPersistenceOutputStream.

◆ setObjectType()

virtual void ml::AbstractPersistenceOutputStream::setObjectType ( const char *  type)
protectedpure virtual

base type name

Implemented in ml::XMLPersistenceOutputStream.

◆ setObjectVersion()

virtual void ml::AbstractPersistenceOutputStream::setObjectVersion ( int  version)
protectedpure virtual

persistence version

Implemented in ml::XMLPersistenceOutputStream.

◆ startStructWithVersion()

void ml::AbstractPersistenceOutputStream::startStructWithVersion ( int  version,
const char *  name = nullptr 
)

start a versioned struct

◆ write() [1/13]

virtual void ml::AbstractPersistenceOutputStream::write ( bool  value,
const char *  name = nullptr 
)
virtual

Write primitive values to the stream.

Note: the default implementation writes bools as MLint32 - binary formats might want to be more efficient

◆ write() [2/13]

void ml::AbstractPersistenceOutputStream::write ( const char *  value,
const char *  name = nullptr 
)
inline

Definition at line 141 of file mlAbstractPersistenceStream.h.

References write().

Referenced by write().

◆ write() [3/13]

template<typename T , size_t n>
void ml::AbstractPersistenceOutputStream::write ( const FloatingPointMatrix< T, n > &  value,
const char *  name = nullptr 
)
inline

Write float matrices like mat4 to the stream.

Definition at line 171 of file mlAbstractPersistenceStream.h.

References ml::FloatingPointMatrix< VectorT, size >::getValuesToPtr().

◆ write() [4/13]

template<typename T , size_t n, class DataContainer >
void ml::AbstractPersistenceOutputStream::write ( const FloatingPointVector< T, n, DataContainer > &  value,
const char *  name = nullptr 
)
inline

Write float vectors like vec3f to the stream.

Definition at line 155 of file mlAbstractPersistenceStream.h.

◆ write() [5/13]

void ml::AbstractPersistenceOutputStream::write ( const std::string &  value,
const char *  name = nullptr 
)

◆ write() [6/13]

template<typename T >
void ml::AbstractPersistenceOutputStream::write ( const std::vector< T > &  values,
const char *  name = nullptr 
)
inline

Write vectors of primitive values to the stream.

Currently supported are MLint32, MLuint32, MLint64, MLuint64, MLfloat and MLdouble

Definition at line 147 of file mlAbstractPersistenceStream.h.

◆ write() [7/13]

template<typename T , size_t n>
void ml::AbstractPersistenceOutputStream::write ( const TVectorNDBase< T, n > &  value,
const char *  name = nullptr 
)
inline

Write integer vectors like ImageVector to the stream.

Definition at line 163 of file mlAbstractPersistenceStream.h.

References ml::TVectorNDBase< CompIntType, NumDim >::array.

◆ write() [8/13]

void ml::AbstractPersistenceOutputStream::write ( MLdouble  value,
const char *  name = nullptr 
)

◆ write() [9/13]

void ml::AbstractPersistenceOutputStream::write ( MLfloat  value,
const char *  name = nullptr 
)

◆ write() [10/13]

void ml::AbstractPersistenceOutputStream::write ( MLint32  value,
const char *  name = nullptr 
)

◆ write() [11/13]

void ml::AbstractPersistenceOutputStream::write ( MLint64  value,
const char *  name = nullptr 
)

◆ write() [12/13]

void ml::AbstractPersistenceOutputStream::write ( MLuint32  value,
const char *  name = nullptr 
)

◆ write() [13/13]

void ml::AbstractPersistenceOutputStream::write ( MLuint64  value,
const char *  name = nullptr 
)

◆ writeData()

virtual void ml::AbstractPersistenceOutputStream::writeData ( const void *  data,
size_t  len,
const char *  name = nullptr 
)
pure virtual

Write binary data to stream.

Implemented in ml::XMLPersistenceOutputStream.

◆ writeObject()

virtual void ml::AbstractPersistenceOutputStream::writeObject ( const Base *const  obj,
const char *  name = nullptr 
)
virtual

Write a Base object to the stream.

This uses the Base::writeTo() method of the object and the methods setObjectType() and setObjectVersion().

◆ writeString()

virtual void ml::AbstractPersistenceOutputStream::writeString ( const char *  name,
const std::string &  value 
)
protectedpure virtual

Abstract writing method that needs to be implemented by derived classes.

Implemented in ml::XMLPersistenceOutputStream.

◆ writeValues() [1/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLdouble values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

◆ writeValues() [2/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLfloat values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

◆ writeValues() [3/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLint32 values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

Abstract writing methods that need to be implemented by derived classes.

fixedList tells the stream if the number of elements to write is fixed (and known when reading) or if it needs to be stored in the stream.

Implemented in ml::XMLPersistenceOutputStream.

◆ writeValues() [4/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLint64 values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

◆ writeValues() [5/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLuint32 values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

◆ writeValues() [6/6]

virtual void ml::AbstractPersistenceOutputStream::writeValues ( const char *  name,
const MLuint64 values,
size_t  n,
bool  fixedList 
)
protectedpure virtual

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