Tulip  5.4.0
Large graphs analysis and drawing
tlp::DataSet Class Reference

#include <DataSet.h>

Public Member Functions

 DataSet (const DataSet &set)
 
bool empty () const
 
bool exists (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
 
template<typename T >
std::string getTypeName () const
 
std::string getTypeName (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 189 of file DataSet.h.

Member Function Documentation

◆ empty()

bool tlp::DataSet::empty ( ) const

Indicates whether the set is empty of not.

◆ exists()

bool tlp::DataSet::exists ( const std::string &  str) const
Parameters
strthe name of the member to look for
Returns
true if str exists into the DataSet.

◆ get()

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 which will be overwritten with the value to retrieve.
Returns
bool Whether there is a value associated with given key or not.

Definition at line 23 of file DataSet.cxx.

+ Here is the caller graph for this function:

◆ getAndFree()

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 which will be overwritten with the value to retrieve.
Returns
bool Whether there is a value associated with given key or not.

Definition at line 38 of file DataSet.cxx.

◆ getData()

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. nullptr if the element does not exist

◆ getTypeName() [1/2]

template<typename T >
std::string tlp::DataSet::getTypeName ( ) const
inline

Returns the mangled name of a type.

Returns
std::string the mangled name (typeid(T).name())

Definition at line 250 of file DataSet.h.

◆ getTypeName() [2/2]

std::string tlp::DataSet::getTypeName ( const std::string &  str) const
Parameters
strthe name of the member to look for
Returns
the mangled name of the type if str exists into the DataSet. An empty string if not.

◆ getValues()

tlp::Iterator<std::pair<std::string, DataType *> >* tlp::DataSet::getValues ( ) const
Returns
An iterator over stored values as a std::pair name => untyped value

◆ operator=()

DataSet& tlp::DataSet::operator= ( const DataSet set)

Performs a deep copy of a DataSet into another.

◆ read()

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

Reads a stream and stores its contents into a DataSet.

◆ readData()

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.

◆ registerDataTypeSerializer()

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 260 of file DataSet.h.

◆ remove()

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

Removes an element from the DataSet.

Parameters
strthe name of the element to remove

◆ set()

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 55 of file DataSet.cxx.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setData()

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

Set from an untyped value.

+ Here is the caller graph for this function:

◆ size()

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

Returns the number of registered values.

◆ toString()

std::string tlp::DataSet::toString ( ) const
Returns
A std::string representation of a DataSet

◆ typenameToSerializer()

static DataTypeSerializer* tlp::DataSet::typenameToSerializer ( const std::string &  name)
static
Returns
the data type serializer associated to the given typename. nullptr if no serializer is found

◆ write()

static void tlp::DataSet::write ( std::ostream &  os,
const DataSet ds 
)
static

Serializes a DataSet into a stream.

◆ writeData()

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

write an embedded value