File: Property.h

package info (click to toggle)
mygui 3.2.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,224 kB
  • sloc: cpp: 118,031; ansic: 30,202; xml: 15,544; cs: 12,602; tcl: 776; python: 417; makefile: 34
file content (72 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (4)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*!
	@file
	@author		Albert Semenov
	@date		08/2010
*/

#ifndef _faf0ef48_7615_4de7_812c_48520c83de61_
#define _faf0ef48_7615_4de7_812c_48520c83de61_

#include "sigslot.h"
#include "DataTypeProperty.h"
#include "SharedPtr.h"

namespace tools
{
	class Data;
	typedef shared_ptr<Data> DataPtr;

	class MYGUI_EXPORT_DLL Property
	{
	public:
		typedef shared_ptr<Property> PropertyPtr;
		typedef weak_ptr<Property> PropertyWeak;

		Property(DataTypePropertyPtr _type, DataPtr _owner);
		~Property();

		static PropertyPtr CreateInstance(DataTypePropertyPtr _type, DataPtr _owner);

		void initialise();

		const std::string& getValue() const;
		void setValue(const std::string& _value);

		template <typename Type>
		Type getValue() const
		{
			return MyGUI::utility::parseValue<Type>(getValue());
		}

		template <typename Type>
		void setValue(const Type& _value)
		{
			setValue(MyGUI::utility::toString(_value));
		}

		void setValue(const bool& _value)
		{
			setValue(std::string(_value ? "True" : "False"));
		}

		DataTypePropertyPtr getType();

		DataPtr getOwner();

		sigslot::signal1<PropertyPtr> eventChangeProperty;

	private:
		Property();

	private:
		std::string mValue;
		DataTypePropertyPtr mType;
		DataPtr mOwner;
		PropertyWeak mWeakThis;
	};

	typedef Property::PropertyPtr PropertyPtr;

}

#endif