![]() |
An open-source, flexible 3D physical simulation framework
|
A collection of DataItems. More...
#include <DataPackage.h>
Public Member Functions | |
DataPackage () | |
~DataPackage () | |
DataPackage (const DataPackage &other) | |
DataPackage & | operator= (const DataPackage &other) |
DataItem & | operator[] (size_t index) |
returns the DataItem at position index. More... | |
const DataItem & | operator[] (size_t index) const |
returns the DataItem at position index. More... | |
void | clear () |
remove all DataItems from this package More... | |
size_t | size () const |
return the number of DataItems in this package More... | |
bool | empty () const |
returns true if there is no DataItem in the package. More... | |
void | add (const DataItem &item) |
adds the DataItem item to the end of the package. More... | |
template<typename T > | |
bool | get (const std::string &itemName, T *val) const |
gets the value of the DataItem with the given name More... | |
template<typename T > | |
bool | get (long index, T *val) const |
gets the value of the DataItem at the given index in the package More... | |
DataType | getType (const std::string &itemName) const |
gets the type of the DataItem with the given name More... | |
DataType | getType (long index) const |
gets the type of the DataItem at the given index in the package More... | |
template<typename T > | |
bool | set (const std::string &itemName, T val) |
tries to set the value of the DataItem with the given name More... | |
template<typename T > | |
bool | set (long index, T val) |
tries to set the value of the DataItem at the given index in the package. More... | |
void | add (const std::string &itemName, int val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, unsigned int val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, long val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, unsigned long val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, float val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, double val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, const std::string &val) |
add a new DataItem to the end of the package. More... | |
void | add (const std::string &itemName, bool val) |
add a new DataItem to the end of the package. More... | |
long | getIndexByName (const std::string &itemName) const |
returns the index of the DataItem with the given name. More... | |
Private Member Functions | |
DataItem * | getItemByName (const std::string &name) |
const DataItem * | getItemByName (const std::string &name) const |
Private Attributes | |
std::vector< DataItem > | package |
std::vector< DataItemConnection > | connections |
A collection of DataItems.
Definition at line 44 of file DataPackage.h.
mars::data_broker::DataPackage::DataPackage | ( | ) |
Definition at line 27 of file DataPackage.cpp.
mars::data_broker::DataPackage::~DataPackage | ( | ) |
Definition at line 30 of file DataPackage.cpp.
mars::data_broker::DataPackage::DataPackage | ( | const DataPackage & | other | ) |
Definition at line 36 of file DataPackage.cpp.
|
inline |
adds the DataItem item to the end of the package.
Definition at line 82 of file DataPackage.h.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
int | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 107 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
unsigned int | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 115 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
long | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 123 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
unsigned long | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 131 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
float | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 139 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
double | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 147 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
const std::string & | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 155 of file DataPackage.cpp.
void mars::data_broker::DataPackage::add | ( | const std::string & | itemName, |
bool | val | ||
) |
add a new DataItem to the end of the package.
The DataItem::type will be derived from the type of val. Note that the DataPackage does not check for name collisions.
Definition at line 163 of file DataPackage.cpp.
|
inline |
remove all DataItems from this package
Definition at line 64 of file DataPackage.h.
|
inline |
returns true
if there is no DataItem in the package.
false
otherwise.
Definition at line 77 of file DataPackage.h.
|
inline |
gets the value of the DataItem with the given name
itemName | The name of the DataItem whose value should be retrieved. |
val | A pointer to a variable where the value can be written to. |
true
if the value was successfully retrieved. false
if the pointer val was of the wrong type or the DataItem with the name itemName doesn't exist. In case false
is returned the content of the pointer remains unchanged. Definition at line 98 of file DataPackage.h.
|
inline |
gets the value of the DataItem at the given index in the package
index | The index into the package of the DataItem whose value should be retrieved. |
val | A pointer to a variable where the value can be written to. |
true
if the value was successfully retrieved. false
if the pointer val was of the wrong type or the index is out of bounds. In case false
is returned the content of the pointer remains unchanged. Definition at line 114 of file DataPackage.h.
long mars::data_broker::DataPackage::getIndexByName | ( | const std::string & | itemName | ) | const |
|
private |
Definition at line 92 of file DataPackage.cpp.
|
private |
Definition at line 88 of file DataPackage.cpp.
DataType mars::data_broker::DataPackage::getType | ( | const std::string & | itemName | ) | const |
gets the type of the DataItem with the given name
itemName | The name of the DataItem whose type should be retrieved. |
Definition at line 59 of file DataPackage.cpp.
DataType mars::data_broker::DataPackage::getType | ( | long | index | ) | const |
gets the type of the DataItem at the given index in the package
index | The index into the package of the DataItem whose type should be retrieved. |
Definition at line 64 of file DataPackage.cpp.
DataPackage & mars::data_broker::DataPackage::operator= | ( | const DataPackage & | other | ) |
Definition at line 39 of file DataPackage.cpp.
|
inline |
returns the DataItem at position index.
There is no bounds checking
Definition at line 55 of file DataPackage.h.
|
inline |
returns the DataItem at position index.
Definition at line 59 of file DataPackage.h.
|
inline |
tries to set the value of the DataItem with the given name
itemName | The name of the DataItem whose value should be set. |
val | The value to which the DataItem should be set. |
true
if the value was successfully set. false
if the type of val does not match the type of the DataItem or the DataItem doesn't exist. When false
is returned the current value of the DataItem is unchanged. Definition at line 150 of file DataPackage.h.
|
inline |
tries to set the value of the DataItem at the given index in the package.
index | The index into the package of the DataItem whose value should be set. |
val | The value to which the DataItem should be set. |
true
if the value was successfully set. false
if the type of val does not match the type of the DataItem or the index is out of bounds. When false
is returned the current value of the DataItem is unchanged. Definition at line 167 of file DataPackage.h.
|
inline |
return the number of DataItems in this package
Definition at line 70 of file DataPackage.h.
|
private |
Definition at line 214 of file DataPackage.h.
|
private |
Definition at line 213 of file DataPackage.h.