OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Property.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10
11#pragma warning(disable:4251)
12
13#define OT_JSON_MEMBER_Property_Type "Type"
14
15namespace ot {
16
17 class PropertyGroup;
18
23 public:
24 Property(const Property* _other);
25 Property(const PropertyBase& _base);
26 Property(PropertyFlags _flags = PropertyFlags(NoFlags));
27 Property(const std::string& _name, PropertyFlags _flags = PropertyFlags(NoFlags));
28
31 virtual ~Property();
32
33 virtual std::string getPropertyType(void) const = 0;
34
36 virtual Property* createCopy(void) const = 0;
37
58 Property* createCopyWithParents(void) const;
59
63 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
64
68 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
69
70 void setParentGroup(PropertyGroup* _group) { m_parentGroup = _group; };
71 PropertyGroup* getParentGroup(void) const { return m_parentGroup; };
72
75 PropertyGroup* getRootGroup(void) const;
76
79 std::string getPropertyPath(char _delimiter = '/') const;
80
81 protected:
86 virtual void getPropertyData(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const = 0;
87
91 virtual void setPropertyData(const ot::ConstJsonObject& _object) = 0;
92
93 private:
94 PropertyGroup* m_parentGroup;
95 };
96
97}
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The PropertyBase class is used to hold general Property information.
Definition PropertyBase.h:25
Definition PropertyGroup.h:23
The Property class is used as a base class for all Properties that can be displayed and modified in t...
Definition Property.h:21
void setParentGroup(PropertyGroup *_group)
Definition Property.h:70
virtual void getPropertyData(ot::JsonValue &_object, ot::JsonAllocator &_allocator) const =0
Add the property data to the provided JSON object The property type is already added.
PropertyGroup * getParentGroup(void) const
Definition Property.h:71
virtual Property * createCopy(void) const =0
Creates a copy of this property.
virtual void setPropertyData(const ot::ConstJsonObject &_object)=0
Set the property data from the provided JSON object.
virtual std::string getPropertyType(void) const =0
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30