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

Example class for dynamic hierarchies. More...

#include <cppexpose/include/cppexpose/scripting/example/TreeNode.h>

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

Public Member Functions

 TreeNode (const std::string &name)
 Constructor. More...
 
virtual ~TreeNode ()
 Destructor. More...
 
int getId () const
 Get node ID. More...
 
void setId (const int &id)
 Set node ID. More...
 
void expand ()
 Expand node. More...
 
void collapse ()
 Collapse node. More...
 
void print (const std::string &indent="")
 Print tree to console. More...
 
- Public Member Functions inherited from cppexpose::Object
const std::vector< Method > & functions () const
 Get list of functions exported by this object. More...
 
template<typename RET , typename... Arguments>
void addFunction (const std::string &name, RET(*fn)(Arguments...))
 Add (export) static function. More...
 
template<class T , typename RET , typename... Arguments>
void addFunction (const std::string &name, T *obj, RET(T::*fn)(Arguments...))
 Add (export) method on object. More...
 
template<class T , typename RET , typename... Arguments>
void addFunction (const std::string &name, T *obj, RET(T::*fn)(Arguments...) const)
 Add (export) const method on object. More...
 
virtual bool isObject () const override
 Check if property is an object. More...
 
virtual std::unique_ptr< AbstractTyped > clone () const override
 
virtual const std::type_info & type () const override
 
virtual std::string typeName () const override
 
virtual bool isReadOnly () const override
 
virtual bool isComposite () const override
 
virtual size_t numSubValues () const override
 
virtual AbstractTyped * subValue (size_t i) override
 
virtual bool isEnum () const override
 
virtual bool isArray () const override
 
virtual bool isVariant () const override
 
virtual bool isString () const override
 
virtual bool isBool () const override
 
virtual bool isNumber () const override
 
virtual bool isIntegral () const override
 
virtual bool isSignedIntegral () const override
 
virtual bool isUnsignedIntegral () const override
 
virtual bool isFloatingPoint () const override
 
virtual Variant toVariant () const override
 
virtual bool fromVariant (const Variant &value) override
 
virtual std::string toString () const override
 
virtual bool fromString (const std::string &value) override
 
virtual bool toBool () const override
 
virtual bool fromBool (bool value) override
 
virtual long long toLongLong () const override
 
virtual bool fromLongLong (long long value) override
 
virtual unsigned long long toULongLong () const override
 
virtual bool fromULongLong (unsigned long long value) override
 
virtual double toDouble () const override
 
virtual bool fromDouble (double value) override
 
std::string relativePathTo (const Object *const other) const
 Get the relative path to another object. More...
 
 Object ()
 Constructor. More...
 
 Object (const std::string &name)
 Constructor. More...
 
 Object (const Object &)=delete
 Copy constructor (deleted) More...
 
virtual ~Object ()
 Destructor. More...
 
Objectoperator= (const Object &)=delete
 Copy assignment operator (deleted) More...
 
const std::string & className () const
 Get class name. More...
 
void setClassName (const std::string &className)
 Set class name. More...
 
void clear ()
 Clear properties. More...
 
const std::unordered_map< std::string, AbstractProperty * > & properties () const
 Get properties. More...
 
bool propertyExists (const std::string &name) const
 Check if property exists. More...
 
AbstractPropertyproperty (size_t index)
 Get property by index. More...
 
const AbstractPropertyproperty (size_t index) const
 
AbstractPropertyproperty (const std::string &path)
 Get property by name. More...
 
const AbstractPropertyproperty (const std::string &path) const
 
bool addProperty (AbstractProperty *property)
 Add property to object. More...
 
bool addProperty (std::unique_ptr< AbstractProperty > &&property)
 Add property to object. More...
 
template<typename Type , typename... Arguments>
bool addProperty (const std::string &name, Arguments &&...arguments)
 Create and add property to object. More...
 
bool removeProperty (AbstractProperty *property)
 Remove property from object. More...
 
template<typename T >
DynamicProperty< T > * createDynamicProperty (const std::string &name, const T &value=T())
 Create dynamic property. More...
 
- Public Member Functions inherited from cppexpose::AbstractProperty
 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...
 
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

cppexpose::Property< int > id
 
- Public Attributes inherited from cppexpose::Object
Signal< size_t, AbstractProperty * > beforeAdd
 Called before a property is added to the object. More...
 
Signal< size_t, AbstractProperty * > afterAdd
 Called after a property is added to the object. More...
 
Signal< size_t, AbstractProperty * > beforeRemove
 Called before a property is removed from the object. More...
 
Signal< size_t, AbstractProperty * > afterRemove
 Called after a property is removed from the object. More...
 
- Public Attributes inherited from cppexpose::AbstractProperty
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 Attributes

int m_id
 ID of the node. More...
 
std::unique_ptr< TreeNodem_left
 Left child node (can be null) More...
 
std::unique_ptr< TreeNodem_right
 Right child node (can be null) More...
 
- Protected Attributes inherited from cppexpose::Object
std::string m_className
 Class name for this object (default: "Object") More...
 
std::vector< AbstractProperty * > m_properties
 List of properties in the object. More...
 
std::unordered_map< std::string, AbstractProperty * > m_propertiesMap
 Map of names and properties. More...
 
std::vector< std::unique_ptr< AbstractProperty > > m_managedProperties
 Property that are owned by the object. More...
 
std::vector< Methodm_functions
 List of exported functions. More...
 
- Protected Attributes inherited from cppexpose::AbstractProperty
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...
 

Additional Inherited Members

- Protected Member Functions inherited from cppexpose::Object
const AbstractPropertyfindProperty (const std::vector< std::string > &path) const
 
- Protected Member Functions inherited from cppexpose::AbstractProperty
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...
 

Detailed Description

Example class for dynamic hierarchies.

Remarks
This class is an example for reflection objects that create dynamic sub-objects. It can be used to test the cppexpose scripting framework's ability to cope with such dynamic object hierarchies.

Constructor & Destructor Documentation

cppexpose::TreeNode::TreeNode ( const std::string &  name)

Constructor.

Parameters
[in]nameObject name
virtual cppexpose::TreeNode::~TreeNode ( )
virtual

Destructor.

Member Function Documentation

int cppexpose::TreeNode::getId ( ) const

Get node ID.

Returns
ID of the node
void cppexpose::TreeNode::setId ( const int &  id)

Set node ID.

Parameters
[in]idID of the node
void cppexpose::TreeNode::expand ( )

Expand node.

Remarks
Expands the node by creating two sub-nodes 'left' and 'right'. If the node is already expanded, this function just returns.
void cppexpose::TreeNode::collapse ( )

Collapse node.

Remarks
If expanded, the sub-nodes 'left' and 'right' will be deleted and removed from the node.
void cppexpose::TreeNode::print ( const std::string &  indent = "")

Print tree to console.

Parameters
[in]indentIndentation string
Remarks
This prints the id and contents of the tree node and all sub-nodes to the console.

Member Data Documentation

cppexpose::Property<int> cppexpose::TreeNode::id
int cppexpose::TreeNode::m_id
protected

ID of the node.

std::unique_ptr<TreeNode> cppexpose::TreeNode::m_left
protected

Left child node (can be null)

std::unique_ptr<TreeNode> cppexpose::TreeNode::m_right
protected

Right child node (can be null)


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