A fuzzy logic C++ library
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends
slifis::DATA_DESCR Class Reference

Data description: what do we want in the datafile ? What column of data ? More...

#include <data_descr.hpp>

+ Collaboration diagram for slifis::DATA_DESCR:

List of all members.

Classes

struct  c_unique
 private class, used for fun ! More...

Public Member Functions

void Print (FILE *f, const char *msg=0) const
DATA_DESCR ComputeIndexesAfterLoading () const
 Adjust the indexes after loading data.
Constructors and related functions
 DATA_DESCR ()
 Constructor 1.
 DATA_DESCR (size_t NbInputs)
 Constructor 3, fills the input indexes with values from 0 to NbInputs-1 and output index with NbInputs.
 DATA_DESCR (std::string output, std::string inputs, char delim=';')
 Constructor 2.
void Clear ()
Fetching information on description
bool IsSet () const
size_t GetNbInputs () const
size_t GetInputIndex (size_t i) const
size_t GetOutputIndex () const
bool HasIndex (size_t idx) const
 Used to know if a given index idx (0-based) is used or not in the data description.
size_t GetHighestIndex () const
 Returns the highest index mentioned here, including input indexes and output index.
Editing description
void Set (std::string output, std::string inputs, char delim=';')
 Assigns description with strings.
void SetOutputColumn (size_t idx)
 Assign output index (starting from 1)
void SetOutputColumn (std::string idx)
 Assign output index (starting from 1)
void AddInputColumn (size_t idx)
 Adds a column index (starting from 1) to the list of the ones we want.
void AddInputColumn (std::string idx)
 Adds a column index (starting from 1) to the list of the ones we want.
void SetInputColumns (std::string str, char sep=';')
 Assigns the vector of requested input columns from a string, typically given from command line.

Private Member Functions

bool P_CheckOutputNotInInputs () const
 Returns false if the output index is included in the input indexes.

Private Attributes

size_t _out_idx
 Index of column of the output value.
std::vector< size_t > _v_in_idx
 Vector of indexes of input values, stored with increasing values.
struct slifis::DATA_DESCR::c_unique UniqueNumber

Friends

class DATA_SET

Detailed Description

Data description: what do we want in the datafile ? What column of data ?

This class is designed to hold information that the users enters via command-line arguments. It only holds column indexes, but holds no information on what kind of data lies there.

If runtime checks are enabled it will check at every usage that it is valid, i.e. the output index is not one of the input indexes.

Warning:
All column indexes here are stored as starting from 0, but user interface uses indexes starting from 1 (first column is "1").

Constructor & Destructor Documentation

Constructor 1.

References Clear().

slifis::DATA_DESCR::DATA_DESCR ( size_t  NbInputs) [inline]

Constructor 3, fills the input indexes with values from 0 to NbInputs-1 and output index with NbInputs.

References _out_idx, _v_in_idx, and UniqueNumber.

slifis::DATA_DESCR::DATA_DESCR ( std::string  output,
std::string  inputs,
char  delim = ';' 
) [inline]

Constructor 2.

Parameters:
outputa string containing the column number of the output value
inputsa string containing the column numbers of the input values, separated by delim (default is semi-colon)
delimdelimiter, default is semi-colon

References Set().


Member Function Documentation

void slifis::DATA_DESCR::Clear ( ) [inline]

References _out_idx, and _v_in_idx.

Referenced by DATA_DESCR().

bool slifis::DATA_DESCR::IsSet ( ) const [inline]
size_t slifis::DATA_DESCR::GetNbInputs ( ) const [inline]
size_t slifis::DATA_DESCR::GetInputIndex ( size_t  i) const
size_t slifis::DATA_DESCR::GetOutputIndex ( ) const [inline]
bool slifis::DATA_DESCR::HasIndex ( size_t  idx) const [inline]

Used to know if a given index idx (0-based) is used or not in the data description.

References _out_idx, and _v_in_idx.

Returns the highest index mentioned here, including input indexes and output index.

Referenced by slifis::DATA_SET::AssignDescription().

void slifis::DATA_DESCR::Set ( std::string  output,
std::string  inputs,
char  delim = ';' 
)

Assigns description with strings.

Parameters:
outputa string holding the index of output column, for example "5"
inputsthe input columns, for example "4;7;9"
delimthe delimiter character, default is ;

References __IN__, __OUT__, slifis::ERR_DATA_BAD_INDEX, and SLIFIS_ERROR_1.

Referenced by DATA_DESCR().

void slifis::DATA_DESCR::SetOutputColumn ( size_t  idx) [inline]

Assign output index (starting from 1)

References __IN__, __OUT__, _out_idx, slifis::ERR_DATA_BAD_INDEX, and SLIFIS_ERROR_2.

Referenced by slifis::DATA_SET::ReadData(), and SetOutputColumn().

void slifis::DATA_DESCR::SetOutputColumn ( std::string  idx) [inline]

Assign output index (starting from 1)

References __IN__, __OUT__, and SetOutputColumn().

void slifis::DATA_DESCR::AddInputColumn ( size_t  idx) [inline]

Adds a column index (starting from 1) to the list of the ones we want.

References __IN__, __OUT__, _v_in_idx, slifis::ERR_DATA_BAD_INDEX, and SLIFIS_ERROR_2.

Referenced by AddInputColumn().

void slifis::DATA_DESCR::AddInputColumn ( std::string  idx) [inline]

Adds a column index (starting from 1) to the list of the ones we want.

References __IN__, __OUT__, AddInputColumn(), slifis::ERR_DATA_BAD_INDEX, and SLIFIS_ERROR_2.

void slifis::DATA_DESCR::SetInputColumns ( std::string  str,
char  sep = ';' 
)

Assigns the vector of requested input columns from a string, typically given from command line.

Warning:
No checking at all is done here, as we don't know anything about the datafile !
Parameters:
strthe input string, with columns indexes ('1' means first column)
sepcharacter used as separator, default is ';'

References __IN__, __OUT__, slifis::ERR_DATA_BAD_INDEX, SLIFIS_ERROR_2, and slifis::TokensList().

void slifis::DATA_DESCR::Print ( FILE *  f,
const char *  msg = 0 
) const

References __IN__, and __OUT__.

Referenced by main().

Adjust the indexes after loading data.

When loading a file that has been given a description, only the required fields are loaded, so one needs to adjust this description. See file test_data_descr.cpp

References __IN__, __OUT__, _out_idx, _v_in_idx, slifis::ERR_DATA_DESCR_INVALID, and SLIFIS_ERROR.

Referenced by slifis::DATAFILE_INFO::AssignDataDescription(), and slifis::DATA_SET::ReadData().

bool slifis::DATA_DESCR::P_CheckOutputNotInInputs ( ) const [inline, private]

Returns false if the output index is included in the input indexes.

References _out_idx, and _v_in_idx.

Referenced by slifis::DATA_SET::AssignDescription(), and GetOutputIndex().


Friends And Related Function Documentation

friend class DATA_SET [friend]

Member Data Documentation

size_t slifis::DATA_DESCR::_out_idx [private]
std::vector<size_t> slifis::DATA_DESCR::_v_in_idx [private]

Vector of indexes of input values, stored with increasing values.

Referenced by AddInputColumn(), Clear(), ComputeIndexesAfterLoading(), DATA_DESCR(), GetNbInputs(), HasIndex(), IsSet(), and P_CheckOutputNotInInputs().

Referenced by DATA_DESCR().