OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
WProtonData Class Reference

Holds the csv data. More...

#include <WProtonData.h>

+ Collaboration diagram for WProtonData:

Public Types

typedef std::shared_ptr< WProtonDataSPtr
 shared_ptr that points to itself More...
 

Public Member Functions

 WProtonData (WDataSetCSV::ContentSPtr csvHeader, WDataSetCSV::ContentSPtr csvData)
 constructor More...
 
WDataSetCSV::ContentSPtr getCSVHeader ()
 getter More...
 
WDataSetCSV::ContentSPtr getCSVData ()
 getter More...
 
void setCSVHeader (WDataSetCSV::ContentSPtr csvHeader)
 setter More...
 
void setCSVData (WDataSetCSV::ContentSPtr csvData)
 setter More...
 
void setStateIndex (std::string columnName, int index)
 setter More...
 
int getColumnIndexBySelection (std::string selectedName)
 getter More...
 
int getColumnIndex (std::string columnName)
 getter More...
 
bool isColumnAvailable (std::string columnName)
 checks whether columns are available More...
 
WDataSetCSV::ContentElemSPtr getColumnTypes ()
 Get column types, stored in a string vector. More...
 
std::vector< std::string > getHeaderFromType (std::list< std::string > typeNames)
 Return a vector of filtered Headers. More...
 

Private Member Functions

void detectColumnTypesFromCsvData (WDataSetCSV::ContentSPtr csvData)
 Reads csv data and stores column types in m_columnTypes. More...
 
std::string determineColumnTypeByString (std::string cellValue)
 Determines column type due to cellValue. More...
 
bool checkIfDoubleColumnCanBeInteger (int columnNumber)
 Checks, if values of a column, containing double values, can be converted to integers. More...
 

Private Attributes

WDataSetCSV::ContentSPtr m_csvHeader
 Stores column index of data. More...
 
WDataSetCSV::ContentSPtr m_csvData
 Stores data from obtained input file. More...
 
std::map< std::string, int > m_columnMap
 Stores data as map. More...
 
std::map< std::string, int > m_ColumnMapSelectedIndex
 Stores index of the selected single-selector (ColumnPropertyHandler) More...
 
WDataSetCSV::ContentElemSPtr m_columnTypes
 Stores the information, which data type is stored in associated column. More...
 

Friends

class WProtonDataTest
 only test class may be friend More...
 

Detailed Description

Holds the csv data.

Definition at line 42 of file WProtonData.h.

Member Typedef Documentation

◆ SPtr

typedef std::shared_ptr< WProtonData > WProtonData::SPtr

shared_ptr that points to itself

Definition at line 52 of file WProtonData.h.

Constructor & Destructor Documentation

◆ WProtonData()

WProtonData::WProtonData ( WDataSetCSV::ContentSPtr  csvHeader,
WDataSetCSV::ContentSPtr  csvData 
)
explicit

constructor

Parameters
csvHeaderpointer to a column-header of the CSV-file
csvDatapointer to a content of the CSV file

Definition at line 34 of file WProtonData.cpp.

References setCSVData(), and setCSVHeader().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkIfDoubleColumnCanBeInteger()

bool WProtonData::checkIfDoubleColumnCanBeInteger ( int  columnNumber)
private

Checks, if values of a column, containing double values, can be converted to integers.

Parameters
columnNumberthe column number within m_csvHeader
Returns
true, if all double values of a column ends with ".0"; false otherwise

Definition at line 170 of file WProtonData.cpp.

References m_csvData.

Referenced by detectColumnTypesFromCsvData().

+ Here is the caller graph for this function:

◆ detectColumnTypesFromCsvData()

void WProtonData::detectColumnTypesFromCsvData ( WDataSetCSV::ContentSPtr  csvData)
private

Reads csv data and stores column types in m_columnTypes.

Parameters
csvDatathe input csv data

Definition at line 123 of file WProtonData.cpp.

References checkIfDoubleColumnCanBeInteger(), determineColumnTypeByString(), WDataType::getDouble(), WDataType::getInt(), m_columnTypes, and m_csvHeader.

Referenced by setCSVData().

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

◆ determineColumnTypeByString()

std::string WProtonData::determineColumnTypeByString ( std::string  cellValue)
private

Determines column type due to cellValue.

Parameters
cellValuethe value of a cell on the basis of which the column type is to be determined
Returns
either "int", "double" or "string"

Definition at line 151 of file WProtonData.cpp.

References WDataType::getDouble(), WDataType::getInt(), and WDataType::getString().

Referenced by detectColumnTypesFromCsvData(), and WProtonDataTest::testDetermineColumnTypeByString().

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

◆ getColumnIndex()

int WProtonData::getColumnIndex ( std::string  columnName)

getter

Parameters
columnNameName of column-header of the CSV-file
Returns
return the position of column-header of the CSV-file as int

Definition at line 108 of file WProtonData.cpp.

References m_columnMap.

Referenced by WProtonDataTest::testGetColumnIndex().

+ Here is the caller graph for this function:

◆ getColumnIndexBySelection()

int WProtonData::getColumnIndexBySelection ( std::string  selectedName)

getter

Parameters
selectedNameName of selected name of single-selection
Returns
return the position current selected item

Definition at line 102 of file WProtonData.cpp.

References m_ColumnMapSelectedIndex.

Referenced by WProtonDataTest::testSetterGetterStateIndex().

+ Here is the caller graph for this function:

◆ getColumnTypes()

WDataSetCSV::ContentElemSPtr WProtonData::getColumnTypes ( )

Get column types, stored in a string vector.

Positions within this vector are linked to positions in m_csvHeader

Returns
a shared pointer to m_columnTypes

Definition at line 118 of file WProtonData.cpp.

References m_columnTypes.

Referenced by WProtonDataTest::testDetectColumnTypesFromCsvData().

+ Here is the caller graph for this function:

◆ getCSVData()

WDataSetCSV::ContentSPtr WProtonData::getCSVData ( )

getter

Returns
pointer to a content of the CSV file

Definition at line 81 of file WProtonData.cpp.

References m_csvData.

◆ getCSVHeader()

WDataSetCSV::ContentSPtr WProtonData::getCSVHeader ( )

getter

Returns
pointer to a column-header of the CSV-file

Definition at line 86 of file WProtonData.cpp.

References m_csvHeader.

◆ getHeaderFromType()

std::vector< std::string > WProtonData::getHeaderFromType ( std::list< std::string >  typeNames)

Return a vector of filtered Headers.

Parameters
typeNamesTypes of filter
Returns
Return a vector of filtered Headers

Definition at line 189 of file WProtonData.cpp.

References WDataType::getDefault(), m_columnTypes, and m_csvHeader.

+ Here is the call graph for this function:

◆ isColumnAvailable()

bool WProtonData::isColumnAvailable ( std::string  columnName)

checks whether columns are available

Parameters
columnNameTHe name of the column.
Returns
true if column is available, false if column is not available

Definition at line 97 of file WProtonData.cpp.

References m_ColumnMapSelectedIndex.

Referenced by WProtonDataTest::testIsColumnAvailable().

+ Here is the caller graph for this function:

◆ setCSVData()

void WProtonData::setCSVData ( WDataSetCSV::ContentSPtr  csvData)

setter

Parameters
csvDataset m_csvData

Definition at line 64 of file WProtonData.cpp.

References detectColumnTypesFromCsvData(), and m_csvData.

Referenced by WProtonDataTest::testSetCSVDataNull(), and WProtonData().

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

◆ setCSVHeader()

void WProtonData::setCSVHeader ( WDataSetCSV::ContentSPtr  csvHeader)

setter

Parameters
csvHeaderset m_csvHeader

Definition at line 40 of file WProtonData.cpp.

References m_columnMap, and m_csvHeader.

Referenced by WProtonDataTest::testSetCSVHeaderEmpty(), WProtonDataTest::testSetCSVHeaderNull(), and WProtonData().

+ Here is the caller graph for this function:

◆ setStateIndex()

void WProtonData::setStateIndex ( std::string  columnName,
int  index 
)

setter

Parameters
columnNameName of column-header of the CSV-file
indexposition of column-header of the CSV-file

Definition at line 91 of file WProtonData.cpp.

References m_ColumnMapSelectedIndex.

Referenced by WProtonDataTest::testIsColumnAvailable(), and WProtonDataTest::testSetterGetterStateIndex().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WProtonDataTest

friend class WProtonDataTest
friend

only test class may be friend

Definition at line 47 of file WProtonData.h.

Member Data Documentation

◆ m_columnMap

std::map< std::string, int > WProtonData::m_columnMap
private

Stores data as map.

Definition at line 149 of file WProtonData.h.

Referenced by getColumnIndex(), and setCSVHeader().

◆ m_ColumnMapSelectedIndex

std::map< std::string, int > WProtonData::m_ColumnMapSelectedIndex
private

Stores index of the selected single-selector (ColumnPropertyHandler)

Definition at line 154 of file WProtonData.h.

Referenced by getColumnIndexBySelection(), isColumnAvailable(), and setStateIndex().

◆ m_columnTypes

WDataSetCSV::ContentElemSPtr WProtonData::m_columnTypes
private

Stores the information, which data type is stored in associated column.

Definition at line 159 of file WProtonData.h.

Referenced by detectColumnTypesFromCsvData(), getColumnTypes(), and getHeaderFromType().

◆ m_csvData

WDataSetCSV::ContentSPtr WProtonData::m_csvData
private

Stores data from obtained input file.

Definition at line 144 of file WProtonData.h.

Referenced by checkIfDoubleColumnCanBeInteger(), getCSVData(), and setCSVData().

◆ m_csvHeader

WDataSetCSV::ContentSPtr WProtonData::m_csvHeader
private

Stores column index of data.

Definition at line 139 of file WProtonData.h.

Referenced by detectColumnTypesFromCsvData(), getCSVHeader(), getHeaderFromType(), and setCSVHeader().


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