Sleeping Wombat Common Library  0.50.0
swCommonLibrary
Properties.h
1 #pragma once
2 
4 #include "swCommonLib/Common/RTTR.h"
5 
6 #include <vector>
7 #include <string>
8 
9 
11 {
12 private:
13 public:
14 
15  static std::vector< rttr::property > GetPropertyPath ( Object* object, const std::string& propertyPath, char separator = '/' );
16  static std::vector< rttr::property > GetPropertyPath ( rttr::variant object, const std::string& propertyPath, Size offset = 0, char separator = '/' );
17 
18  static std::pair< rttr::variant, rttr::property > GetProperty ( Object* object, const std::string& propertyPath, char separator = '/' );
19  static std::pair< rttr::variant, rttr::property > GetProperty ( rttr::variant object, const std::string& propertyPath, Size offset = 0, char separator = '/' );
20  static std::pair< rttr::variant, rttr::property > GetProperty ( Object* object, const std::vector< rttr::property >& propertyPath );
21 
22  template< typename Type >
23  static Type GetValue ( Object* object, const std::vector< rttr::property >& propertyPath );
24 
25  static rttr::property EmptyProperty ();
26  static TypeID GetRealType ( const rttr::variant& object );
27  static TypeID GetRealType ( Object* object );
28 };
29 
30 //====================================================================================//
31 // Implementation
32 //====================================================================================//
33 
34 
35 template< typename Type >
36 inline Type Properties::GetValue ( Object* object, const std::vector< rttr::property >& propertyPath )
37 {
38  rttr::variant propertyVal = object;
39 
40  for( auto& property : propertyPath )
41  {
42  propertyVal = property.get_value( propertyVal );
43  }
44 
45  return propertyVal.get_value< Type >();
46 }
static TypeID GetRealType(const rttr::variant &object)
Gets real type of object. If class inherited EngineObject, we can check it's real type...
Definition: Properties.cpp:127
Base clas for all objects in sleeping wombat libraries.
Definition: Object.h:42
Definition: Properties.h:10