BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
BPMNOS::Model::LookupTable Class Reference

Class generating a lookup table from a CSV file. More...

Detailed Description

A LookupTable loads a CSV file with header line and allows to retrieve entries using a list of key-value pairs. Should multiple entries match the given key-value pairs, the first match is returned.

Definition at line 29 of file LookupTable.h.

#include <LookupTable.h>

Public Member Functions

 LookupTable (const std::string &name, const std::string &source, const std::vector< std::string > &folders)
 Constructs a LookupTable object using data from a CSV file.
 
double at (const std::vector< double > &keys) const
 
size_t size () const
 

Public Attributes

const std::string name
 

Protected Member Functions

CSVReader openCsv (const std::string &filename, const std::vector< std::string > &folders)
 
void createMap (const std::string &source, const std::vector< std::string > &folders)
 

Protected Attributes

BPMNOS::vector_map< std::vector< double >, double > lookupMap
 

Constructor & Destructor Documentation

◆ LookupTable()

LookupTable::LookupTable ( const std::string & name,
const std::string & source,
const std::vector< std::string > & folders )

This constructor initializes a LookupTable object using the data read from a CSV file specified by the filename and folders. It first tries to read the file using the provided filename. If the file is not found in the current working directory, the function looks for the file in the list of folders provided in the folders parameter.

Parameters
filenameThe name of the CSV file to read the data from.

Definition at line 7 of file LookupTable.cpp.

Member Function Documentation

◆ at()

double LookupTable::at ( const std::vector< double > & keys) const

Definition at line 61 of file LookupTable.cpp.

◆ createMap()

void LookupTable::createMap ( const std::string & source,
const std::vector< std::string > & folders )
protected

Definition at line 31 of file LookupTable.cpp.

◆ openCsv()

BPMNOS::CSVReader LookupTable::openCsv ( const std::string & filename,
const std::vector< std::string > & folders )
protected

Definition at line 13 of file LookupTable.cpp.

◆ size()

size_t BPMNOS::Model::LookupTable::size ( ) const
inline

Definition at line 45 of file LookupTable.h.

Member Data Documentation

◆ lookupMap

BPMNOS::vector_map< std::vector< double >, double > BPMNOS::Model::LookupTable::lookupMap
protected

Definition at line 49 of file LookupTable.h.

◆ name

const std::string BPMNOS::Model::LookupTable::name

Definition at line 42 of file LookupTable.h.


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