Encapsulates service runtime data. More...
#include <serviceruntimedata.hpp>
Classes | |
class | ModifiedCallback |
Old school modification callback. More... | |
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 Member Functions | |
ModifiedSubscriptionToken | addModifiedNotificationHandler (ModifiedFunction callback) |
Allows to subscribe to modifications in this data context. | |
ModifiedSubscriptionToken | addModifiedNotificationHandlerEx (ModifiedCallback *callback) |
Subscribes to modification notifications within this object. | |
bool | createElement (const string &parentPath, const string &xml) |
Create a new element to the runtime data in the given path. | |
RuntimeDataObjectBoolSharedPtr | getBoolObject (const string &path) const |
Retrieve boolean object at specific path. | |
bool | getBoolValue (const string &path, bool defaultValue=false) |
Retrieve boolean value from runtime data parameter. | |
RuntimeDataObjectIntSharedPtr | getIntObject (const string &path) const |
Retrieve int object at specific path. | |
int | getIntValue (const string &path, int defaultValue=0) |
Retrieve int value from runtime data parameter. | |
size_t | getListItemCount (const string &path) const |
Returns the amount of list items the pointed list has. | |
RuntimeDataObjectListSharedPtr | getListObject (const string &path) const |
Retrieve list object at specific path. | |
RuntimeDataObjectSharedPtr | getObject (const string &path) const |
Retrieves object. | |
RuntimeDataObject::Type | getObjectType (const string &path) const |
Retrieves the type of the object at specific path. | |
RuntimeDataObjectRealSharedPtr | getRealObject (const string &path) const |
Retrieve real object at specific path. | |
double | getRealValue (const string &path, double defaultValue=0) |
Retrieve real value from runtime data parameter. | |
RuntimeDataObjectSharedPtr | getRoot () |
Retrieve the root node. | |
const string & | getSchema () |
Returns the data schema in XML. | |
const string & | getServiceName () const |
Retrieves the service name to which the runtime data belongs. | |
RuntimeDataObjectStringSharedPtr | getStringObject (const string &path) const |
Retrieve string object at specifi path. | |
string | getStringValue (const string &path, string defaultValue="") |
Retrieve string value from runtime data parameter. | |
bool | hasObject (const string &path) const |
Checks whether object exists in specific path. | |
void | invalidateSchema () |
Purge XML Schema cache. When a schema is requested next time, the tree structure is to be scanned. | |
void | notifyModified (string path="") |
Notifies subscriptions when the content changes. | |
bool | parseFromXML (const string &serviceIdentifier, const string &xml) |
Parses the structure from a XML file. | |
bool | parseFromXMLElement (const tinyxml2::XMLElement *element) |
Parses structure from xml structure. | |
bool | processMessage (const MessagePackage &message, shared_ptr< GenericRPCReplyMessage > &ret) |
Offer received message directly to service to implement a short path for scripts and built-in methods. Intended for internal use. | |
bool | removeElement (const string &path) |
Remove the given element from the runtime data, removes intermediate elements if they become empty. | |
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. | |
ServiceRuntimeData (ConnectDomainSharedPtr domain, const persistence::SettingFactory *settingFactory) | |
Runtime data of a service. | |
ServiceRuntimeData (ConnectDomainSharedPtr domain, const persistence::SettingFactory *settingFactory, const string &service_name) | |
Runtime data of a service. | |
bool | setSerializedValue (const string &path, const string &serializedValue) |
Set value for a runtime data parameter. | |
bool | setValue (const string &path, bool value) |
Set value for a runtime data parameter. | |
bool | setValue (const string &path, const char *value) |
Set value for a runtime data parameter. | |
bool | setValue (const string &path, double value) |
Set value for a runtime data parameter. | |
bool | setValue (const string &path, int value) |
Set value for a runtime data parameter. | |
bool | setValue (const string &path, string value) |
Set value for a runtime data parameter. | |
virtual | ~ServiceRuntimeData () |
Protected Member Functions | |
void | createServiceExtensionForRuntimeData (const string &parentPath, const tinyxml2::XMLElement *element, const string &operation, RuntimeDataObjectSharedPtr node) |
Create a method or event for a writable or method-readable runtime data. | |
RuntimeDataObjectSharedPtr | getObjectInternal (const string &path, bool passLists) const |
Retrieves object. | |
void | processNode (const tinyxml2::XMLElement *element, RuntimeDataObjectSharedPtr parent) |
Processes a single node during construction. | |
void | processNode (const tinyxml2::XMLElement *element, RuntimeDataObjectSharedPtr parent, bool createMethod) |
Processes a single node during construction. | |
void | validateHashCodes (RuntimeDataObjectSharedPtr object) |
Processes a node tree and checks that it does not contain duplicate hash values that might collide. | |
Encapsulates service runtime data.
typedef function<void(const string& path) kanzi::connect::ServiceRuntimeData::ModifiedFunction) |
Callback function type for change subscriptions.
typedef shared_ptr<void> kanzi::connect::ServiceRuntimeData::ModifiedSubscriptionToken |
Token type that can be used to identify the change subscription.
|
explicit |
Runtime data of a service.
domain | the domain where the runtime data operates in. |
settingFactory | factory to access persistence service |
|
explicit |
Runtime data of a service.
domain | the domain where the runtime data operates in. |
settingFactory | factory to access persistence service |
service_name | the service name to which the runtime data belongs to |
|
virtual |
ModifiedSubscriptionToken kanzi::connect::ServiceRuntimeData::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. |
ModifiedSubscriptionToken kanzi::connect::ServiceRuntimeData::addModifiedNotificationHandlerEx | ( | ModifiedCallback * | callback | ) |
Subscribes to modification notifications within this object.
callback | the callback interface whom method is to be called on change. |
bool kanzi::connect::ServiceRuntimeData::createElement | ( | const string & | parentPath, |
const string & | xml ) |
Create a new element to the runtime data in the given path.
parentPath | Specifies where to add the new element. |
xml | Contains the xml defining the element contents |
|
protected |
Create a method or event for a writable or method-readable runtime data.
parentPath | parent path of the given element |
element | the element contains runtime data contents |
operation | "set","get","notify" |
node | The node which processes the method arguments when called |
RuntimeDataObjectBoolSharedPtr kanzi::connect::ServiceRuntimeData::getBoolObject | ( | const string & | path | ) | const |
Retrieve boolean object at specific path.
path | full path to object to retrieve. |
bool kanzi::connect::ServiceRuntimeData::getBoolValue | ( | const string & | path, |
bool | defaultValue = false ) |
Retrieve boolean value from runtime data parameter.
path | identify the data object. |
defaultValue | value to return in case named parameter not found. |
RuntimeDataObjectIntSharedPtr kanzi::connect::ServiceRuntimeData::getIntObject | ( | const string & | path | ) | const |
Retrieve int object at specific path.
path | full path to object to retrieve. |
int kanzi::connect::ServiceRuntimeData::getIntValue | ( | const string & | path, |
int | defaultValue = 0 ) |
Retrieve int value from runtime data parameter.
path | identify the data object. |
defaultValue | value to return in case named parameter not found. |
size_t kanzi::connect::ServiceRuntimeData::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.
path | the path to list to inspect |
RuntimeDataObjectListSharedPtr kanzi::connect::ServiceRuntimeData::getListObject | ( | const string & | path | ) | const |
Retrieve list object at specific path.
path | full path to object to retrieve. |
RuntimeDataObjectSharedPtr kanzi::connect::ServiceRuntimeData::getObject | ( | const string & | path | ) | const |
Retrieves object.
path | Full path to object |
|
protected |
Retrieves object.
path | Full path to object |
passLists | if true, then also lists are gone through |
RuntimeDataObject::Type kanzi::connect::ServiceRuntimeData::getObjectType | ( | const string & | path | ) | const |
Retrieves the type of the object at specific path.
path | Full path to object. |
RuntimeDataObjectRealSharedPtr kanzi::connect::ServiceRuntimeData::getRealObject | ( | const string & | path | ) | const |
Retrieve real object at specific path.
path | full path to object to retrieve. |
double kanzi::connect::ServiceRuntimeData::getRealValue | ( | const string & | path, |
double | defaultValue = 0 ) |
Retrieve real value from runtime data parameter.
path | identify the data object. |
defaultValue | value to return in case named parameter not found. |
RuntimeDataObjectSharedPtr kanzi::connect::ServiceRuntimeData::getRoot | ( | ) |
Retrieve the root node.
const string & kanzi::connect::ServiceRuntimeData::getSchema | ( | ) |
Returns the data schema in XML.
const string & kanzi::connect::ServiceRuntimeData::getServiceName | ( | ) | const |
Retrieves the service name to which the runtime data belongs.
RuntimeDataObjectStringSharedPtr kanzi::connect::ServiceRuntimeData::getStringObject | ( | const string & | path | ) | const |
Retrieve string object at specifi path.
path | full path to object to retrieve. |
string kanzi::connect::ServiceRuntimeData::getStringValue | ( | const string & | path, |
string | defaultValue = "" ) |
Retrieve string value from runtime data parameter.
path | identify the data object. |
defaultValue | value to return in case named parameter not found. |
bool kanzi::connect::ServiceRuntimeData::hasObject | ( | const string & | path | ) | const |
Checks whether object exists in specific path.
path | Full path to object, using dotted format First.Second.Third |
void kanzi::connect::ServiceRuntimeData::invalidateSchema | ( | ) |
Purge XML Schema cache. When a schema is requested next time, the tree structure is to be scanned.
void kanzi::connect::ServiceRuntimeData::notifyModified | ( | string | path = "" | ) |
Notifies subscriptions when the content changes.
Framework reports changed values to clients asynchronously if an instance of ConnectDomainSharedPtr 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.
path | the path that needs to be reported. |
bool kanzi::connect::ServiceRuntimeData::parseFromXML | ( | const string & | serviceIdentifier, |
const string & | xml ) |
Parses the structure from a XML file.
serviceIdentifier | Identifies the service for which the runtime data belongs to |
xml | structure |
bool kanzi::connect::ServiceRuntimeData::parseFromXMLElement | ( | const tinyxml2::XMLElement * | element | ) |
Parses structure from xml structure.
element | the element whom childs are to be enumerated |
bool kanzi::connect::ServiceRuntimeData::processMessage | ( | const MessagePackage & | message, |
shared_ptr< GenericRPCReplyMessage > & | ret ) |
Offer received message directly to service to implement a short path for scripts and built-in methods. Intended for internal use.
|
protected |
Processes a single node during construction.
element | the element to process |
parent | parent node |
|
protected |
Processes a single node during construction.
element | the element to process |
parent | parent node |
createMethod | if true, create method for writable runtime data |
bool kanzi::connect::ServiceRuntimeData::removeElement | ( | const string & | path | ) |
Remove the given element from the runtime data, removes intermediate elements if they become empty.
path | Identifies the element to remove |
void kanzi::connect::ServiceRuntimeData::removeMethodRecursive | ( | const string & | path | ) |
Remove all existing methods under the given path.
void kanzi::connect::ServiceRuntimeData::removeModifiedNotificationHandler | ( | ModifiedSubscriptionToken | token | ) |
Allows to unsubscribe from modifications in this data context.
token | Token to identify the subscription that should be removed. |
bool kanzi::connect::ServiceRuntimeData::setSerializedValue | ( | const string & | path, |
const string & | serializedValue ) |
Set value for a runtime data parameter.
path | identify the data object |
serializedValue | new value to set in serialized format, it will deserialized based on the type of path target. |
bool kanzi::connect::ServiceRuntimeData::setValue | ( | const string & | path, |
bool | value ) |
Set value for a runtime data parameter.
path | identify the data object |
value | new value to set. |
bool kanzi::connect::ServiceRuntimeData::setValue | ( | const string & | path, |
const char * | value ) |
Set value for a runtime data parameter.
path | identify the data object |
value | new value to set. |
bool kanzi::connect::ServiceRuntimeData::setValue | ( | const string & | path, |
double | value ) |
Set value for a runtime data parameter.
path | identify the data object |
value | new value to set. |
bool kanzi::connect::ServiceRuntimeData::setValue | ( | const string & | path, |
int | value ) |
Set value for a runtime data parameter.
path | identify the data object |
value | new value to set. |
bool kanzi::connect::ServiceRuntimeData::setValue | ( | const string & | path, |
string | value ) |
Set value for a runtime data parameter.
path | identify the data object |
value | new value to set. |
|
protected |
Processes a node tree and checks that it does not contain duplicate hash values that might collide.
object | identifier. |