SourceForge.net Logo timeSeries: timeSeries Class Library

lookupTable Class Reference
[Lookup tables]

class that represents a lookup table More...

#include <lookupTable.h>

List of all members.

Classes

class  badConversion
 thrown when a found result cannot be converted to the requested type More...
class  fieldNameNotFound
 thrown when a specified field name cannot be found More...
class  keyNotFound
 thrown when a specified keyname cannot be found More...
class  lookupExceptions
 lookup table exception class More...

Public Member Functions

 lookupTable (std::string fileName, std::string keyname)
 constructs a lookupTable from a data file
template<class T >
find (std::string keyVal, std::string fieldName)

Detailed Description

class that represents a lookup table

Overview
Lookup tables are constructed from tab-delimited text files containing record-oriented data. Each record consists of a n-tuple of data. There is no restriction on the type of the data contained in each field. The first line of the data file must contain the field labels.
When constructing the table, one field is designated as the key field. This is the only field that can be used to retrieve data. The value of this field may be queried and the value of any other field in the matching record may be retrieved using the find member function. For purposes of searching the key is always treated as a string. Searches are efficient since the tables are represented internally as a binary tree sorted on the key field. Once constructed, a given instance of a table may be copied efficiently because the actual table data is referenced via shared pointers. This means that large tables can be passed by value without penalty.
If searches on multiple keys are required, multiple lookupTable objects can be constructed from the same data file, specifying the appropriate key field each time. Unlike copying or passing by value, this does allocate memory for all the table data.
Examples:

campAnalysis.cpp, campVIRTTEXAnalysis.cpp, hmi04.cpp, and hmi04.h.


Constructor & Destructor Documentation

lookupTable::lookupTable ( std::string  fileName,
std::string  keyname 
)

constructs a lookupTable from a data file

Parameters:
fileName string containing the name of a tab-delimited data file
keyname string containing the key field name that will be used to retrieve data from the table

The data file must be a pre-existing tab-delimited file. The first row must contain labels for each data field


Member Function Documentation

template<class T >
T lookupTable::find ( std::string  keyVal,
std::string  fieldName 
) [inline]
Exceptions:
lookupTable::badConversion 
lookupTable::keyNotFound 
lookupTable::fieldNameNotFound 
Returns:
a data item of type T. The contents of the field will be converted to type T before returning. If the conversion cannot be completed a lookupTable::badConversion exception will be thrown.
Parameters:
keyVal a string containing the value of the key field that identifies the data record to be searched. If there are multiple records with the same keyVal, which record is returned is undefined. Therefore it is advisable to search only on unique keys.

If the keyVal is not found, find throws lookupTable::keyNotFound

If the fieldName is not found, find throws lookupTable::fieldNameNotFound

Parameters:
fieldName a string containing the name of the field to be retrieved
Examples:
campAnalysis.cpp, campVIRTTEXAnalysis.cpp, and hmi04.cpp.
Generated on Tue Mar 16 15:10:52 2010 for timeSeries by  doxygen 1.6.3