Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
propertycollection.h
1 #pragma once
2 
3 #include <map>
4 #include <string>
5 #include <functional>
6 
7 #include <glow/logging.h>
8 
9 #include "def_regex.h"
10 
12 public:
13  virtual bool update(const std::string& key, const std::string& svalue) = 0;
14 };
15 
16 template <class T>
17 class PropertyImpl;
18 
19 template <class T>
21 public:
22  PropertyCollection(regexns::regex regex, std::function<T(const std::string&)> converter);
23 
24  PropertyImpl<T>* getImpl(const std::string& key);
25  PropertyImpl<T>* getImpl(const std::string& key, const T& defaultValue);
26 
27  virtual bool update(const std::string& key, const std::string& svalue) override;
28 
29  void set(const std::string& key, const T& value);
30 
31  T get(const std::string& name) const;
32  T get(const std::string& name, const T& defaultValue) const;
33 
34 
35 protected:
36  std::map<std::string, T> m_values;
37  std::map<std::string, PropertyImpl<T>*> m_properties;
38  regexns::regex m_regex;
39  std::function<T(const std::string&)> m_converter;
40 
41  PropertyImpl<T>* getOrCreate(const std::string& key);
42  PropertyImpl<T>* create(const std::string& key);
43 
44 };
45 
46 #include "propertycollection.inl"
Definition: propertycollection.h:20
Definition: propertycollection.h:11
Definition: property.h:6