All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kanzi::DataObject Class Reference

DataObject is the base class for data. More...

#include <kanzi/data/data_object.hpp>

Inheritance diagram for kanzi::DataObject:
kanzi::TypedDataObject< DataType, DataTypeEnum >

Public Types

enum  Type {
  Object, Integer, Real, Bool,
  String, Enum, List
}
 Type enumerations for different data object types. More...
 
typedef function< void()> ModifiedFunction
 Callback function type for change subscriptions. More...
 
typedef shared_ptr< void > ModifiedSubscriptionToken
 Token type that can be used to identify the change subscription. More...
 
typedef vector
< DataObjectSharedPtr
ChildContainer
 Iterators for children. More...
 
typedef
ChildContainer::const_iterator 
ChildConstIterator
 
typedef
ChildContainer::const_reverse_iterator 
ChildConstReverseIterator
 

Public Member Functions

 DataObject (string_view name)
 Standard constructor. More...
 
string getName () const
 Allows to retrieve the name of the object. More...
 
void setName (string_view value)
 Sets the name of the object. More...
 
virtual Type getType () const
 Allows to retrieve the type of the object. More...
 
size_t getChildCount () const
 Retrieves the count of child objects in this data object. More...
 
DataObjectSharedPtr getChild (size_t index) const
 Retrieves a child object in given index. More...
 
size_t getChildIndex (const DataObject &child) const
 Retrieves the index of a child data object. More...
 
bool hasChild (const DataObject &child) const
 Checks whether or not the child exists. More...
 
DataObjectSharedPtr findChild (string_view name)
 Tries to find a child with given name. More...
 
void addChild (const DataObjectSharedPtr &child)
 Adds data object as child of this object. More...
 
void insertChild (size_t index, const DataObjectSharedPtr &child)
 Inserts data object as child of this object, allows to specify index of the object. More...
 
void removeChild (const DataObject &child)
 Removes a child object from list of childs. More...
 
void removeChild (size_t index)
 Removes a child object in given index. More...
 
void removeAllChildren ()
 Removes all children. More...
 
ChildConstIterator beginChildren () const
 Returns iterator to start of the child container. More...
 
ChildConstIterator endChildren () const
 Returns iterator in the end of the child container. More...
 
template<typename Type >
shared_ptr< TypelookupDataObject (string_view relativePath)
 
DataObjectSharedPtr lookupDataObject (string_view relativePath)
 Performs object look-up by path. More...
 
ModifiedSubscriptionToken addModifiedNotificationHandler (ModifiedFunction callback)
 Allows to subscribe to modifications in this data object. More...
 
void removeModifiedNotificationHandler (ModifiedSubscriptionToken token)
 Allows to unsubscribe from modifications in this data object. More...
 
void notifyModified ()
 Triggers modification procedure in this data object, which invokes the subscriptions. More...
 

Detailed Description

DataObject is the base class for data.

All data within the data source is described as a tree of data objects. The base class provides support for the hierarchy as the derived classes provide support for different value types.

Member Typedef Documentation

typedef function<void()> kanzi::DataObject::ModifiedFunction

Callback function type for change subscriptions.

Token type that can be used to identify the change subscription.

Iterators for children.

typedef ChildContainer::const_iterator kanzi::DataObject::ChildConstIterator
typedef ChildContainer::const_reverse_iterator kanzi::DataObject::ChildConstReverseIterator

Member Enumeration Documentation

Type enumerations for different data object types.

Enumerator
Object 
Integer 
Real 
Bool 
String 
Enum 
List 

Constructor & Destructor Documentation

kanzi::DataObject::DataObject ( string_view  name)
explicit

Standard constructor.

Parameters
nameName of the data object.

Member Function Documentation

string kanzi::DataObject::getName ( ) const

Allows to retrieve the name of the object.

Returns
Returns the name of the object.
void kanzi::DataObject::setName ( string_view  value)

Sets the name of the object.

Parameters
valueNew name that is assigned to object.
virtual Type kanzi::DataObject::getType ( ) const
inlinevirtual

Allows to retrieve the type of the object.

Returns
Type enumeration of the object.

Reimplemented in kanzi::TypedDataObject< DataType, DataTypeEnum >.

size_t kanzi::DataObject::getChildCount ( ) const

Retrieves the count of child objects in this data object.

Returns
Child object count.
DataObjectSharedPtr kanzi::DataObject::getChild ( size_t  index) const

Retrieves a child object in given index.

Returns
Child data object in given index.
size_t kanzi::DataObject::getChildIndex ( const DataObject child) const

Retrieves the index of a child data object.

Returns
Index of the item in question, throws exception if there is no such child.
bool kanzi::DataObject::hasChild ( const DataObject child) const

Checks whether or not the child exists.

Returns
true if there is such child, otherwise false.
DataObjectSharedPtr kanzi::DataObject::findChild ( string_view  name)

Tries to find a child with given name.

Returns
Child object that was found, or empty pointer if there is no such child.
void kanzi::DataObject::addChild ( const DataObjectSharedPtr child)

Adds data object as child of this object.

Parameters
childChild object to add.
void kanzi::DataObject::insertChild ( size_t  index,
const DataObjectSharedPtr child 
)

Inserts data object as child of this object, allows to specify index of the object.

Parameters
indexIndex where to add given object.
childChild object to add.
void kanzi::DataObject::removeChild ( const DataObject child)

Removes a child object from list of childs.

Parameters
childChild object to remove.
void kanzi::DataObject::removeChild ( size_t  index)

Removes a child object in given index.

Parameters
Indexof the child object to remove.
void kanzi::DataObject::removeAllChildren ( )

Removes all children.

ChildConstIterator kanzi::DataObject::beginChildren ( ) const

Returns iterator to start of the child container.

Returns
Iterator at the beginning of the container.
ChildConstIterator kanzi::DataObject::endChildren ( ) const

Returns iterator in the end of the child container.

Returns
Iterator in the end of the container.
template<typename Type >
shared_ptr<Type> kanzi::DataObject::lookupDataObject ( string_view  relativePath)
inline
DataObjectSharedPtr kanzi::DataObject::lookupDataObject ( string_view  relativePath)

Performs object look-up by path.

Parameters
relativePathPath of the object where to look at, separated by '.'.
Returns
Data object that was found, or empty pointer if there was no such object.
ModifiedSubscriptionToken kanzi::DataObject::addModifiedNotificationHandler ( ModifiedFunction  callback)

Allows to subscribe to modifications in this data object.

Parameters
callbackCallback that is invoked when a change occurs in this data object.
Returns
Token that can be used to identify and remove given subscripion.
void kanzi::DataObject::removeModifiedNotificationHandler ( ModifiedSubscriptionToken  token)

Allows to unsubscribe from modifications in this data object.

Parameters
tokenToken to identify the subscription that should be removed.
void kanzi::DataObject::notifyModified ( )

Triggers modification procedure in this data object, which invokes the subscriptions.

Should be called by derived classes whenever the value of the object is changed.


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