RuntimeDataObject is a base class for hierarchical runtime data. More...
#include <runtimedataobject.hpp>
Public Types | |
typedef ChildContainer::const_iterator | ChildConstIterator |
typedef ChildContainer::const_reverse_iterator | ChildConstReverseIterator |
typedef vector< RuntimeDataObjectSharedPtr > | ChildContainer |
Iterators for children. | |
typedef function< void(RuntimeDataObject *self) | ModifiedFunction) |
Callback function type for change subscriptions. | |
typedef shared_ptr< void > | ModifiedSubscriptionToken |
Token type that can be used to identify the change subscription. | |
enum class | Persistence { NON_PERSISTENT , PERSISTENT } |
Is the runtime data object persistent or not. More... | |
enum | Type { Object = 0 , Integer = 1 , Real = 2 , Bool = 3 , String = 4 , List = 6 , Unknown = 100 } |
Type enumerations for different data object types. More... | |
Public Member Functions | |
void | addChild (const RuntimeDataObjectSharedPtr &child) |
Adds data object as child of this object. | |
ModifiedSubscriptionToken | addModifiedNotificationHandler (ModifiedFunction callback) |
Allows to subscribe to modifications in this data context. | |
ChildConstIterator | beginChildren () const |
Returns iterator to start of the child container. | |
template<typename _ToClass > | |
shared_ptr< _ToClass > | castTo () |
Cast this object to specific type. | |
virtual RuntimeDataObjectSharedPtr | clone () |
Clones an object and creates exact duplicate of it. | |
void | copyDataFrom (RuntimeDataObject &from) |
Copies basic data from provided object. | |
virtual bool | copyValueFrom (RuntimeDataObjectSharedPtr other) |
Copies a value from other object. | |
bool | createChild (const string &name, const RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const int flags, const persistence::SettingFactory *settingFactory) |
Create a child under this runtime data object. | |
bool | createChildRecursive (const string &path, RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const int flags, const persistence::SettingFactory *settingFactory) |
Create a child data object in the correct place in hierarchy specified by path. | |
RuntimeDataObjectSharedPtr | createPathObjects (const string &path, const persistence::SettingFactory *settingFactory) |
Create objects enough to have the given path in the runtime data and return the leaf object All created objects are of Type::Object. | |
ChildConstIterator | endChildren () const |
Returns iterator in the end of the child container. | |
virtual bool | equals (RuntimeDataObjectSharedPtr other) |
Compares objects and returns true if objects, including childs, are equal. | |
RuntimeDataObjectSharedPtr | findChild (const string &name) |
Tries to find a child with given name. | |
template<typename _T > | |
shared_ptr< _T > | findChild (const string &name) |
Retrieve a typed children with specific name. | |
RuntimeDataObjectSharedPtr | findChild (uint32_t hash) |
Tries to find a child with given name hash code. | |
template<typename _T > | |
shared_ptr< _T > | findChild (uint32_t hash) |
Retrieve a typed children with specific name hash code. | |
RuntimeDataObjectSharedPtr | findChildRecursive (const string &path, bool passLists=true) |
Locates childs recursively. | |
template<typename _T > | |
shared_ptr< _T > | findChildRecursive (const string &path, bool passLists=true) |
Locates childs recursively. | |
bool | generatesGetter () const |
Retrieve getter generation status. | |
RuntimeDataObjectSharedPtr | getChild (size_t index) const |
Retrieves a child object in given index. | |
template<typename _T > | |
shared_ptr< _T > | getChild (size_t index) const |
size_t | getChildCount () const |
Retrieves the count of child objects in this data object. | |
size_t | getChildIndex (const RuntimeDataObject &child) const |
Retrieves the index of a child data object. | |
virtual string | getDefaultValueStr () const |
Virtual function which exists in this base class but should never be used. This is overridden in classes where its appropriate. | |
void | getFreeformProperties (vector< pair< string, string > > &output) |
Get list of the free form properties defined for the object output The freeform properties will be copied here,. | |
int | getIntProperty (const string &name, int defaultValue=0) const |
Retrieve int property value. | |
string | getName () const |
Allows to retrieve the name of the object. | |
virtual uint32_t | getNameHash () |
retrieve hash code for the name portion of node | |
string | getNameOverride () const |
Retrieve the overriden name. | |
const string & | getPath () const |
virtual string | getSerializedValue () const |
Get the runtimedata object value in serialized format. | |
string | getStringProperty (const string &name, const string defaultValue="") const |
Retrieve string property value. | |
virtual Type | getType () const |
Allows to retrieve the type of the object. | |
template<typename _ToClass > | |
shared_ptr< _ToClass > | getUIDelegate () |
Retrieve UI Delegate and cast it to approriate type. | |
ModifiedSubscriptionToken | getUIDelegateModificationHandlerToken () const |
Retrieve UI Delegate specific modification handlers registration token. | |
bool | getWritable () const |
Retrieve writable status. | |
bool | hasChild (const RuntimeDataObject &child) const |
Checks whether or not the child exists. | |
bool | hasProperty (const string &name) |
Checks whether there is a property with given name. | |
virtual void | notifyModified (RuntimeDataObject *object=0) |
Triggers modification procedure in this data context, which invokes the subscriptions. | |
virtual void | removeAllChildren () |
Removes all children. | |
virtual void | removeChild (const RuntimeDataObject &child) |
Removes a child object from list of childs. | |
virtual bool | removeChild (const string &name) |
Remove specified child of this object. | |
virtual void | removeChild (size_t index) |
Removes a child object in given index. | |
bool | removeChildRecursive (const string &path) |
Remove specified child and all elements in the path that would become empty. | |
void | removeModifiedNotificationHandler (ModifiedSubscriptionToken token) |
Allows to unsubscribe from modifications in this data context. | |
void | removeProperty (const string &name) |
Removes a property with specific name. | |
RuntimeDataObject (ConnectDomainSharedPtr domain, const string &name, const string nameOverride="") | |
Standard constructor. | |
RuntimeDataObject (ConnectDomainSharedPtr domain, const string &path, const string &name, const string nameOverride) | |
Standard constructor. | |
bool | sendsEvent () const |
Retrieve notifier event generation status. | |
void | setGenerateGetter (bool creteGetter) |
Set generate getter flag. | |
void | setName (const string &value) |
Sets the name of the object. | |
void | setNameOverride (const string &value) |
Sets the overriden name of the object. | |
void | setProperty (const string &name, const string &value) |
Sets a local property - this information is not serialized. | |
void | setProperty (const string &name, int value) |
Sets a local property - this information is not serialized. | |
void | setSendsEvent (bool createEventOnChange) |
Set generate notifier event flag. | |
bool | setSerializedValue (const string &serializedValue) |
Set the value for this data object, if this is not typed or list type then this will fail. | |
void | setUIDelegateModificationHandlerToken (ModifiedSubscriptionToken token) |
Store UI Delegate modification handler handle. | |
void | setUIDelegete (shared_ptr< DataObject > deleg) |
Configures UI Delegate object for this content object. | |
void | setWritable (bool writable) |
Set writable flag. | |
virtual | ~RuntimeDataObject () |
C++ destructor. | |
Static Public Member Functions | |
static bool | isFreeformProperty (const string &propertyName) |
Checks whether the named property is one of the defined properties or not. | |
static Type | str2Type (const string &str) |
Convert a string to Type. | |
static string | type2Str (const Type type) |
Convert the type enumeration value to human readable string. | |
Protected Types | |
typedef unordered_map< RuntimeDataObjectSharedPtr, ModifiedSubscriptionToken > | ChildrenSubscriptionContainer |
enum | PrivateRuntimeFlags { NONE = 0x0 , HAS_SETTER = 0x0001 , HAS_NOTIFIER = 0x0010 , HAS_GETTER = 0x0100 } |
Protected Attributes | |
ChildContainer | m_children |
Children of the data object. | |
ChildrenSubscriptionContainer | m_childrenSubscriptionTokens |
ConnectDomainSharedPtr | m_domain |
The connect domain this dataobject is bound to. | |
int | m_flags |
string | m_name |
Name of the object. | |
uint32_t | m_nameHash |
Hash code of the name. | |
string | m_nameOverride |
UI Override for the name. | |
string | m_path |
Contains the full path of the object and its parents. | |
optional< unordered_map< string, string > > | m_properties |
Free form properties set for the object. | |
Type | m_type |
Possible type. | |
weak_ptr< DataObject > | m_UIDelegate |
UI class, kept as unknown here, just a pointer. | |
ModifiedSubscriptionToken | m_UIDelegateModificationToken |
Token for modification registrations of UI Delegate. | |
RuntimeDataObject is a base class for hierarchical runtime data.
typedef ChildContainer::const_iterator kanzi::connect::RuntimeDataObject::ChildConstIterator |
typedef ChildContainer::const_reverse_iterator kanzi::connect::RuntimeDataObject::ChildConstReverseIterator |
Iterators for children.
|
protected |
typedef function<void(RuntimeDataObject* self) kanzi::connect::RuntimeDataObject::ModifiedFunction) |
Callback function type for change subscriptions.
typedef shared_ptr<void> kanzi::connect::RuntimeDataObject::ModifiedSubscriptionToken |
Token type that can be used to identify the change subscription.
|
strong |
|
protected |
|
explicit |
Standard constructor.
domain | connect domain |
name | Name of the data object. |
nameOverride | overridden name of the object. |
|
explicit |
Standard constructor.
domain | connect domain |
path | Path that contains names of the parents separated with '.' |
name | Name of the data object. |
nameOverride | overridden name of the object. |
|
virtual |
C++ destructor.
void kanzi::connect::RuntimeDataObject::addChild | ( | const RuntimeDataObjectSharedPtr & | child | ) |
Adds data object as child of this object.
child | Child object to add. |
ModifiedSubscriptionToken kanzi::connect::RuntimeDataObject::addModifiedNotificationHandler | ( | ModifiedFunction | callback | ) |
Allows to subscribe to modifications in this data context.
callback | Callback that is invoked when a change occurs in this data context. |
ChildConstIterator kanzi::connect::RuntimeDataObject::beginChildren | ( | ) | const |
Returns iterator to start of the child container.
|
inline |
Cast this object to specific type.
|
virtual |
Clones an object and creates exact duplicate of it.
How ever, possible modification subscriptions are not duplicated.
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >, and kanzi::connect::RuntimeDataObjectList.
void kanzi::connect::RuntimeDataObject::copyDataFrom | ( | RuntimeDataObject & | from | ) |
Copies basic data from provided object.
from | where the copying is done from. |
|
virtual |
Copies a value from other object.
other | the object where-from copying takes place |
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >.
bool kanzi::connect::RuntimeDataObject::createChild | ( | const string & | name, |
const RuntimeDataObject::Type | dataType, | ||
const string & | serializedDefaultValue, | ||
const bool | persistent, | ||
const int | flags, | ||
const persistence::SettingFactory * | settingFactory ) |
Create a child under this runtime data object.
name | The name of the child |
dataType | The data type of the child |
serializedDefaultValue | The default value in serialized format, to be deserialized based on given data type |
persistent | Is the element persisted over reboots |
flags | Should the element have modifier method (used by code generation only) |
settingFactory | Used to create children with persistent values |
bool kanzi::connect::RuntimeDataObject::createChildRecursive | ( | const string & | path, |
RuntimeDataObject::Type | dataType, | ||
const string & | serializedDefaultValue, | ||
const bool | persistent, | ||
const int | flags, | ||
const persistence::SettingFactory * | settingFactory ) |
Create a child data object in the correct place in hierarchy specified by path.
path | Specifies the location of the child, if needed then intermediate layers are created on the way |
dataType | The data type of the child |
serializedDefaultValue | The default value in serialized format, to be deserialized based on given data type |
persistent | Is the element persisted over reboots |
flags | Should the element have modifier method (used by code generation only) |
settingFactory | Used to create children with persistent values |
RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObject::createPathObjects | ( | const string & | path, |
const persistence::SettingFactory * | settingFactory ) |
Create objects enough to have the given path in the runtime data and return the leaf object All created objects are of Type::Object.
path | Identifies the objects to create |
settingFactory | Used to create children with persistent values (passed to future children, not used directly) |
ChildConstIterator kanzi::connect::RuntimeDataObject::endChildren | ( | ) | const |
Returns iterator in the end of the child container.
|
virtual |
Compares objects and returns true if objects, including childs, are equal.
other | where to compare |
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >, and kanzi::connect::RuntimeDataObjectList.
RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObject::findChild | ( | const string & | name | ) |
Tries to find a child with given name.
|
inline |
Retrieve a typed children with specific name.
name | the name of children to look for |
RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObject::findChild | ( | uint32_t | hash | ) |
Tries to find a child with given name hash code.
hash | the hashcode to be used in lookup. |
|
inline |
Retrieve a typed children with specific name hash code.
hash | The hash of the children to look for. |
RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObject::findChildRecursive | ( | const string & | path, |
bool | passLists = true ) |
Locates childs recursively.
path | full path to object, items separated with dot ('.'). i.e. Engine.Speed |
passLists | whether to go over lists. |
|
inline |
Locates childs recursively.
path | full path to object, items separated with dot ('.'). i.e. Engine.Speed |
passLists | whether to go over lists. |
bool kanzi::connect::RuntimeDataObject::generatesGetter | ( | ) | const |
Retrieve getter generation status.
RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObject::getChild | ( | size_t | index | ) | const |
Retrieves a child object in given index.
|
inline |
size_t kanzi::connect::RuntimeDataObject::getChildCount | ( | ) | const |
Retrieves the count of child objects in this data object.
size_t kanzi::connect::RuntimeDataObject::getChildIndex | ( | const RuntimeDataObject & | child | ) | const |
Retrieves the index of a child data object.
|
inlinevirtual |
Virtual function which exists in this base class but should never be used. This is overridden in classes where its appropriate.
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >.
void kanzi::connect::RuntimeDataObject::getFreeformProperties | ( | vector< pair< string, string > > & | output | ) |
Get list of the free form properties defined for the object output The freeform properties will be copied here,.
int kanzi::connect::RuntimeDataObject::getIntProperty | ( | const string & | name, |
int | defaultValue = 0 ) const |
Retrieve int property value.
name | the name of the property |
defaultValue | the value for the property |
string kanzi::connect::RuntimeDataObject::getName | ( | ) | const |
Allows to retrieve the name of the object.
|
virtual |
retrieve hash code for the name portion of node
string kanzi::connect::RuntimeDataObject::getNameOverride | ( | ) | const |
Retrieve the overriden name.
const string & kanzi::connect::RuntimeDataObject::getPath | ( | ) | const |
|
virtual |
Get the runtimedata object value in serialized format.
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >.
string kanzi::connect::RuntimeDataObject::getStringProperty | ( | const string & | name, |
const string | defaultValue = "" ) const |
Retrieve string property value.
name | the name of the property |
defaultValue | the value for the property |
|
inlinevirtual |
Allows to retrieve the type of the object.
Reimplemented in kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >, and kanzi::connect::RuntimeDataObjectList.
|
inline |
Retrieve UI Delegate and cast it to approriate type.
ModifiedSubscriptionToken kanzi::connect::RuntimeDataObject::getUIDelegateModificationHandlerToken | ( | ) | const |
Retrieve UI Delegate specific modification handlers registration token.
bool kanzi::connect::RuntimeDataObject::getWritable | ( | ) | const |
Retrieve writable status.
bool kanzi::connect::RuntimeDataObject::hasChild | ( | const RuntimeDataObject & | child | ) | const |
Checks whether or not the child exists.
bool kanzi::connect::RuntimeDataObject::hasProperty | ( | const string & | name | ) |
Checks whether there is a property with given name.
name | the name to check. |
|
static |
Checks whether the named property is one of the defined properties or not.
propertyName | Identifies what kind of property is |
|
virtual |
Triggers modification procedure in this data context, which invokes the subscriptions.
Should be called by derived classes whenever the value of the object is changed.
|
virtual |
Removes all children.
Reimplemented in kanzi::connect::RuntimeDataObjectList.
|
virtual |
Removes a child object from list of childs.
child | Child object to remove. |
Reimplemented in kanzi::connect::RuntimeDataObjectList.
|
virtual |
Remove specified child of this object.
name | Identifies the child to remove |
|
virtual |
Removes a child object in given index.
index | The index of the child object to remove. |
Reimplemented in kanzi::connect::RuntimeDataObjectList.
bool kanzi::connect::RuntimeDataObject::removeChildRecursive | ( | const string & | path | ) |
Remove specified child and all elements in the path that would become empty.
path | Identifies the element to remove |
void kanzi::connect::RuntimeDataObject::removeModifiedNotificationHandler | ( | ModifiedSubscriptionToken | token | ) |
Allows to unsubscribe from modifications in this data context.
token | Token to identify the subscription that should be removed. |
void kanzi::connect::RuntimeDataObject::removeProperty | ( | const string & | name | ) |
Removes a property with specific name.
name | the name of the property to remove. |
bool kanzi::connect::RuntimeDataObject::sendsEvent | ( | ) | const |
Retrieve notifier event generation status.
void kanzi::connect::RuntimeDataObject::setGenerateGetter | ( | bool | creteGetter | ) |
Set generate getter flag.
param createGetter if true, the object will have a direct method to read its value
void kanzi::connect::RuntimeDataObject::setName | ( | const string & | value | ) |
Sets the name of the object.
value | New name that is assigned to object. |
void kanzi::connect::RuntimeDataObject::setNameOverride | ( | const string & | value | ) |
Sets the overriden name of the object.
value | New name that is assigned to object. |
void kanzi::connect::RuntimeDataObject::setProperty | ( | const string & | name, |
const string & | value ) |
Sets a local property - this information is not serialized.
name | name of the property |
value | the value for the property. |
void kanzi::connect::RuntimeDataObject::setProperty | ( | const string & | name, |
int | value ) |
Sets a local property - this information is not serialized.
name | the name of the property |
value | the value of the property |
void kanzi::connect::RuntimeDataObject::setSendsEvent | ( | bool | createEventOnChange | ) |
Set generate notifier event flag.
param createEventOnChange if true, the object will emit an event when its value changes
bool kanzi::connect::RuntimeDataObject::setSerializedValue | ( | const string & | serializedValue | ) |
Set the value for this data object, if this is not typed or list type then this will fail.
serializedValue | Contains the data value to set in serialized format |
void kanzi::connect::RuntimeDataObject::setUIDelegateModificationHandlerToken | ( | ModifiedSubscriptionToken | token | ) |
Store UI Delegate modification handler handle.
token | the token to store |
|
inline |
Configures UI Delegate object for this content object.
deleg | delegate object |
void kanzi::connect::RuntimeDataObject::setWritable | ( | bool | writable | ) |
Set writable flag.
writable | state |
|
static |
Convert a string to Type.
str | Contains the data type, interchangeable with type2Str |
|
static |
Convert the type enumeration value to human readable string.
type | The enumeration value to convert |
|
protected |
Children of the data object.
|
protected |
|
protected |
The connect domain this dataobject is bound to.
|
protected |
|
protected |
Name of the object.
|
protected |
Hash code of the name.
|
protected |
UI Override for the name.
|
protected |
Contains the full path of the object and its parents.
|
protected |
Free form properties set for the object.
|
protected |
Possible type.
|
protected |
UI class, kept as unknown here, just a pointer.
|
protected |
Token for modification registrations of UI Delegate.