OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::Property Class Referenceabstract

The Property class is used as a base class for all Properties that can be displayed and modified in the frontend. More...

#include "Property.h"

Inheritance diagram for ot::Property:
ot::PropertyBase ot::Serializable ot::PropertyBool ot::PropertyColor ot::PropertyDirectory ot::PropertyDouble ot::PropertyFilePath ot::PropertyInt ot::PropertyPainter2D ot::PropertyString ot::PropertyStringList

Public Member Functions

 Property (const Property *_other)
 
 Property (const PropertyBase &_base)
 
 Property (PropertyFlags _flags=PropertyFlags(NoFlags))
 
 Property (const std::string &_name, PropertyFlags _flags=PropertyFlags(NoFlags))
 
virtual ~Property ()
 Destructor. Destroys the parent group if set.
 
virtual std::string getPropertyType (void) const =0
 
virtual PropertycreateCopy (void) const =0
 Creates a copy of this property.
 
PropertycreateCopyWithParents (void) const
 brief Creates a copy of this property and all parent groups excluding other properties and group paths. The created property will have all the parent groups set up to the root group.
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ot::ConstJsonObject &_object) override
 Will set the object contents from the provided JSON object.
 
void setParentGroup (PropertyGroup *_group)
 
PropertyGroupgetParentGroup (void) const
 
PropertyGroupgetRootGroup (void) const
 Returns the root group. If this item has no parent group returns 0.
 
std::string getPropertyPath (char _delimiter='/') const
 Returns the property path. The property path is a string containing all parent groups and the property name (e.g. "RootGroup/ChildGroup/ThisItem").
 
- Public Member Functions inherited from ot::PropertyBase
 PropertyBase (PropertyFlags _flags=PropertyFlags(NoFlags))
 Default constructor.
 
 PropertyBase (const std::string &_name, PropertyFlags _flags=PropertyFlags(NoFlags))
 Assignment constructor.
 
 PropertyBase (const PropertyBase &_other)
 Copy constructor.
 
virtual ~PropertyBase ()
 Destructor.
 
PropertyBaseoperator= (const PropertyBase &_other)
 Assignment operator.
 
void setPropertyName (const std::string &_name)
 
const std::string & getPropertyName (void) const
 
void setPropertyTitle (const std::string &_title)
 Set the property title If no title set the name will be used as title.
 
const std::string & getPropertyTitle (void) const
 Property title If no title set the name will be used as title.
 
void setPropertyTip (const std::string &_tip)
 
std::string & getPropertyTip (void)
 
const std::string & getPropertyTip (void) const
 
void setPropertyFlag (PropertyFlag _flag, bool _active=true)
 
void setPropertyFlags (PropertyFlags _flags)
 
PropertyFlagsgetPropertyFlags (void)
 
const PropertyFlagsgetPropertyFlags (void) const
 
void setSpecialType (const std::string &_type)
 
const std::string & getSpecialType (void) const
 
void addAdditionalPropertyData (const std::string &_key, const std::string &_data)
 
void setAdditionalPropertyData (const std::map< std::string, std::string > &_data)
 
const std::map< std::string, std::string > & getAllAdditionalPropertyData (void) const
 
std::string getAdditionalPropertyData (const std::string &_key) const
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 

Protected Member Functions

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.
 
virtual void setPropertyData (const ot::ConstJsonObject &_object)=0
 Set the property data from the provided JSON object.
 

Additional Inherited Members

- Public Types inherited from ot::PropertyBase
enum  PropertyFlag {
  NoFlags = 0x0000 , IsReadOnly = 0x0001 , IsProtected = 0x0002 , IsHidden = 0x0004 ,
  HasMultipleValues = 0x0008 , HasInputError = 0x0010 , IsDeletable = 0x0020 , AllowCustomValues = 0x1000 ,
  AllowMultiselection = 0x2000
}
 The PropertyFlag enum contains different settings for properties. More...
 
typedef Flags< PropertyFlagPropertyFlags
 The PropertyFlag enum contains different settings for properties.
 
- Static Public Member Functions inherited from ot::PropertyBase
static std::string toString (PropertyFlag _flag)
 Creates a string representation of the provided PropertyFlag.
 
