STK++ 0.9.13
|
implementation
of the DataHandlerBase class using ReadWriteCsv and Array2D.
More...
#include <STK_DataHandler.h>
Public Types | |
typedef DataHandlerBase< DataHandler > | Base |
typedef DataHandlerBase< DataHandler >::InfoMap | InfoMap |
![]() | |
typedef std::map< std::string, std::string > | InfoMap |
Public Member Functions | |
DataHandler () | |
default constructor | |
~DataHandler () | |
destructor | |
ReadWriteCsv const & | data () const |
get the whole data set | |
ReadWriteCsv const & | descriptor () const |
get the whole descriptor set | |
int | nbSample () const |
int | nbVariable () const |
void | setWithNames (bool withNames) |
set withNames flag | |
bool | readDataFromCsvFile (std::string const &datafile, std::string descriptorfile) |
read a data file and its companion description file. | |
bool | readDataFromCsvFile (std::string const &datafile, std::string const &idData, std::string const &idModel) |
read a data set from an Array2D. | |
template<typename Type > | |
bool | readDataFromArray2D (Array2D< Type > const &data, std::string const &idData, std::string const &idModel) |
read a data set from an Array2D. | |
template<typename Array > | |
bool | readDataFromArray (ExprBase< Array > const &data, std::string const &idData, std::string const &idModel) |
read a data set from an Array or Expression. | |
template<typename Type > | |
void | getData (std::string const &idData, Array2D< Type > &data) const |
void | removeData (std::string const &idData) |
remove the data with the given idData | |
![]() | |
~DataHandlerBase () | |
destructor | |
InfoMap const & | info () 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 | |
![]() | |
Derived & | asDerived () |
static cast : return a reference of this with a cast to the derived class. | |
Derived const & | asDerived () 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 const * | asPtrDerived () 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 | |
std::vector< int > | colIndex (std::string const &idData) const |
lookup on the descriptors in order to get the columns of the ReadWriteCsv with the Id idData. | |
![]() | |
DataHandlerBase () | |
default constructor | |
![]() | |
IRecursiveTemplate () | |
constructor. | |
~IRecursiveTemplate () | |
destructor. | |
Private Attributes | |
bool | withNames_ |
first line with names ? | |
ReadWriteCsv | data_ |
data files | |
ReadWriteCsv | descriptor_ |
descriptor files with two rows. | |
Additional Inherited Members | |
![]() | |
InfoMap | info_ |
Store the informations of the mixtures in the form (idData, idModel) with. | |
implementation
of the DataHandlerBase class using ReadWriteCsv and Array2D.
The DataHandler class allow to read various csv files with their description files and to get the columns identified by an idData in an Array2D
. All data are stored in memory in a ReadWriteCsv structure.
Definition at line 69 of file STK_DataHandler.h.
Definition at line 72 of file STK_DataHandler.h.
Definition at line 73 of file STK_DataHandler.h.
|
inline |
default constructor
Definition at line 75 of file STK_DataHandler.h.
References data_, and descriptor_.
|
inline |
lookup on the descriptors in order to get the columns of the ReadWriteCsv with the Id idData.
idData | id of the data to get |
Definition at line 138 of file STK_DataHandler.cpp.
References descriptor_.
Referenced by getData().
|
inline |
get the whole data set
Definition at line 80 of file STK_DataHandler.h.
References data_.
Referenced by getData(), readDataFromArray(), readDataFromArray2D(), and readDataFromCsvFile().
|
inline |
get the whole descriptor set
Definition at line 82 of file STK_DataHandler.h.
References descriptor_.
void STK::DataHandler::getData | ( | std::string const & | idData, |
Array2D< Type > & | data | ||
) | const |
Definition at line 148 of file STK_DataHandler.h.
References _T, colIndex(), data(), data_, nbSample(), nbVariable(), and stk_cout.
|
inline |
Definition at line 84 of file STK_DataHandler.h.
References data_.
Referenced by getData().
|
inline |
Definition at line 86 of file STK_DataHandler.h.
References data_.
Referenced by getData().
bool STK::DataHandler::readDataFromArray | ( | ExprBase< Array > const & | data, |
std::string const & | idData, | ||
std::string const & | idModel | ||
) |
read a data set from an Array or Expression.
This method should be essentially used:
data | the data set |
idData | the id of the data |
idModel | an id identifying the model to use with the data set |
Definition at line 191 of file STK_DataHandler.h.
References STK::DataHandlerBase< DataHandler >::addInfo(), STK::baseIdx, data(), data_, descriptor_, STK::stringNa, and STK::typeToString().
bool STK::DataHandler::readDataFromArray2D | ( | Array2D< Type > const & | data, |
std::string const & | idData, | ||
std::string const & | idModel | ||
) |
read a data set from an Array2D.
This method should be essentially used:
data | the data set |
idData | the id of the data |
idModel | an id identifying the model to use with the data set |
Definition at line 169 of file STK_DataHandler.h.
References STK::DataHandlerBase< DataHandler >::addInfo(), STK::baseIdx, data(), data_, descriptor_, STK::stringNa, and STK::typeToString().
bool STK::DataHandler::readDataFromCsvFile | ( | std::string const & | datafile, |
std::string const & | idData, | ||
std::string const & | idModel | ||
) |
read a data set from an Array2D.
read a data file
datafile | the data file to get |
idData | the id of the data |
idModel | an id identifying the model to use with the data set |
Definition at line 41 of file STK_DataHandler.cpp.
References _T, STK::DataHandlerBase< DataHandler >::addInfo(), STK::baseIdx, data(), data_, descriptor_, STK::IRunnerBase::error(), stk_cerr, STK::stringNa, and withNames_.
bool STK::DataHandler::readDataFromCsvFile | ( | std::string const & | datafile, |
std::string | descriptorfile | ||
) |
read a data file and its companion description file.
Definition at line 68 of file STK_DataHandler.cpp.
References _T, STK::DataHandlerBase< DataHandler >::addInfo(), data_, descriptor_, STK::IRunnerBase::error(), stk_cerr, and withNames_.
remove the data with the given idData
Definition at line 121 of file STK_DataHandler.cpp.
References data_, descriptor_, and STK::DataHandlerBase< DataHandler >::info_.
set withNames flag
Definition at line 89 of file STK_DataHandler.h.
References withNames_.
|
private |
data files
Definition at line 138 of file STK_DataHandler.h.
Referenced by data(), DataHandler(), getData(), nbSample(), nbVariable(), readDataFromArray(), readDataFromArray2D(), readDataFromCsvFile(), readDataFromCsvFile(), and removeData().
|
private |
descriptor files with two rows.
On the first row we get the idModel, on the second row, we get the idData
Definition at line 142 of file STK_DataHandler.h.
Referenced by colIndex(), DataHandler(), descriptor(), readDataFromArray(), readDataFromArray2D(), readDataFromCsvFile(), readDataFromCsvFile(), and removeData().
|
private |
first line with names ?
Definition at line 136 of file STK_DataHandler.h.
Referenced by readDataFromCsvFile(), readDataFromCsvFile(), and setWithNames().