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
-
RuntimeDataObject
(ConnectDomain *domain, const string &name, const string nameOverride = "")¶ Standard constructor.
- Parameters
domain
: connect domainname
: Name of the data object.nameOverride
: overridden name of the object.
-
RuntimeDataObject
(ConnectDomain *domain, const string &path, const string &name, const string nameOverride)¶ Standard constructor.
- Parameters
domain
: connect domainpath
: Path that contains names of the parents separated with ‘.’name
: Name of the data object.nameOverride
: overridden name of the object.
-
~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.
- Return
Token that can be used to identify and remove given subscription.
- Parameters
callback
: Callback that is invoked when a change occurs in this data context.
-
ChildConstIterator
beginChildren
() const¶ Returns iterator to start of the child container.
- Return
Iterator at the beginning of the container.
Cast this object to specific type.
-
RuntimeDataObjectSharedPtr
clone
()¶ Clones an object and creates exact duplicate of it.
How ever, possible modification subscriptions are not duplicated.
- Return
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.
- Return
true if copied successfully.
- Parameters
other
: the object where-from copying takes place
-
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.
- Return
True if the child was successfully added
- Parameters
name
: The name of the childdataType
: The data type of the childserializedDefaultValue
: The default value in serialized format, to be deserialized based on given data typepersistent
: Is the element persisted over rebootswritable
: Should the element have modifier method (used by code generation only)settingFactory
: Used to create children with persistent values
-
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.
- Return
True if the child was successfully added
- Parameters
path
: Specifies the location of the child, if needed then intermediate layers are created on the waydataType
: The data type of the childserializedDefaultValue
: The default value in serialized format, to be deserialized based on given data typepersistent
: Is the element persisted over rebootswritable
: Should the element have modifier method (used by code generation only)settingFactory
: Used to create children with persistent values
-
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.
- Return
The created leaf object which can be used as parent for future children
- Parameters
path
: Identifies the objects to createsettingFactory
: Used to create children with persistent values (passed to future children, not used directly)
-
ChildConstIterator
endChildren
() const¶ Returns iterator in the end of the child container.
- Return
Iterator in the end of the container.
Compares objects and returns true if objects, including childs, are equal.
- Return
true if equal.
- Parameters
other
: where to compare
-
RuntimeDataObjectSharedPtr
findChild
(const string &name)¶ Tries to find a child with given name.
- Return
Child object that was found, or empty pointer if there is no such child.
Retrieve a typed children with specific name.
- Return
typed shared pointer or empty pointer.
- Parameters
name
: the name of children to look for
-
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.
- Return
typed shared pointer or empty pointer.
- Parameters
hash
: The hash of the children to look for.
-
RuntimeDataObjectSharedPtr
findChildRecursive
(const string &path, bool passLists = true)¶ Locates childs recursively.
- Return
Object that was found or empty pointer if path could not be resolved.
- Parameters
path
: full path to object, items separated with dot (‘.’). i.e. Engine.SpeedpassLists
: whether to go over lists.
Locates childs recursively.
- Return
Object that was found or empty pointer if path could not be resolved.
- Parameters
path
: full path to object, items separated with dot (‘.’). i.e. Engine.SpeedpassLists
: whether to go over lists.
-
RuntimeDataObjectSharedPtr
getChild
(size_t index) const¶ Retrieves a child object in given index.
- Return
Child data object in given index.
-
size_t
getChildCount
() const¶ Retrieves the count of child objects in this data object.
- Return
Child object count.
-
size_t
getChildIndex
(const RuntimeDataObject &child) const¶ Retrieves the index of a child data object.
- Return
Index of the item in question, throws exception if there is no such child.
-
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.
- Return
retrieved value
- Parameters
name
: the name of the propertydefaultValue
: the value for the property
-
string
getName
() const¶ Allows to retrieve the name of the object.
- Return
Returns the name of the object.
-
uint32_t
getNameHash
()¶ retrieve hash code for the name portion of node
- Return
CRC32 hash.
-
string
getNameOverride
() const¶ Retrieve the overriden name.
- Return
the overriden name. if not specified then returns same as getName
-
const string &
getPath
() const¶
-
string
getSerializedValue
() const¶ Get the runtimedata object value in serialized format.
- Return
The value, empty string if object has no value
-
string
getStringProperty
(const string &name, const string defaultValue = "") const¶ Retrieve string property value.
- Return
retrieved value
- Parameters
name
: the name of the propertydefaultValue
: the value for the property
-
Type
getType
() const¶ Allows to retrieve the type of the object.
- Return
Type enumeration of the object.
Retrieve UI Delegate and cast it to approriate type.
- Note
This is Kanzi Connect frameworks internal use only.
- Return
caseted type or null.
-
ModifiedSubscriptionToken
getUIDelegateModificationHandlerToken
() const¶ Retrieve UI Delegate specific modification handlers registration token.
- Note
This is Kanzi Connect frameworks internal use only.
- Return
registration token.
-
bool
getWritable
() const¶ Retrieve writable status.
- Return
writable status.
-
bool
hasChild
(const RuntimeDataObject &child) const¶ Checks whether or not the child exists.
- Return
true if there is such child, otherwise false.
-
bool
hasProperty
(const string &name)¶ Checks whether there is a property with given name.
- Return
true if property with name exists.
- Parameters
name
: the name to check.
-
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.
-
void
removeAllChildren
()¶ Removes all children.
-
void
removeChild
(const RuntimeDataObject &child)¶ Removes a child object from list of childs.
- Parameters
child
: Child object to remove.
-
bool
removeChild
(const string &name)¶ Remove specified child of this object.
- Return
True if a child is found and removed
- Parameters
name
: Identifies the child to remove
-
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.
- Return
True if at least one element was removed
- Parameters
path
: Identifies the element to remove
-
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 propertyvalue
: 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 propertyvalue
: 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.
- Return
False if fails due to object type or data deserialization failure
- Parameters
serializedValue
: Contains the data value to set in serialized format
-
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
-
bool
isFreeformProperty
(const string &propertyName)¶ Checks whether the named property is one of the defined properties or not.
- Return
True if property is not one of the specially defined ones
- Parameters
propertyName
: Identifies what kind of property is
-
typedef ChildContainer::const_iterator