Sleeping Wombat Common Library  0.50.0
swCommonLibrary
StringPropertyPath.h
Go to the documentation of this file.
1 #pragma once
2 
9 
10 
12 template< typename KeyType >
14 {
15 private:
16  std::string m_path;
17 
18 protected:
19 public:
20  explicit StringPropertyPath ();
21  explicit StringPropertyPath ( Object* object, const std::string& propertyPath );
22  ~StringPropertyPath () = default;
23 
24 
25  KeyType GetValue ( Object* object );
26  void SetValue ( Object* object, KeyType& value );
27 };
28 
29 
30 //====================================================================================//
31 // Implementation
32 //====================================================================================//
33 
34 
35 // ================================ //
36 //
37 template< typename KeyType >
39  : m_path( "" )
40 {}
41 
42 // ================================ //
43 //
44 template< typename KeyType >
45 inline StringPropertyPath< KeyType >::StringPropertyPath( Object* object, const std::string& propertyPath )
46  : m_path( propertyPath )
47 {}
48 
49 // ================================ //
50 //
51 template< typename KeyType >
52 inline KeyType StringPropertyPath< KeyType >::GetValue ( Object* object )
53 {
54  auto finalPair = Properties::GetProperty( object, m_path );
55  auto& owner = finalPair.first;
56  auto& prop = finalPair.second;
57 
58  return sw::SerializationCore::GetPropertyValue< KeyType >( prop, owner );
59 }
60 
61 template< typename KeyType >
62 inline void StringPropertyPath< KeyType >::SetValue ( Object* object, KeyType& value )
63 {
64  auto finalPair = Properties::GetProperty( object, m_path );
65  auto& owner = finalPair.first;
66  auto& prop = finalPair.second;
67 
68  sw::SerializationCore::SetPropertyValue( prop, owner, value );
69 }
static void SetPropertyValue(rttr::property prop, const rttr::instance &object, PropertyType value)
Ustawia wartość podanej właściwości.
Definition: SerializationCore.inl:79
Base clas for all objects in sleeping wombat libraries.
Definition: Object.h:42
Definition: StringPropertyPath.h:13