Sleeping Wombat GUI  0.100
swGUI
Property.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <cassert>
5 
6 class IEnableProperty;
7 
8 
9 
10 class IProperty
11 {
12 protected:
13 
16 
17 public:
18 
19  IProperty( const rttr::property metaInfo, IEnableProperty* object )
20  : m_metaInfo( metaInfo )
21  , m_ownerObj( object )
22  {}
23 
26  : m_ownerObj( object )
27  {}
28 
29  std::string GetPropertyName() { return m_metaInfo.get_name(); }
30  rttr::type GetPropertyType() { return m_metaInfo.get_type(); }
31 
32  bool IsValid() { return m_metaInfo.is_valid() && m_ownerObj; }
33 
34 
35 protected:
36 
37  template< typename ClassType, typename ParamType >
38  ParamType ClassType::* GetMemberPointer()
39  {
40  return static_cast< const rttr::detail::property_wrapper_member_base< ClassType, ParamType >* >( m_metaInfo.m_wrapper )->GetPtr();
41  }
42 };
43 
44 
45 
46 template< typename PropertyType >
47 class Property : public IProperty
48 {
49 private:
50 public:
51 
52  Property( const rttr::property metaInfo, IEnableProperty* object )
53  : IProperty( metaInfo, object )
54  {
55  //assert( IsValid() );
56  }
57 
60  : IProperty( object )
61  {}
62 
63  inline PropertyType& operator()( void )
64  {
65  assert( IsValid() );
66 
67  auto memberPtr = GetMemberPointer< IEnableProperty, PropertyType >();
68  return m_ownerObj->*memberPtr;
69  }
70 
71  inline operator PropertyType&()
72  {
73  assert( IsValid() );
74 
75  auto memberPtr = GetMemberPointer< IEnableProperty, PropertyType >();
76  return m_ownerObj->*memberPtr;
77  }
78 };
std::string GetPropertyName()
Definition: Property.h:29
Definition: IEnableProperty.h:7
IProperty(IEnableProperty *object)
Tworzy niepoprawny obiekt IProperty.
Definition: Property.h:25
&RenderTargetObject::m_colorBuffer property("DepthBuffer",&RenderTargetObject::m_depthBuffer).property("StencilBuffer"
const rttr::property m_metaInfo
Definition: Property.h:14
rttr::type GetPropertyType()
Definition: Property.h:30
Property(const rttr::property metaInfo, IEnableProperty *object)
Definition: Property.h:52
bool IsValid()
Definition: Property.h:32
IEnableProperty * m_ownerObj
Definition: Property.h:15
Definition: Property.h:47
PropertyType & operator()(void)
Definition: Property.h:63
IProperty(const rttr::property metaInfo, IEnableProperty *object)
Definition: Property.h:19
Definition: Property.h:10
ParamType ClassType::* GetMemberPointer()
Definition: Property.h:38
Property(IEnableProperty *object)
Tworzy niepoprawny obiekt Property.
Definition: Property.h:59