STK++ 0.9.13
STK::DataHandlerBase< Derived > Class Template Reference

A class derived from a DataHandlerBase allows to store various data sets identified by an idData and an idModel. More...

#include <STK_DataHandlerBase.h>

Inheritance diagram for STK::DataHandlerBase< Derived >:
Inheritance graph

Public Types

typedef std::map< std::string, std::string > InfoMap
 

Public Member Functions

 ~DataHandlerBase ()
 destructor
 
InfoMap constinfo () const
 
bool addInfo (std::string const &idData, std::string const &idModel)
 Add an info descriptor to the data handler.
 
bool getIdModelName (std::string const &idData, std::string &idModel) const
 Giving the Id of a data set, find the Id of the model.
 
void writeInfo (ostream &os) const
 write infoMap on os
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Protected Member Functions

 DataHandlerBase ()
 default constructor
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 

Protected Attributes

InfoMap info_
 Store the informations of the mixtures in the form (idData, idModel) with.
 

Detailed Description

template<class Derived>
class STK::DataHandlerBase< Derived >

A class derived from a DataHandlerBase allows to store various data sets identified by an idData and an idModel.

A typical usage of a data handler is to store and handle various multiple sets of data. Each data set possess an id (idData) and can be retrieved by using it. To each data set is also associated an idModel allowing to know which kind of (statistical) model is applied in order to model the data set.

Note
In incoming version of STK++ DataHandlerBase could be renamed as IDataHandler

Definition at line 69 of file STK_DataHandlerBase.h.

Member Typedef Documentation

◆ InfoMap

template<class Derived >
typedef std::map<std::string, std::string> STK::DataHandlerBase< Derived >::InfoMap

Definition at line 76 of file STK_DataHandlerBase.h.

Constructor & Destructor Documentation

◆ DataHandlerBase()

template<class Derived >
STK::DataHandlerBase< Derived >::DataHandlerBase ( )
inlineprotected

default constructor

Definition at line 73 of file STK_DataHandlerBase.h.

73{}

◆ ~DataHandlerBase()

template<class Derived >
STK::DataHandlerBase< Derived >::~DataHandlerBase ( )
inline

destructor

Definition at line 78 of file STK_DataHandlerBase.h.

78{}

Member Function Documentation

◆ addInfo()

template<class Derived >
bool STK::DataHandlerBase< Derived >::addInfo ( std::string const idData,
std::string const idModel 
)

Add an info descriptor to the data handler.

An info descriptor is a pair that allow to say that all columns of the data set(s) handled by the data handler and having the name "idData" are modeled by the model with model "idModel".

Parameters
idDatacan be any string given by the user for identifying data.
idModelrepresent the idModel of a given model (can be defined inside or outside STK++).
Note
If the pair (idData, idModel) already exists then addInfo will do nothing.
Returns
false if there exists already an idData matched with an other idModel, true otherwise.

Definition at line 127 of file STK_DataHandlerBase.h.

128{
129 // parse descriptor file
130 std::pair<InfoMap::iterator,bool> ret;
131 // check if identifer is already present
132 ret = info_.insert(std::pair<std::string,std::string>(idData, idModel));
133 // if name already exists, check if there is incoherence
134 if (ret.second==false)
135 {
136 if (ret.first->second != idModel)
137 {
138#ifdef STK_DMANAGER_DEBUG
139 stk_cerr << _T("In DataHandlerBase::addInfo, There exists an idData with a different idModel.\n");
140#endif
141 return false;
142 }
143 }
144 return true;
145}
#define stk_cerr
Standard stk error stream.
#define _T(x)
Let x unmodified.
InfoMap info_
Store the informations of the mixtures in the form (idData, idModel) with.

References _T, and stk_cerr.

◆ getIdModelName()

template<class Derived >
bool STK::DataHandlerBase< Derived >::getIdModelName ( std::string const idData,
std::string &  idModel 
) const

Giving the Id of a data set, find the Id of the model.

Parameters
idDatacan be any string given by the user for identifying data.
idModelThe Id of the model associated with the data (not modified if idData is not present in the map).
Returns
true if there exists an idData in the InfoMap, false otherwise.

Definition at line 155 of file STK_DataHandlerBase.h.

156{
157 bool res = false;
158 // find idData
159 InfoMap::const_iterator it = info_.find(idData);
160 if (it != info_.end()) { idModel = it->second; res = true;}
161 return res;
162}

◆ info()

template<class Derived >
InfoMap const & STK::DataHandlerBase< Derived >::info ( ) const
inline
Returns
the map with the idDatas and idModel of the models

Definition at line 80 of file STK_DataHandlerBase.h.

80{ return info_;}

References STK::DataHandlerBase< Derived >::info_.

◆ writeInfo()

template<class Derived >
void STK::DataHandlerBase< Derived >::writeInfo ( ostream os) const

write infoMap on os

Definition at line 166 of file STK_DataHandlerBase.h.

167{
168 // show content
169 for (InfoMap::const_iterator it=info_.begin(); it!=info_.end(); ++it)
170 os << _T("IdData: ") << it->first << _T(", IdModel: ") << it->second << _T('\n');
171}

References _T.

Member Data Documentation

◆ info_

template<class Derived >
InfoMap STK::DataHandlerBase< Derived >::info_
protected

Store the informations of the mixtures in the form (idData, idModel) with.

  • idData: an arbitrary idData for data.
  • idModel: a string which represent a (statistical) model.
    See also
    stringToMixture

Definition at line 110 of file STK_DataHandlerBase.h.

Referenced by STK::DataHandlerBase< Derived >::info().


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