Main Page · Modules · All Classes · Class Hierarchy
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
MCDataContainer Class Reference

Data container. More...

#include <MCDataContainer.hpp>

Inheritance diagram for MCDataContainer:
MPDataContainer

Public Member Functions

 MCDataContainer (const std::string &name, bool portable=false)
 Class constructor. More...
 
virtual ~MCDataContainer ()
 Class destructor.
 
bool IsPortable () const
 Check if the data container is portable. More...
 
void Clear ()
 Clear the data container by destroying all data items.
 
std::string GetName () const
 Get the data container name. More...
 
MCBinaryDataEncode () const
 Save the data container into binary form. More...
 
void Dump () const
 Dump container items.
 
MC::StringList GetDataNames () const
 Get data item names. More...
 
void AddData (MCDataItemBase &item)
 Add a new data item. More...
 
MCDataItemBaseGetData (const std::string &data_name)
 Get a data item. More...
 
const MC::DataItemBasePtrList & GetAllData () const
 Get all data items. More...
 
void RemoveData (const std::string &data_name)
 Remove a data item. More...
 
virtual MCDataItemBaseGetInputArchiveDataType (const std::string &type_name, const std::string &data_name)
 Create a custom data type in a derived container. More...
 

Static Public Member Functions

static MCDataContainerDecode (const MCBinaryData &data, bool portable=false, MCDataContainer *instance=nullptr)
 Load the data container from binary form. More...
 

Private Attributes

std::string Name
 Data container name.
 
bool Portable
 Data container type (portable/non-portable)
 
MC::DataItemBasePtrList Items
 Data items.
 

Detailed Description

Data container.

Definition at line 156 of file MCDataContainer.hpp.

Constructor & Destructor Documentation

MCDataContainer::MCDataContainer ( const std::string &  name,
bool  portable = false 
)

Class constructor.

Parameters
nameContainer name
portableWhenever the new container should use portable serialization

Note: The portable and non-portable data containers are NOT compatible and they cannot be encoded/decoded into each other.

Definition at line 71 of file MCDataContainer.cpp.

Member Function Documentation

void MCDataContainer::AddData ( MCDataItemBase item)

Add a new data item.

Parameters
itemNew data item

If a data item exists with the same name, the old data item is destroyed before adding the new data.

Definition at line 207 of file MCDataContainer.cpp.

MCDataContainer * MCDataContainer::Decode ( const MCBinaryData data,
bool  portable = false,
MCDataContainer instance = nullptr 
)
static

Load the data container from binary form.

Parameters
dataBinary data
portableWhether the encoded container is portable
instancePointer to data container instance (may be NULL)
Returns
Decoded data container otherwise NULL.

A data container instance can be passed to support custom data types with a derived data container type.

Definition at line 140 of file MCDataContainer.cpp.

MCBinaryData * MCDataContainer::Encode ( ) const

Save the data container into binary form.

Returns
Newly allocated binary data otherwise NULL.

Definition at line 114 of file MCDataContainer.cpp.

const MC::DataItemBasePtrList & MCDataContainer::GetAllData ( ) const

Get all data items.

Returns
Data item list.

Definition at line 237 of file MCDataContainer.cpp.

MCDataItemBase * MCDataContainer::GetData ( const std::string &  data_name)

Get a data item.

Parameters
data_nameData name
Returns
Pointer to the data item otherwise NULL.

Definition at line 224 of file MCDataContainer.cpp.

MC::StringList MCDataContainer::GetDataNames ( ) const

Get data item names.

Returns
Data item names

Definition at line 195 of file MCDataContainer.cpp.

MCDataItemBase * MCDataContainer::GetInputArchiveDataType ( const std::string &  type_name,
const std::string &  data_name 
)
virtual

Create a custom data type in a derived container.

Parameters
type_nameCustom data type name to be created
data_nameCustom data name to be created
Returns
Newly allocated custom data item, otherwise NULL.

Reimplemented in MPDataContainer.

Definition at line 257 of file MCDataContainer.cpp.

std::string MCDataContainer::GetName ( ) const

Get the data container name.

Returns
Data container name

Definition at line 108 of file MCDataContainer.cpp.

bool MCDataContainer::IsPortable ( ) const

Check if the data container is portable.

Returns
True if portable otherwise false.

Definition at line 91 of file MCDataContainer.cpp.

void MCDataContainer::RemoveData ( const std::string &  data_name)

Remove a data item.

Parameters
data_nameData name to be removed

Definition at line 243 of file MCDataContainer.cpp.


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