summaryrefslogtreecommitdiff
path: root/include/llmr/style/class_properties.hpp
blob: 55d6aa2cc6af1672b7a6354f99aa84d41c4e3c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef LLMR_STYLE_CLASS_PROPERTIES
#define LLMR_STYLE_CLASS_PROPERTIES

#include <llmr/style/property_key.hpp>
#include <llmr/style/property_value.hpp>
#include <llmr/style/property_transition.hpp>

#include <map>

namespace llmr {

class ClassProperties {
public:
    inline ClassProperties() {}
    inline ClassProperties(ClassProperties &&properties)
        : properties(std::move(properties.properties)) {}

    inline void set(PropertyKey key, const PropertyValue &value) {
        properties.emplace(key, value);
    }

    inline void set(PropertyKey key, const PropertyTransition &transition) {
        transitions.emplace(key, transition);
    }

    const PropertyTransition &getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const;

    // Route-through iterable interface so that you can iterate on the object as is.
    inline std::map<PropertyKey, PropertyValue>::const_iterator begin() const {
        return properties.begin();
    }
    inline std::map<PropertyKey, PropertyValue>::const_iterator end() const {
        return properties.end();
    }

public:
    std::map<PropertyKey, PropertyValue> properties;
    std::map<PropertyKey, PropertyTransition> transitions;
};

}

#endif