1 #ifndef VECTORFIELDRENDERING_OPTIONS_HXX
2 #define VECTORFIELDRENDERING_OPTIONS_HXX
5 #include <unordered_map>
9 namespace VFRendering {
21 typedef decltype(Option<i>().default_value) type;
41 std::vector<int> keys()
const;
43 std::vector<int> update(
const Options &other);
46 struct IStorableOption {
47 virtual ~IStorableOption() {}
51 struct StorableOption :
public IStorableOption {
52 StorableOption(
const typename Type<i>::type& value) : m_value(value) {}
53 typename Type<i>::type m_value;
56 std::unordered_map<int, std::shared_ptr<IStorableOption>> m_options;
61 Options Options::withOption(
typename Type<index>::type value) {
63 options.set<index>(value);
68 typename Options::template Type<index>::type Options::get()
const {
70 if (
auto storableOption =
static_cast<StorableOption<index> *
>(m_options.at(index).get())) {
71 return storableOption->m_value;
74 return Option<index>().default_value;
78 bool Options::has()
const {
79 return (m_options.find(index) != m_options.end());
83 void Options::set(
typename Type<index>::type value) {
84 m_options[index] = std::make_shared<StorableOption<index>>(value);
88 void Options::clear() {
89 m_options.erase(index);