ServiceRuntimeData¶
-
class
kanzi::connect
::
ServiceRuntimeData
¶ Encapsulates service runtime data.
Public Types
-
typedef function<void(const string &path)>
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
-
ServiceRuntimeData
(ConnectDomain *domain, const persistence::SettingFactory *settingFactory)¶ Runtime data of a service.
- Parameters
domain
: the domain where the runtime data operates in.settingFactory
: factory to access persistence service
-
ServiceRuntimeData
(ConnectDomain *domain, const persistence::SettingFactory *settingFactory, const string &service_name)¶ Runtime data of a service.
- Parameters
domain
: the domain where the runtime data operates in.settingFactory
: factory to access persistence serviceservice_name
: the service name to which the runtime data belongs to
-
~ServiceRuntimeData
()¶
-
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.
-
ModifiedSubscriptionToken
addModifiedNotificationHandlerEx
(ModifiedCallback *callback)¶ Subscribes to modification notifications within this object.
- Return
token that can be used to identify and remove given subscription.
- Parameters
callback
: the callback interface whom method is to be called on change.
-
bool
createElement
(const string &parentPath, const string &xml)¶ Create a new element to the runtime data in the given path.
- Return
True if the new element was successfully added
- Parameters
parentPath
: Specifies where to add the new element.xml
: Contains the xml defining the element contents
-
RuntimeDataObjectBoolSharedPtr
getBoolObject
(const string &path) const¶ Retrieve boolean object at specific path.
- Return
boolean object or empty pointer.
- Parameters
path
: full path to object to retrieve.
-
bool
getBoolValue
(const string &path, bool defaultValue = false)¶ Retrieve boolean value from runtime data parameter.
- Return
runtime data value
- Parameters
path
: identify the data object.defaultValue
: value to return in case named parameter not found.
-
RuntimeDataObjectIntSharedPtr
getIntObject
(const string &path) const¶ Retrieve int object at specific path.
- Return
int object or empty pointer.
- Parameters
path
: full path to object to retrieve.
-
int
getIntValue
(const string &path, int defaultValue = 0)¶ Retrieve int value from runtime data parameter.
- Return
runtime data value
- Parameters
path
: identify the data object.defaultValue
: value to return in case named parameter not found.
-
size_t
getListItemCount
(const string &path) const¶ Returns the amount of list items the pointed list has.
Shall the path point to something else than a list then 0 is returned.
- Return
amount of objects. >= 0.
- Parameters
path
: the path to list to inspect
-
RuntimeDataObjectListSharedPtr
getListObject
(const string &path) const¶ Retrieve list object at specific path.
- Return
string object or empty pointer.
- Parameters
path
: full path to object to retrieve.
-
RuntimeDataObjectSharedPtr
getObject
(const string &path) const¶ Retrieves object.
- Return
object or empty pointer.
- Parameters
path
: Full path to object
-
RuntimeDataObject::Type
getObjectType
(const string &path) const¶ Retrieves the type of the object at specific path.
- Return
type of object.
- Parameters
path
: Full path to object.
-
RuntimeDataObjectRealSharedPtr
getRealObject
(const string &path) const¶ Retrieve real object at specific path.
- Return
real object or empty pointer.
- Parameters
path
: full path to object to retrieve.
-
double
getRealValue
(const string &path, double defaultValue = 0)¶ Retrieve real value from runtime data parameter.
- Return
runtime data value
- Parameters
path
: identify the data object.defaultValue
: value to return in case named parameter not found.
-
RuntimeDataObjectSharedPtr
getRoot
()¶ Retrieve the root node.
- Return
the root node.
-
string
getSchema
()¶ Returns the data schema in XML.
- Return
XML Schema.
-
const string &
getServiceName
() const¶ Retrieves the service name to which the runtime data belongs.
- Return
the service name to which the runtime data belongs
-
RuntimeDataObjectStringSharedPtr
getStringObject
(const string &path) const¶ Retrieve string object at specifi path.
- Return
string object or empty pointer.
- Parameters
path
: full path to object to retrieve.
-
string
getStringValue
(const string &path, string defaultValue = "")¶ Retrieve string value from runtime data parameter.
- Return
runtime data value
- Parameters
path
: identify the data object.defaultValue
: value to return in case named parameter not found.
-
bool
hasObject
(const string &path) const¶ Checks whether object exists in specific path.
- Return
true if path points to a valid object.
- Parameters
path
: Full path to object, using dotted format First.Second.Third
-
void
notifyModified
(string path = "")¶ Notifies subscriptions when the content changes.
Framework reports changed values to clients asynchronously if an instance of ConnectDomain is given to the class during construction. However, by manually notifying changes, one can flush the pending notifications and also patch several changes into single notification. It is up to subscription, what values will be actually sent to client.
- Parameters
path
: the path that needs to be reported.
-
bool
parseFromXML
(const string &serviceIdentifier, const string &xml)¶ Parses the structure from a XML file.
- Return
true if file parsed successfully
- Parameters
serviceIdentifier
: Identifies the service for which the runtime data belongs toxml
: structure
-
bool
parseFromXMLElement
(const tinyxml2::XMLElement *element)¶ Parses structure from xml structure.
- Return
true if success, false otherwise.
- Parameters
element
: the element whom childs are to be enumerated
-
bool
removeElement
(const string &path)¶ Remove the given element from the runtime data, removes intermediate elements if they become empty.
- Return
True if removal succeeded
- Parameters
path
: Identifies the element to remove
-
void
removeMethodRecursive
(const string &path)¶ Remove all existing methods under the given path.
-
void
removeModifiedNotificationHandler
(ModifiedSubscriptionToken token)¶ Allows to unsubscribe from modifications in this data context.
- Parameters
token
: Token to identify the subscription that should be removed.
-
bool
setSerializedValue
(const string &path, const string &serializedValue)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectserializedValue
: new value to set in serialized format, it will deserialized based on the type of path target.
-
bool
setValue
(const string &path, int value)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectvalue
: new value to set.
-
bool
setValue
(const string &path, double value)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectvalue
: new value to set.
-
bool
setValue
(const string &path, string value)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectvalue
: new value to set.
-
bool
setValue
(const string &path, const char *value)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectvalue
: new value to set.
-
bool
setValue
(const string &path, bool value)¶ Set value for a runtime data parameter.
- Return
true if values set.
- Parameters
path
: identify the data objectvalue
: new value to set.
-
class
ModifiedCallback
¶ Old school modification callback.
-
typedef function<void(const string &path)>