Euphoria
propertytree.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 #include <map>
5 #include <memory>
6 
7 #include "base/vec3.h"
8 
9 namespace eu::core
10 {
11  enum class ValueType
12  {
13  int_type,
14  float_type,
15  vec3f_type,
16  map_type
17  };
18 
19  struct Value
20  {
21  const ValueType type;
22 
23  explicit Value(ValueType vt) : type(vt) {}
24  virtual ~Value() = default;
25 
26  Value(const Value&) = delete;
27  Value(Value&&) = delete;
28  void operator=(const Value&) = delete;
29  void operator=(Value&&) = delete;
30  };
31 
32  struct IntValue : public Value
33  {
34  int value;
35 
36  explicit IntValue(int i);
37 
38  [[nodiscard]] static int& get(core::Value* value);
39  };
40 
41  struct FloatValue : public Value
42  {
43  float value;
44 
45  explicit FloatValue(float f);
46 
47  [[nodiscard]] static float& get(core::Value* value);
48  };
49 
50  struct Vec3fValue : public Value
51  {
53 
54  explicit Vec3fValue(const vec3f& v);
55 
56  [[nodiscard]] static vec3f& get(core::Value* value);
57  };
58 
59  struct MapValue : public Value
60  {
61  std::map<std::string, std::shared_ptr<Value>> properties;
62 
63  MapValue();
64 
65  void set(const std::string& name, std::shared_ptr<Value> value);
66  std::shared_ptr<Value> get_or_null(const std::string& name);
67  };
68 
69 }
static float & get(core::Value *value)
Definition: propertytree.cc:25
static int & get(core::Value *value)
Definition: propertytree.cc:13
std::shared_ptr< Value > get_or_null(const std::string &name)
Definition: propertytree.cc:57
void set(const std::string &name, std::shared_ptr< Value > value)
Definition: propertytree.cc:51
std::map< std::string, std::shared_ptr< Value > > properties
Definition: propertytree.h:61
Value(Value &&)=delete
void operator=(const Value &)=delete
virtual ~Value()=default
void operator=(Value &&)=delete
Value(const Value &)=delete
const ValueType type
Definition: propertytree.h:21
Value(ValueType vt)
Definition: propertytree.h:23
Vec3fValue(const vec3f &v)
Definition: propertytree.cc:34
static vec3f & get(core::Value *value)
Definition: propertytree.cc:38
Definition: vec3.h:48