Sleeping Wombat Common Library  0.50.0
swCommonLibrary
DirectPropertyh.h
1 #pragma once
2 
8 #include "swCommonLib/Common/RTTR.h"
10 
11 #include "swCommonLib/Common/Properties/Properties.h"
13 
14 
16 template< typename KeyType >
18 {
19 private:
20  rttr::property m_property;
21  rttr::variant m_object;
22 
23 protected:
24 public:
26  explicit DirectProperty ();
27  explicit DirectProperty ( Object* object, const std::string& propertyPath );
28  ~DirectProperty () = default;
29 
30 
31  KeyType GetValue ( Object* object );
32  void SetValue ( Object* object, KeyType& value );
33 };
34 
35 //====================================================================================//
36 // Implementation
37 //====================================================================================//
38 
39 // ================================ //
40 //
41 template< typename KeyType >
43  : m_property( Properties::EmptyProperty() )
44  , m_object( rttr::variant() )
45 {}
46 
47 
48 // ================================ //
49 //
50 template< typename KeyType >
51 inline DirectProperty< KeyType >::DirectProperty ( Object* object, const std::string& propertyPath )
52  : m_property( Properties::EmptyProperty() )
53  , m_object( nullptr )
54 {
55  auto accessor = Properties::GetProperty( object, propertyPath );
56  m_property = accessor.second;
57  m_object = accessor.first;
58 }
59 
60 // ================================ //
61 //
62 template< typename KeyType >
64 {
65  return sw::SerializationCore::GetPropertyValue< KeyType >( m_property, m_object );
66 }
67 
68 // ================================ //
69 //
70 template< typename KeyType >
71 inline void DirectProperty< KeyType >::SetValue ( Object* object, KeyType& value )
72 {
73  sw::SerializationCore::SetPropertyValue( m_property, m_object, value );
74 }
75 
Definition: TypesDefinitions.h:42
static void SetPropertyValue(rttr::property prop, const rttr::instance &object, PropertyType value)
Ustawia wartość podanej właściwości.
Definition: SerializationCore.inl:79
rttr::variant m_object
Definition: DirectPropertyh.h:21
Definition: DirectPropertyh.h:17
Base clas for all objects in sleeping wombat libraries.
Definition: Object.h:42
Definition: Properties.h:10
DirectProperty()
Constructor for serialization.
Definition: DirectPropertyh.h:42