BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
LookupTable.h
Go to the documentation of this file.
1#ifndef BPMNOS_LookupTable_H
2#define BPMNOS_LookupTable_H
3
4#include <string>
5#include <unordered_map>
6#include <variant>
7#include <initializer_list>
8#include <filesystem>
9#include <optional>
16
17#include <functional>
18
19namespace BPMNOS::Model {
20
21/**
22 * @brief Class generating a lookup table from a CSV file.
23 *
24 * A LookupTable loads a CSV file with header line and
25 * allows to retrieve entries using a list of key-value pairs.
26 * Should multiple entries match the given key-value pairs,
27 * the first match is returned.
28 */
30public:
31 /**
32 * @brief Constructs a LookupTable object using data from a CSV file.
33 *
34 * This constructor initializes a LookupTable object using the data read from a CSV
35 * file specified by the filename and folders. It first tries to read the file using
36 * the provided filename. If the file is not found in the current working directory,
37 * the function looks for the file in the list of folders provided in the folders parameter.
38 *
39 * @param filename The name of the CSV file to read the data from.
40 */
41 LookupTable(const std::string& name, const std::string& source, const std::vector<std::string>& folders);
42 const std::string name;
43
44 double at( const std::vector< double >& keys ) const;
45 size_t size() const { return lookupMap.size(); }
46protected:
47 CSVReader openCsv(const std::string& filename, const std::vector<std::string>& folders);
48 void createMap(const std::string& source, const std::vector<std::string>& folders);
50};
51
52} // namespace BPMNOS::Model
53
54#endif // BPMNOS_LookupTable_H
Class generating a lookup table from a CSV file.
Definition LookupTable.h:29
CSVReader openCsv(const std::string &filename, const std::vector< std::string > &folders)
double at(const std::vector< double > &keys) const
const std::string name
Definition LookupTable.h:42
BPMNOS::vector_map< std::vector< double >, double > lookupMap
Definition LookupTable.h:49
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.
void createMap(const std::string &source, const std::vector< std::string > &folders)
Wrapper class around std::unordered_map for maps with vector keys.
Definition vector_map.h:31
size_type size() const noexcept
Definition vector_map.h:96