ServiceRuntimeDataRegistry

class kanzi::connect::ServiceRuntimeDataRegistry : public VirtualFileProvider

Encapsulates service runtime data.

Public Types

typedef shared_ptr<void> ContentRegistrationToken
typedef shared_ptr<void> ContentSubscriptionToken
typedef function<void(const string&, const string&)> RuntimeContentUpdateCallback

Public Functions

ServiceRuntimeDataRegistry(ConnectDomain *domain = nullptr, DiagnosticsManagerSharedPtr diagnostics = DiagnosticsManagerSharedPtr())

C++ constructor.

Parameters
  • domain: the connect domain (optional)

  • diagnostics: diagnostics functionality for traffic logging etc.

RuntimeDataObjectSharedPtr getRootObjectForRegistration(ContentRegistrationToken token)

Retrieves the root object associated with the specific content registration token.

Return

shared pointer to root node. Should not ever be empty pointer.

Parameters
  • token: the content registration token

RuntimeDataObjectSharedPtr getRootObjectForSubscription(ContentSubscriptionToken token)

Retrieves the root object associated with the specific content listener token.

Return

shared pointer to root node. Can be empty pointer.

Parameters
  • token: the token to query

const string getSchemaForSubscription(ContentSubscriptionToken token)

Retrieve XML format schema for content subscription.

Return

XML format schema. Or empty string if unable to retrieve.

Parameters
  • token: identifies the subscription

void initializeHTTP()

Initializes HTTP Functionality.

Must be called after HTTP Functionality itself has been initialized.

ContentSubscriptionToken registerContentListener(const string &path, RuntimeContentUpdateCallback callback)

Registers runtime content listener to a specific path.

Return

handle that can later on be used to unregister content listener.

Parameters
  • path: where to register.

ContentRegistrationToken registerContentProducer(const string &servicename, const string &xml)

Registers a content producer from XML schema definition.

This is used with remote services.

Return

handle to object that can later on be used to.

Parameters
  • servicename: name of the service

  • xml: xml contents

ContentRegistrationToken registerContentProducer(const string &servicename, RuntimeDataObjectSharedPtr dataRoot, const string &schema)

Registers a content producer, aka a service.

Return

handle to object that can later on be used to.

Parameters
  • servicename: The name of the service.

  • dataRoot: The root object.

bool renameContentProducer(const string &oldname, const string &newname)

Renames a content producer.

Required for example by simulator when service models name is changed

Return

true if succeeded, false otherwise.

Parameters
  • oldname: the old name.

  • newname: the new name.

void uninitializeHTTP()

Uninitialize HTTP Functionality.

void unregisterContentListener(ContentSubscriptionToken token)

Unregisters content listener.

Parameters
  • token: what to unregister.

void unregisterContentProducer(ContentRegistrationToken handle)

Unregister content producer.

Parameters
  • handle: the handle of operation

bool updateData(ContentRegistrationToken handle, const string &stream, const string &path)

Updates the data of a specific registration.

Return

true if update took place.

Parameters
  • handle: identifies the updated, earlier returned by registerContentProducer

  • stream: the serialized update content.

  • path: the path that was reported to be changed.

bool updateDataForPath(ContentRegistrationToken handle, const string &path)

Updates the data of specific registration and especially a specified path within it.

Return

true if update took place.

Parameters
  • handle: identifies the updated, earlier returned by registerContentProducer

  • path: the path that changed.

ServiceRuntimeDataRegistry::ContentRegistrationToken updateSchema(ContentRegistrationToken token, const string &schema)

Updates the schema at runtime.

Return

handle to new registration.

Parameters
  • token: identifies the content registration

  • schema: new xml definition of the data

ContentRegistrationToken updateSchema(ContentRegistrationToken token, RuntimeDataObjectSharedPtr dataRoot, const string &schema)

Changes the runtime data schema.

Parameters
  • token: the token that identifies the previously registered content producer

  • dataRoot: the root object.

  • schema: the xml schema that defines the new structure.

Public Members

bool m_active

True if data should be distributed.

DiagnosticsManagerSharedPtr m_diagnostics

Diagnostics manager.

ConnectDomain *m_domain

The domain.

VirtualFileLocalClientSharedPtr m_HTTPClient

HTTP Client for HTTP Communications.

VirtualFileClient::RegistrationToken m_HTTPSchemaToken

HTTP Schema token.

VirtualFileClient::RegistrationToken m_HTTPToken

HTTP registration token.