RuntimeDataObject¶
-
class
kanzi::connect
::
RuntimeDataObject
: public enable_shared_from_this<RuntimeDataObject>¶ RuntimeDataObject is a base class for hierarchical runtime data.
Subclassed by RuntimeDataObjectList, RuntimeDataObjectTyped< DataType, DataTypeEnum >
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.
Public Functions
-
explicit
RuntimeDataObject
(ConnectDomain *domain, const string &name, const string nameOverride = "")¶ Standard constructor.
- Parameters
domain – connect domain
name – Name of the data object.
nameOverride – overridden name of the object.
-
explicit
RuntimeDataObject
(ConnectDomain *domain, const string &path, const string &name, const string nameOverride)¶ Standard constructor.
- Parameters
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
~RuntimeDataObject
()¶ C++ destructor.
Adds data object as child of this object.
- Parameters
child – Child object to add.
-
ModifiedSubscriptionToken
addModifiedNotificationHandler
(ModifiedFunction callback)¶ Allows to subscribe to modifications in this data context.
- Parameters
callback – Callback that is invoked when a change occurs in this data context.
- Returns
Token that can be used to identify and remove given subscription.
-
ChildConstIterator
beginChildren
() const¶ Returns iterator to start of the child container.
- Returns
Iterator at the beginning of the container.
Cast this object to specific type.
-
virtual RuntimeDataObjectSharedPtr
clone
()¶ Clones an object and creates exact duplicate of it.
How ever, possible modification subscriptions are not duplicated.
- Returns
newly allocated object with exactly same contents.
-
void
copyDataFrom
(RuntimeDataObject &from)¶ Copies basic data from provided object.
- Parameters
from – where the copying is done from.
Copies a value from other object.
- Parameters
other – the object where-from copying takes place
- Returns
true if copied successfully.
-
bool
createChild
(const string &name, const RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const bool writable, const persistence::SettingFactory *settingFactory)¶ Create a child under this runtime data object.
- Parameters
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
writable – Should the element have modifier method (used by code generation only)
settingFactory – Used to create children with persistent values
- Returns
True if the child was successfully added
-
bool
createChildRecursive
(const string &path, RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const bool writable, const persistence::SettingFactory *settingFactory)¶ Create a child data object in the correct place in hierarchy specified by path.
- Parameters
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
writable – Should the element have modifier method (used by code generation only)
settingFactory – Used to create children with persistent values
- Returns
True if the child was successfully added
-
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.
- Parameters
path – Identifies the objects to create
settingFactory – Used to create children with persistent values (passed to future children, not used directly)
- Returns
The created leaf object which can be used as parent for future children
-
ChildConstIterator
endChildren
() const¶ Returns iterator in the end of the child container.
- Returns
Iterator in the end of the container.
Compares objects and returns true if objects, including childs, are equal.
- Parameters
other – where to compare
- Returns
true if equal.
-
RuntimeDataObjectSharedPtr
findChild
(const string &name)¶ Tries to find a child with given name.
- Returns
Child object that was found, or empty pointer if there is no such child.
Retrieve a typed children with specific name.
- Parameters
name – the name of children to look for
- Returns
typed shared pointer or empty pointer.
-
RuntimeDataObjectSharedPtr
findChild
(uint32_t hash)¶ Tries to find a child with given name hash code.
- Parameters
hash – the hashcode to be used in lookup.
Retrieve a typed children with specific name hash code.
- Parameters
hash – The hash of the children to look for.
- Returns
typed shared pointer or empty pointer.
-
RuntimeDataObjectSharedPtr
findChildRecursive
(const string &path, bool passLists = true)¶ Locates childs recursively.
- Parameters
path – full path to object, items separated with dot (‘.’). i.e. Engine.Speed
passLists – whether to go over lists.
- Returns
Object that was found or empty pointer if path could not be resolved.
Locates childs recursively.
- Parameters
path – full path to object, items separated with dot (‘.’). i.e. Engine.Speed
passLists – whether to go over lists.
- Returns
Object that was found or empty pointer if path could not be resolved.
-
RuntimeDataObjectSharedPtr
getChild
(size_t index) const¶ Retrieves a child object in given index.
- Returns
Child data object in given index.
-
size_t
getChildCount
() const¶ Retrieves the count of child objects in this data object.
- Returns
Child object count.
-
size_t
getChildIndex
(const RuntimeDataObject &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.
-
inline 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,.
- See
RuntimeDataObject::isFreeformProperty
-
int
getIntProperty
(const string &name, int defaultValue = 0) const¶ Retrieve int property value.
- Parameters
name – the name of the property
defaultValue – the value for the property
- Returns
retrieved value
-
string
getName
() const¶ Allows to retrieve the name of the object.
- Returns
Returns the name of the object.
-
virtual uint32_t
getNameHash
()¶ retrieve hash code for the name portion of node
- Returns
CRC32 hash.
-
string
getNameOverride
() const¶ Retrieve the overriden name.
- Returns
the overriden name. if not specified then returns same as getName
-
const string &
getPath
() const¶
-
virtual string
getSerializedValue
() const¶ Get the runtimedata object value in serialized format.
- Returns
The value, empty string if object has no value
-
string
getStringProperty
(const string &name, const string defaultValue = "") const¶ Retrieve string property value.
- Parameters
name – the name of the property
defaultValue – the value for the property
- Returns
retrieved value
-
inline virtual Type
getType
() const¶ Allows to retrieve the type of the object.
- Returns
Type enumeration of the object.
Retrieve UI Delegate and cast it to approriate type.
Note
This is Kanzi Connect frameworks internal use only.
- Returns
caseted type or null.
-
ModifiedSubscriptionToken
getUIDelegateModificationHandlerToken
() const¶ Retrieve UI Delegate specific modification handlers registration token.
Note
This is Kanzi Connect frameworks internal use only.
- Returns
registration token.
-
bool
getWritable
() const¶ Retrieve writable status.
- Returns
writable status.
-
bool
hasChild
(const RuntimeDataObject &child) const¶ Checks whether or not the child exists.
- Returns
true if there is such child, otherwise false.
-
bool
hasProperty
(const string &name)¶ Checks whether there is a property with given name.
- Parameters
name – the name to check.
- Returns
true if property with name exists.
-
virtual void
notifyModified
(RuntimeDataObject *object = 0)¶ 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 void
removeAllChildren
()¶ Removes all children.
-
virtual void
removeChild
(const RuntimeDataObject &child)¶ Removes a child object from list of childs.
- Parameters
child – Child object to remove.
-
virtual bool
removeChild
(const string &name)¶ Remove specified child of this object.
- Parameters
name – Identifies the child to remove
- Returns
True if a child is found and removed
-
virtual void
removeChild
(size_t index)¶ Removes a child object in given index.
- Parameters
index – The index of the child object to remove.
-
bool
removeChildRecursive
(const string &path)¶ Remove specified child and all elements in the path that would become empty.
- Parameters
path – Identifies the element to remove
- Returns
True if at least one element was removed
-
void
removeModifiedNotificationHandler
(ModifiedSubscriptionToken token)¶ Allows to unsubscribe from modifications in this data context.
- Parameters
token – Token to identify the subscription that should be removed.
-
void
removeProperty
(const string &name)¶ Removes a property with specific name.
- Parameters
name – the name of the property to remove.
-
void
setName
(const string &value)¶ Sets the name of the object.
- Parameters
value – New name that is assigned to object.
-
void
setNameOverride
(const string &value)¶ Sets the overriden name of the object.
- Parameters
value – New name that is assigned to object.
-
void
setProperty
(const string &name, const string &value)¶ Sets a local property - this information is not serialized.
- Parameters
name – name of the property
value – the value for the property.
-
void
setProperty
(const string &name, int value)¶ Sets a local property - this information is not serialized.
- Parameters
name – the name of the property
value – the value of the property
-
bool
setSerializedValue
(const string &serializedValue)¶ Set the value for this data object, if this is not typed or list type then this will fail.
- Parameters
serializedValue – Contains the data value to set in serialized format
- Returns
False if fails due to object type or data deserialization failure
-
void
setUIDelegateModificationHandlerToken
(ModifiedSubscriptionToken token)¶ Store UI Delegate modification handler handle.
Note
This is Kanzi Connect frameworks internal use only.
- Parameters
token – the token to store
Configures UI Delegate object for this content object.
Note
This is Kanzi Connect frameworks internal use only.
- Parameters
deleg – delegate object
-
void
setWritable
(bool writable)¶ Set writable flag.
- Parameters
writable – state
Public Static Functions
-
static bool
isFreeformProperty
(const string &propertyName)¶ Checks whether the named property is one of the defined properties or not.
- Parameters
propertyName – Identifies what kind of property is
- Returns
True if property is not one of the specially defined ones
-
typedef ChildContainer::const_iterator