static PropertyFlag stringToFlag (const std::string &_flag)
 Returns the PropertyFlag that is represented by the string.
 
static std::list< std::string > toStringList (PropertyFlags _flags)
 Creates a list containing strings that represent the set PropertyFlags.
 
static PropertyFlags stringListToFlags (const std::list< std::string > &_flags)
 Returns the PropertyFlags that are represented by the string list.
 

Detailed Description

The Property class is used as a base class for all Properties that can be displayed and modified in the frontend.

Constructor & Destructor Documentation

◆ Property() [1/4]

ot::Property::Property ( const Property * _other)

◆ Property() [2/4]

ot::Property::Property ( const PropertyBase & _base)

◆ Property() [3/4]

ot::Property::Property ( PropertyFlags _flags = PropertyFlags(NoFlags))

◆ Property() [4/4]

ot::Property::Property ( const std::string & _name,
PropertyFlags _flags = PropertyFlags(NoFlags) )

◆ ~Property()

ot::Property::~Property ( )
virtual

Destructor. Destroys the parent group if set.

Member Function Documentation

◆ addToJsonObject()

void ot::Property::addToJsonObject ( ot::JsonValue & _object,
ot::JsonAllocator & _allocator ) const
overridevirtual

Add the object contents to the provided JSON object.

Parameters
_objectJson object reference
_allocatorAllocator

Reimplemented from ot::PropertyBase.

◆ createCopy()

virtual Property * ot::Property::createCopy ( void ) const
pure virtual

◆ createCopyWithParents()

ot::Property * ot::Property::createCopyWithParents ( void ) const

brief Creates a copy of this property and all parent groups excluding other properties and group paths. The created property will have all the parent groups set up to the root group.

Note
Other child groups and properties are ignored.

Assume you have the following structure:

  Root
  +--> ChildGroup1
       +--> Property1
  +--> ChildGroup2
       +--> <This Property>
  +--> ChildGroup3
       +--> Property3

Then the new structure will be:
  Root
  +--> ChildGroup2
       +--> <This Property>

◆ getParentGroup()

PropertyGroup * ot::Property::getParentGroup ( void ) const
inline

◆ getPropertyData()

virtual void ot::Property::getPropertyData ( ot::JsonValue & _object,
ot::JsonAllocator & _allocator ) const
protectedpure virtual

Add the property data to the provided JSON object The property type is already added.

Parameters
_objectJson object reference
_allocatorAllocator

Implemented in ot::PropertyBool, ot::PropertyColor, ot::PropertyDirectory, ot::PropertyDouble, ot::PropertyFilePath, ot::PropertyInt, ot::PropertyPainter2D, ot::PropertyString, and ot::PropertyStringList.

◆ getPropertyPath()

std::string ot::Property::getPropertyPath ( char _delimiter = '/') const

Returns the property path. The property path is a string containing all parent groups and the property name (e.g. "RootGroup/ChildGroup/ThisItem").

◆ getPropertyType()

virtual std::string ot::Property::getPropertyType ( void ) const
pure virtual

◆ getRootGroup()

ot::PropertyGroup * ot::Property::getRootGroup ( void ) const

Returns the root group. If this item has no parent group returns 0.

◆ setFromJsonObject()

void ot::Property::setFromJsonObject ( const ot::ConstJsonObject & _object)
overridevirtual

Will set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types)

Reimplemented from ot::PropertyBase.

◆ setParentGroup()

void ot::Property::setParentGroup ( PropertyGroup * _group)
inline

◆ setPropertyData()

virtual void ot::Property::setPropertyData ( const ot::ConstJsonObject & _object)
protectedpure virtual

Set the property data from the provided JSON object.

Parameters
_objectThe JSON object containing the information
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types)

Implemented in ot::PropertyBool, ot::PropertyColor, ot::PropertyDirectory, ot::PropertyDouble, ot::PropertyFilePath, ot::PropertyInt, ot::PropertyPainter2D, ot::PropertyString, and ot::PropertyStringList.


The documentation for this class was generated from the following files: