cppexpose  1.0.0.b785e04f23b8
C++ library for type introspection, reflection, and scripting interface
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
cppexpose::AbstractProperty Class Referenceabstract

Base class for properties. More...

#include <cppexpose/include/cppexpose/reflection/AbstractProperty.h>

Inheritance diagram for cppexpose::AbstractProperty:
Inheritance graph
[legend]
Collaboration diagram for cppexpose::AbstractProperty:
Collaboration graph
[legend]

Public Member Functions

 AbstractProperty ()
 Constructor. More...
 
 AbstractProperty (const Variant &options)
 Constructor. More...
 
virtual ~AbstractProperty ()
 Destructor. More...
 
const std::string & name () const
 Get name. More...
 
void setName (const std::string &name)
 Set name. More...
 
std::string qualifiedName (const Object *relativeRoot=nullptr) const
 Get qualified name. More...
 
Objectparent () const
 Get parent object. More...
 
bool hasParent () const
 Finds out whether the Object has a parent. More...
 
virtual bool isObject () const =0
 Check if property is an object. More...
 
const VariantMap & options () const
 Get options of property. More...
 
void setOptions (const VariantMap &map)
 Set options of property. More...
 
bool hasOption (const std::string &key) const
 Check if option is set. More...
 
const Variant & option (const std::string &key) const
 Get option of property. More...
 
template<typename Type >
Type option (const std::string &key, const Type &defaultValue=Type()) const
 Get option of property convert to a specific type. More...
 
void setOption (const std::string &key, const Variant &value)
 Set option of property. More...
 
bool removeOption (const std::string &key)
 Remove option of property. More...
 

Public Attributes

Signal< AbstractProperty * > beforeDestroy
 Called before a property is destroyed. More...
 
Signal< const std::string & > optionChanged
 Called when an option of the property has been changed. More...
 

Protected Member Functions

void initProperty (const std::string &name, Object *parent)
 Initialize property. More...
 
void setParent (Object *parent)
 Set parent object. More...
 
virtual void onOptionChanged (const std::string &option)
 Called when an option of the property has changed. More...
 

Protected Attributes

std::string m_name
 Name of the property. More...
 
Objectm_parent
 Parent object. More...
 
VariantMap m_options
 Additional options for the property (e.g., minimum or maximum values) More...
 

Friends

class Object
 

Detailed Description

Base class for properties.

Constructor & Destructor Documentation

cppexpose::AbstractProperty::AbstractProperty ( )

Constructor.

cppexpose::AbstractProperty::AbstractProperty ( const Variant &  options)

Constructor.

Parameters
[in]optionsOptions with which the property is initialized
virtual cppexpose::AbstractProperty::~AbstractProperty ( )
virtual

Destructor.

Member Function Documentation

const std::string& cppexpose::AbstractProperty::name ( ) const
void cppexpose::AbstractProperty::setName ( const std::string &  name)

Set name.

Parameters
[in]nameName
Remarks
This function should never be called after the property has been added to a parent object. The name change will not be updated in the parent container.
std::string cppexpose::AbstractProperty::qualifiedName ( const Object relativeRoot = nullptr) const

Get qualified name.

Parameters
[in]relativeRoot(optional) Root object for relative name resolution
Returns
Qualified name
Remarks
Returns ablosute qualified name if relativeRoot is not found in ancestral hierarchy
Object* cppexpose::AbstractProperty::parent ( ) const

Get parent object.

Returns
Parent (can be null)
bool cppexpose::AbstractProperty::hasParent ( ) const

Finds out whether the Object has a parent.

Returns
false if the parent is null, otherwise true
virtual bool cppexpose::AbstractProperty::isObject ( ) const
pure virtual

Check if property is an object.

Returns
'true' if property is an object, else 'false'

Implemented in cppexpose::Object.

const VariantMap& cppexpose::AbstractProperty::options ( ) const

Get options of property.

Options provide additional meta information about a property. Use options to add, e.g., minimum and maximum values, affixes, or flags. These can be used to configure editor widgets. Look at the class documentation of the specific property type to get a list of supported options.

Returns
List of options
void cppexpose::AbstractProperty::setOptions ( const VariantMap &  map)

Set options of property.

Parameters
[in]mapList of options
bool cppexpose::AbstractProperty::hasOption ( const std::string &  key) const

Check if option is set.

Parameters
[in]keyOption name
Returns
'true' if the option is set, else 'false'
const Variant& cppexpose::AbstractProperty::option ( const std::string &  key) const

Get option of property.

Parameters
[in]keyOption name
Returns
Option value

Referenced by option().

template<typename Type >
Type cppexpose::AbstractProperty::option ( const std::string &  key,
const Type &  defaultValue = Type() 
) const

Get option of property convert to a specific type.

Parameters
[in]keyOption name
[in]defaultValueDefault value
Returns
Option value converted to Type, defaultValue if the option doesn't exist or couldn't be converted

References option().

void cppexpose::AbstractProperty::setOption ( const std::string &  key,
const Variant &  value 
)

Set option of property.

Parameters
[in]keyOption name
[in]valueOption value
bool cppexpose::AbstractProperty::removeOption ( const std::string &  key)

Remove option of property.

Parameters
[in]keyOption name
Returns
'true' if the option has been removed, else 'false'
void cppexpose::AbstractProperty::initProperty ( const std::string &  name,
Object parent 
)
protected

Initialize property.

Parameters
[in]nameName (can be empty)
[in]parentParent object (can be null)
[in]ownershipProperty ownership
Remarks
The internal parent is updated to the parent parameter. Do not set m_parent before calling this function, otherwise the property might be rejected when added to the parent.
void cppexpose::AbstractProperty::setParent ( Object parent)
protected

Set parent object.

Parameters
[in]parentParent object (can be null)
Remarks
This function should only be called by Object when adding or removing properties.
virtual void cppexpose::AbstractProperty::onOptionChanged ( const std::string &  option)
protectedvirtual

Called when an option of the property has changed.

Parameters
[in]optionName of the option
Remarks
This function is empty be default and can be implemented in derived classes.

Friends And Related Function Documentation

friend class Object
friend

Member Data Documentation

Signal<AbstractProperty *> cppexpose::AbstractProperty::beforeDestroy

Called before a property is destroyed.

Signal<const std::string &> cppexpose::AbstractProperty::optionChanged

Called when an option of the property has been changed.

std::string cppexpose::AbstractProperty::m_name
protected

Name of the property.

Object* cppexpose::AbstractProperty::m_parent
protected

Parent object.

VariantMap cppexpose::AbstractProperty::m_options
protected

Additional options for the property (e.g., minimum or maximum values)


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