Sleeping Wombat GUI  0.100
swGUI
PropertyPath.h
Go to the documentation of this file.
1 #pragma once
2 
11 
12 #include <vector>
13 
14 
16 template< typename KeyType >
18 {
19 private:
20  std::vector< rttr::property > m_path;
21 
22 public:
24  explicit PropertyPath ();
25  explicit PropertyPath ( EngineObject* object, const std::string& propertyPath );
26  ~PropertyPath () = default;
27 
28  KeyType GetValue ( EngineObject* object );
29  void SetValue ( EngineObject* object, KeyType& value );
30 };
31 
32 
33 //====================================================================================//
34 // Implementation
35 //====================================================================================//
36 
37 // ================================ //
38 //
39 template< typename KeyType >
41 {}
42 
43 // ================================ //
44 //
45 template< typename KeyType >
46 inline PropertyPath< KeyType >::PropertyPath ( EngineObject* object, const std::string& propertyPath )
47  : m_path( Properties::GetPropertyPath( object, propertyPath ) )
48 {}
49 
50 // ================================ //
51 //
52 template< typename KeyType >
54 {
55  auto finalPair = Properties::GetProperty( object, m_path );
56  auto& owner = finalPair.first;
57  auto& prop = finalPair.second;
58 
59  return Serialization::GetPropertyValue< KeyType >( prop, owner );
60 }
61 
62 // ================================ //
63 //
64 template< typename KeyType >
66 {
67  auto finalPair = Properties::GetProperty( object, m_path );
68  auto& owner = finalPair.first;
69  auto& prop = finalPair.second;
70 
71  Serialization::SetPropertyValue( prop, owner, value );
72 }
KeyType
Definition: all_0.js:13
static std::pair< rttr::variant, rttr::property > GetProperty(EngineObject *object, const std::string &propertyPath, char separator= '/')
Definition: Properties.cpp:66
std::vector< rttr::property > m_path
Definition: PropertyPath.h:20
void SetValue(EngineObject *object, KeyType &value)
Definition: PropertyPath.h:65
Klasa bazowa dla obiektów, które mają być dostępne w edytorze poprzez rttr. Należy po niej odziedzicz...
Definition: EngineObject.h:22
Definition: PropertyPath.h:17
PropertyPath()
Constructor for serialization.
Definition: PropertyPath.h:40
~PropertyPath()=default
KeyType GetValue(EngineObject *object)
Definition: PropertyPath.h:53
static void SetPropertyValue(rttr::property prop, const rttr::instance &object, PropertyType value)
Ustawia wartość podanej właściwości.
Definition: Serialization.inl:50
Definition: Properties.h:10