Privacy
An open-source, flexible 3D physical simulation framework
mars::data_broker::DataPackage Class Reference

A collection of DataItems. More...

#include <DataPackage.h>

Public Member Functions

 DataPackage ()
 
 ~DataPackage ()
 
 DataPackage (const DataPackage &other)
 
DataPackageoperator= (const DataPackage &other)
 
DataItemoperator[] (size_t index)
 returns the DataItem at position index. More...
 
const DataItemoperator[] (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

DataItemgetItemByName (const std::string &name)
 
const DataItemgetItemByName (const std::string &name) const
 

Private Attributes

std::vector< DataItempackage
 
std::vector< DataItemConnectionconnections
 

Detailed Description

A collection of DataItems.

Definition at line 44 of file DataPackage.h.

Constructor & Destructor Documentation

◆ DataPackage() [1/2]

mars::data_broker::DataPackage::DataPackage ( )

Definition at line 27 of file DataPackage.cpp.

◆ ~DataPackage()

mars::data_broker::DataPackage::~DataPackage ( )

Definition at line 30 of file DataPackage.cpp.

◆ DataPackage() [2/2]

mars::data_broker::DataPackage::DataPackage ( const DataPackage other)

Definition at line 36 of file DataPackage.cpp.

Member Function Documentation

◆ add() [1/9]

void mars::data_broker::DataPackage::add ( const DataItem item)
inline

adds the DataItem item to the end of the package.

Definition at line 82 of file DataPackage.h.

◆ add() [2/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
int  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [3/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
unsigned int  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [4/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
long  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [5/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
unsigned long  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [6/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
float  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [7/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
double  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [8/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
const std::string &  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ add() [9/9]

void mars::data_broker::DataPackage::add ( const std::string &  itemName,
bool  val 
)

add a new DataItem to the end of the package.

Parameters
itemNameThe name of the new DataItem.
valThe initial value of the DataItem.

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.

◆ clear()

void mars::data_broker::DataPackage::clear ( )
inline

remove all DataItems from this package

Definition at line 64 of file DataPackage.h.

◆ empty()

bool mars::data_broker::DataPackage::empty ( ) const
inline

returns true if there is no DataItem in the package.

false otherwise.

Definition at line 77 of file DataPackage.h.

◆ get() [1/2]

template<typename T >
bool mars::data_broker::DataPackage::get ( const std::string &  itemName,
T *  val 
) const
inline

gets the value of the DataItem with the given name

Parameters
itemNameThe name of the DataItem whose value should be retrieved.
valA pointer to a variable where the value can be written to.
Returns
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.

◆ get() [2/2]

template<typename T >
bool mars::data_broker::DataPackage::get ( long  index,
T *  val 
) const
inline

gets the value of the DataItem at the given index in the package

Parameters
indexThe index into the package of the DataItem whose value should be retrieved.
valA pointer to a variable where the value can be written to.
Returns
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.

◆ getIndexByName()

long mars::data_broker::DataPackage::getIndexByName ( const std::string &  itemName) const

returns the index of the DataItem with the given name.

Parameters
itemNameThe name of the DataItem whose index to retrieve.
Returns
The index of the DataItem with the given name or -1 if no such DataItem exists.

Definition at line 71 of file DataPackage.cpp.

◆ getItemByName() [1/2]

DataItem * mars::data_broker::DataPackage::getItemByName ( const std::string &  name)
private

Definition at line 92 of file DataPackage.cpp.

◆ getItemByName() [2/2]

const DataItem * mars::data_broker::DataPackage::getItemByName ( const std::string &  name) const
private

Definition at line 88 of file DataPackage.cpp.

◆ getType() [1/2]

DataType mars::data_broker::DataPackage::getType ( const std::string &  itemName) const

gets the type of the DataItem with the given name

Parameters
itemNameThe name of the DataItem whose type should be retrieved.
Returns
The DataType of the DataItem if a DataItem named itemName exists. DataType::UNDEFINED_TYPE otherwise.

Definition at line 59 of file DataPackage.cpp.

◆ getType() [2/2]

DataType mars::data_broker::DataPackage::getType ( long  index) const

gets the type of the DataItem at the given index in the package

Parameters
indexThe index into the package of the DataItem whose type should be retrieved.
Returns
The DataType of the DataItem if index is a valid. DataType::UNDEFINED_TYPE otherwise.

Definition at line 64 of file DataPackage.cpp.

◆ operator=()

DataPackage & mars::data_broker::DataPackage::operator= ( const DataPackage other)

Definition at line 39 of file DataPackage.cpp.

◆ operator[]() [1/2]

DataItem& mars::data_broker::DataPackage::operator[] ( size_t  index)
inline

returns the DataItem at position index.

There is no bounds checking

Definition at line 55 of file DataPackage.h.

◆ operator[]() [2/2]

const DataItem& mars::data_broker::DataPackage::operator[] ( size_t  index) const
inline

returns the DataItem at position index.

Definition at line 59 of file DataPackage.h.

◆ set() [1/2]

template<typename T >
bool mars::data_broker::DataPackage::set ( const std::string &  itemName,
val 
)
inline

tries to set the value of the DataItem with the given name

Parameters
itemNameThe name of the DataItem whose value should be set.
valThe value to which the DataItem should be set.
Returns
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.

◆ set() [2/2]

template<typename T >
bool mars::data_broker::DataPackage::set ( long  index,
val 
)
inline

tries to set the value of the DataItem at the given index in the package.

Parameters
indexThe index into the package of the DataItem whose value should be set.
valThe value to which the DataItem should be set.
Returns
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.

◆ size()

size_t mars::data_broker::DataPackage::size ( ) const
inline

return the number of DataItems in this package

Definition at line 70 of file DataPackage.h.

Member Data Documentation

◆ connections

std::vector<DataItemConnection> mars::data_broker::DataPackage::connections
private

Definition at line 214 of file DataPackage.h.

◆ package

std::vector<DataItem> mars::data_broker::DataPackage::package
private

Definition at line 213 of file DataPackage.h.


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