-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProperty.h
50 lines (43 loc) · 957 Bytes
/
Property.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//============
// Property.h
//============
#pragma once
//==========
// Property
//==========
template <class _owner_t, class _item_t>
class Property
{
public:
// Con-/Destructors
Property(_owner_t* Owner, _item_t Value=_item_t()): m_Owner(Owner), m_Value(Value) {}
Property(Property const&)=delete;
Property(Property&&)=delete;
// Access
//inline operator bool()const { return tValue; }
inline operator _item_t const&()const { return m_Value; }
inline _item_t const& Get()const { return m_Value; }
// Modification
inline Property& operator=(_item_t Value)
{
Set(Value);
return *this;
}
inline Property& operator=(Property const& Property)
{
return operator=(Property.m_Value);
}
Event<_owner_t, _item_t> Changed;
VOID Set(_item_t const& Value, BOOL Notify=true)
{
if(m_Value==Value)
return;
m_Value=Value;
if(Notify)
Changed(m_Owner, Value);
}
private:
// Common
_owner_t* m_Owner;
_item_t m_Value;
};