Sleeping Wombat Common Library  0.50.0
swCommonLibrary
PropertyPath.h
Go to the documentation of this file.
1 #pragma once
2 
8 #include "swCommonLib/Common/RTTR.h"
9 #include "swCommonLib/Common/Properties/Properties.h"
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 ( Object* object, const std::string& propertyPath );
26  ~PropertyPath () = default;
27 
28  KeyType GetValue ( Object* object );
29  void SetValue ( Object* 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 ( Object* object, const std::string& propertyPath )
47  : m_path( Properties::GetPropertyPath( object, propertyPath ) )
48 {}
49 
50 // ================================ //
51 //
52 template< typename KeyType >
53 inline KeyType PropertyPath< KeyType >::GetValue ( Object* object )
54 {
55  auto finalPair = Properties::GetProperty( object, m_path );
56  auto& owner = finalPair.first;
57  auto& prop = finalPair.second;
58 
59  return sw::SerializationCore::GetPropertyValue< KeyType >( prop, owner );
60 }
61 
62 // ================================ //
63 //
64 template< typename KeyType >
65 inline void PropertyPath< KeyType >::SetValue ( Object* object, KeyType& value )
66 {
67  auto finalPair = Properties::GetProperty( object, m_path );
68  auto& owner = finalPair.first;
69  auto& prop = finalPair.second;
70 
71  sw::SerializationCore::SetPropertyValue( prop, owner, value );
72 }
static void SetPropertyValue(rttr::property prop, const rttr::instance &object, PropertyType value)
Ustawia wartość podanej właściwości.
Definition: SerializationCore.inl:79
Definition: PropertyPath.h:17
PropertyPath()
Constructor for serialization.
Definition: PropertyPath.h:40
Base clas for all objects in sleeping wombat libraries.
Definition: Object.h:42
Definition: Properties.h:10