DataObject is the base class for data. More...
#include <kanzi/data/data_object.hpp>
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< Type > | lookupDataObject (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... | |
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.
typedef function<void()> kanzi::DataObject::ModifiedFunction |
Callback function type for change subscriptions.
typedef shared_ptr<void> kanzi::DataObject::ModifiedSubscriptionToken |
Token type that can be used to identify the change subscription.
typedef vector<DataObjectSharedPtr> kanzi::DataObject::ChildContainer |
Iterators for children.
typedef ChildContainer::const_iterator kanzi::DataObject::ChildConstIterator |
typedef ChildContainer::const_reverse_iterator kanzi::DataObject::ChildConstReverseIterator |
|
explicit |
Standard constructor.
name | Name of the data object. |
string kanzi::DataObject::getName | ( | ) | const |
Allows to retrieve the name of the object.
void kanzi::DataObject::setName | ( | string_view | value | ) |
Sets the name of the object.
value | New name that is assigned to object. |
|
inlinevirtual |
Allows to retrieve the type 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.
DataObjectSharedPtr kanzi::DataObject::getChild | ( | size_t | index | ) | const |
Retrieves a child object in given index.
size_t kanzi::DataObject::getChildIndex | ( | const DataObject & | child | ) | const |
Retrieves the index of a child data object.
bool kanzi::DataObject::hasChild | ( | const DataObject & | child | ) | const |
Checks whether or not the child exists.
DataObjectSharedPtr kanzi::DataObject::findChild | ( | string_view | name | ) |
Tries to find a child with given name.
void kanzi::DataObject::addChild | ( | const DataObjectSharedPtr & | child | ) |
Adds data object as child of this object.
child | Child 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.
index | Index where to add given object. |
child | Child object to add. |
void kanzi::DataObject::removeChild | ( | const DataObject & | child | ) |
Removes a child object from list of childs.
child | Child object to remove. |
void kanzi::DataObject::removeChild | ( | size_t | index | ) |
Removes a child object in given index.
Index | of 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.
ChildConstIterator kanzi::DataObject::endChildren | ( | ) | const |
Returns iterator in the end of the child container.
|
inline |
DataObjectSharedPtr kanzi::DataObject::lookupDataObject | ( | string_view | relativePath | ) |
Performs object look-up by path.
relativePath | Path of the object where to look at, separated by '.'. |
ModifiedSubscriptionToken kanzi::DataObject::addModifiedNotificationHandler | ( | ModifiedFunction | callback | ) |
Allows to subscribe to modifications in this data object.
callback | Callback that is invoked when a change occurs in this data object. |
void kanzi::DataObject::removeModifiedNotificationHandler | ( | ModifiedSubscriptionToken | token | ) |
Allows to unsubscribe from modifications in this data object.
token | Token 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.