| 1 |
#ifndef __READERLP_BUILDER_HPP__ |
| 2 |
#define __READERLP_BUILDER_HPP__ |
| 3 |
|
| 4 |
#include <memory> |
| 5 |
#include <string> |
| 6 |
#include <unordered_map> |
| 7 |
|
| 8 |
#include "model.hpp" |
| 9 |
|
| 10 |
struct Builder { |
| 11 |
std::unordered_map<std::string, std::shared_ptr<Variable>> variables; |
| 12 |
|
| 13 |
Model model; |
| 14 |
|
| 15 |
std::shared_ptr<Variable> getvarbyname(const std::string& name) { |
| 16 |
auto it = variables.find(name); |
| 17 |
if (it != variables.end()) return it->second; |
| 18 |
auto newvar = std::shared_ptr<Variable>(new Variable(name)); |
| 19 |
variables.insert(std::make_pair(name, newvar)); |
| 20 |
model.variables.push_back(newvar); |
| 21 |
return newvar; |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
#endif |