Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
tlp::DataSet Class Reference

#include <DataSet.h>

Public Member Functions

 DataSet (const DataSet &set)
 
bool empty () const
 
bool exist (const std::string &str) const
 
template<typename T >
bool get (const std::string &key, T &value) const
 
template<typename T >
bool getAndFree (const std::string &key, T &value)
 
DataTypegetData (const std::string &str) const
 
tlp::Iterator< std::pair
< std::string, DataType * > > * 
getValues () const
 
DataSetoperator= (const DataSet &set)
 
bool readData (std::istream &is, const std::string &prop, const std::string &outputTypeName)
 
void remove (const std::string &str)
 
template<typename T >
void set (const std::string &key, const T &value)
 
void setData (const std::string &str, const DataType *value)
 
unsigned int size () const
 
std::string toString () const
 
void writeData (std::ostream &os, const std::string &prop, const DataType *dt) const
 

Static Public Member Functions

static bool read (std::istream &is, DataSet &ds)
 
template<typename T >
static void registerDataTypeSerializer (const DataTypeSerializer &serializer)
 
static DataTypeSerializer * typenameToSerializer (const std::string &name)
 
static void write (std::ostream &os, const DataSet &ds)
 

Detailed Description

A container that can store data from any type.

The DataSet aggregate data of various types into a single structure and map each value to a key (std::string) describing its name. DataSet is mainly used in plugins. When creating a plugin, one can add input parameters (using tlp::WithParameter methods) and retrieve them from the dataSet member variable once they have been set by the user.

Definition at line 165 of file DataSet.h.

Member Function Documentation

bool tlp::DataSet::empty ( ) const

Indicates whether the set is empty of not.

bool tlp::DataSet::exist ( const std::string &  str) const
Parameters
strthe name of the member to look for
Returns
true if str exists into the DataSet.
template<typename T >
bool tlp::DataSet::get ( const std::string &  key,
T &  value 
) const

Returns the stored value associated with the given key. The stored value is a copy of the original value that was set. If there is no value associated with the given key, the input value is left untouched.

Parameters
keyThe key with which the data we want to retrieve is associated.
valueA variable wich will be overwritten with the value to retrieve.
Returns
bool Whether there is a value associated with given key or not.

Definition at line 22 of file DataSet.cxx.

template<typename T >
bool tlp::DataSet::getAndFree ( const std::string &  key,
T &  value 
)

Returns the stored value, and deletes the stored copy. If no value is found, nothing is deleted.

Parameters
keyThe key with which the data we want to retrieve is associated.
valueA variable wich will be overwritten with the value to retrieve.
Returns
bool Whether there is a value associated with given key or not.

Definition at line 36 of file DataSet.cxx.

DataType* tlp::DataSet::getData ( const std::string &  str) const
Parameters
strThe name of the element to retrieve
Returns
A untyped value for a given element name. NULL if the element does not exist
tlp::Iterator< std::pair<std::string, DataType*> >* tlp::DataSet::getValues ( ) const
Returns
An iterator over stored values as a std::pair name => untyped value
DataSet& tlp::DataSet::operator= ( const DataSet set)

Performs a deep copy of a DataSet into another.

static bool tlp::DataSet::read ( std::istream &  is,
DataSet ds 
)
static

Reads a stream and stores its contents into a DataSet.

bool tlp::DataSet::readData ( std::istream &  is,
const std::string &  prop,
const std::string &  outputTypeName 
)

Read a value and stores it into the specified type.

template<typename T >
static void tlp::DataSet::registerDataTypeSerializer ( const DataTypeSerializer &  serializer)
inlinestatic

Registers a serializer for a known type.

Serializers are used to write/read from std::ostream objects when saving DataSet instances.

Definition at line 222 of file DataSet.h.

void tlp::DataSet::remove ( const std::string &  str)

Removes an element from the DataSet.

Parameters
strthe name of the element to remove
template<typename T >
void tlp::DataSet::set ( const std::string &  key,
const T &  value 
)

Stores a copy of the given param, associated with the key. The value must have a well-formed copy constructor.

Parameters
keyThe key which can be used to retrieve the data.
valueThe data to store.
Returns
void

Definition at line 52 of file DataSet.cxx.

void tlp::DataSet::setData ( const std::string &  str,
const DataType value 
)

Set from an untyped value.

unsigned int tlp::DataSet::size ( ) const

Returns the number of registered values.

std::string tlp::DataSet::toString ( ) const
Returns
A std::string representation of a DataSet
static DataTypeSerializer* tlp::DataSet::typenameToSerializer ( const std::string &  name)
static
Returns
the data type serializer associated to the given typename. NULL if no serializer is found
static void tlp::DataSet::write ( std::ostream &  os,
const DataSet ds 
)
static

Serializes a DataSet into a stream.

void tlp::DataSet::writeData ( std::ostream &  os,
const std::string &  prop,
const DataType dt 
) const

write an embedded value