STK++ 0.9.13
STK::IDataHandler Class Referenceabstract

A DataHandler class allow to store various data set identified with an idData (a string). More...

#include <STK_IDataHandler.h>

Public Types

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

Public Member Functions

 IDataHandler ()
 default constructor
 
virtual ~IDataHandler ()
 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 a the Id of a dataset, find the Id of the model.
 
virtual int nbSample () const =0
 
void writeInfo (ostream &os) const
 write the info on os
 

Protected Attributes

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

Detailed Description

A DataHandler class allow to store various data set identified with an idData (a string).

To each data set there is an attached (statistical) model that can be adjusted to this data set. This statistical model is identified by an idModel (a string).

Note
all data set should have the same number of individuals.
In next version IDataHandler will disappear and will be replaced by DataHandlerBase class

Definition at line 65 of file STK_IDataHandler.h.

Member Typedef Documentation

◆ InfoMap

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

Definition at line 68 of file STK_IDataHandler.h.

Constructor & Destructor Documentation

◆ IDataHandler()

STK::IDataHandler::IDataHandler ( )
inline

default constructor

Definition at line 70 of file STK_IDataHandler.h.

70{}

◆ ~IDataHandler()

virtual STK::IDataHandler::~IDataHandler ( )
inlinevirtual

destructor

Definition at line 72 of file STK_IDataHandler.h.

72{}

Member Function Documentation

◆ addInfo()

bool STK::IDataHandler::addInfo ( std::string const idData,
std::string const idModel 
)
inline

Add an info descriptor to the data handler.

An info descriptor is a pair that allow to say that the data set handled having the name (ID) "idData" is modeled by the model with name (ID) "idModel".

Parameters
idDatacan be any string given by the user for identifying data.
idModelrepresents 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 116 of file STK_IDataHandler.h.

117{
118 // parse descriptor file
119 std::pair<InfoMap::iterator,bool> ret;
120 // check if identifer is already present
121 ret = info_.insert(std::pair<std::string,std::string>(idData, idModel));
122 // if name already exists, check if there is incoherence
123 if (ret.second==false)
124 {
125 if (ret.first->second != idModel)
126 {
127#ifdef STK_DMANAGER_DEBUG
128 stk_cerr << _T("In IDataHandler::addInfo, There exists an idData with a different idModel.\n");
129#endif
130 return false;
131 }
132 }
133 return true;
134}
#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, info_, and stk_cerr.

◆ getIdModelName()

bool STK::IDataHandler::getIdModelName ( std::string const idData,
std::string &  idModel 
) const
inline

Giving a the Id of a dataset, 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 143 of file STK_IDataHandler.h.

144{
145 bool res = false;
146 // show content
147 for (InfoMap::const_iterator it=info_.begin(); it!=info_.end(); ++it)
148 { if (it->first == idData) { idModel = it->second; res = true; break;}}
149 return res;
150}

References info_.

◆ info()

InfoMap const & STK::IDataHandler::info ( ) const
inline
Returns
the map with the idDatas and idModel of the models

Definition at line 74 of file STK_IDataHandler.h.

74{ return info_;}

References info_.

◆ nbSample()

virtual int STK::IDataHandler::nbSample ( ) const
pure virtual
Returns
the number of sample (the number of rows of the data sets)

◆ writeInfo()

void STK::IDataHandler::writeInfo ( ostream os) const
inline

write the info on os

Definition at line 109 of file STK_IDataHandler.h.

110{
111 // show content
112 for (InfoMap::const_iterator it=info_.begin(); it!=info_.end(); ++it)
113 os << _T("IdData: ") << it->first << _T(", IdModel: ") << it->second << _T('\n');
114}

References _T, and info_.

Member Data Documentation

◆ info_

InfoMap STK::IDataHandler::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 106 of file STK_IDataHandler.h.

Referenced by addInfo(), getIdModelName(), info(), and writeInfo().


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