Main Page · Modules · All Classes · Class Hierarchy |
Data container. More...
#include <MCDataContainer.hpp>
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... | |
MCBinaryData * | Encode () 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... | |
MCDataItemBase * | GetData (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 MCDataItemBase * | GetInputArchiveDataType (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 MCDataContainer * | Decode (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. | |
Data container.
Definition at line 156 of file MCDataContainer.hpp.
MCDataContainer::MCDataContainer | ( | const std::string & | name, |
bool | portable = false |
||
) |
Class constructor.
name | Container name |
portable | Whenever 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.
void MCDataContainer::AddData | ( | MCDataItemBase & | item | ) |
Add a new data item.
item | New 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.
|
static |
Load the data container from binary form.
data | Binary data |
portable | Whether the encoded container is portable |
instance | Pointer to data container instance (may be 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.
Definition at line 114 of file MCDataContainer.cpp.
const MC::DataItemBasePtrList & MCDataContainer::GetAllData | ( | ) | const |
MCDataItemBase * MCDataContainer::GetData | ( | const std::string & | data_name | ) |
Get a data item.
data_name | Data name |
Definition at line 224 of file MCDataContainer.cpp.
MC::StringList MCDataContainer::GetDataNames | ( | ) | const |
|
virtual |
Create a custom data type in a derived container.
type_name | Custom data type name to be created |
data_name | Custom data name to be created |
Reimplemented in MPDataContainer.
Definition at line 257 of file MCDataContainer.cpp.
std::string MCDataContainer::GetName | ( | ) | const |
Get the data container name.
Definition at line 108 of file MCDataContainer.cpp.
bool MCDataContainer::IsPortable | ( | ) | const |
Check if the data container is portable.
Definition at line 91 of file MCDataContainer.cpp.
void MCDataContainer::RemoveData | ( | const std::string & | data_name | ) |
Remove a data item.
data_name | Data name to be removed |
Definition at line 243 of file MCDataContainer.cpp.