Abstract base class that abstracts the origin of the service and simplifies the service management. More...
#include <service_host.hpp>
Public Types | |
typedef function< void(ServiceHost *, RuntimeDataObjectSharedPtr) | ConfigurationPropertyChangedCallback) |
Callback prototype to invoke when service configuration properties change. | |
Public Member Functions | |
virtual AbstractSessionSharedPtr | acquireSession (ConnectedClientSharedPtr client, int sessionId)=0 |
Creates a session to this service. | |
virtual void | changeType (const string &type)=0 |
Changes the interface name at runtime. | |
virtual int | clientID () const =0 |
Returns the client identifier. | |
virtual int | countSessions () const =0 |
Returns amount of sessions towards this service. | |
virtual void | ensureDomain (ConnectDomainSharedPtr domain) |
Ensure that service instance (if local) has domain set. | |
virtual ClientDescriptorSharedPtr | getClientDescriptor ()=0 |
Return the client descriptor. | |
virtual RuntimeDataObjectSharedPtr | getConfigurationProperties ()=0 |
Retrieve service configuration properties. | |
virtual const AbstractService::ServiceDescription & | getDescription ()=0 |
Retrieve the service description from service host. | |
virtual const string | getHash () |
virtual string | getIdentifier () const =0 |
Retrieve interface identifier. | |
virtual RuntimeDataObject * | getRuntimeData () |
Internal API for across service scripting, not for public use. | |
virtual AbstractServiceSharedPtr | getService () const =0 |
Returns a service instance. | |
virtual const string | getServiceDescriptionSchema (bool details=false) |
Retrieve service description schema. | |
virtual string | getServiceRoutingInformationDescription (int serverclientid)=0 |
Must be overridden by the corresponding implementation. | |
virtual shared_ptr< ServiceServiceConcept::Session > | getServiceSession () const =0 |
Returns a session to remote service. | |
virtual const AbstractService::ServiceState & | getState ()=0 |
Retrieve the service state information. | |
virtual void | initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue)=0 |
Initialize the service. | |
virtual bool | local () const =0 |
Is this service local or not. | |
virtual void | notifyAll (const MessagePackage &event) |
Internal API for across service scripting, not for public use. | |
virtual void | notifyClientDisconnected (int clientId)=0 |
Invoked to inform that specific client has disconnected. | |
virtual void | receiveMessage (ConnectedClientSharedPtr client, const MessagePackage &message)=0 |
Invoked for each message this service should handle. | |
virtual bool | registerServiceRuntimeData (const string schema="") |
Invoked to register service runtime data. | |
virtual bool | registerServiceRuntimeDataSchemaChange (const string &xml) |
Invoked to change runtime data schema at runtime. | |
virtual void | releaseSession (int clientId, int sessionId)=0 |
Releases a session. | |
virtual bool | reportServiceRuntimeData (const string &path, const string &stream) |
Can be called, mainly for remote services, to inform about new service information that was received. | |
ServiceHost (ServiceRuntimeDataRegistrySharedPtr registry=ServiceRuntimeDataRegistrySharedPtr()) | |
C++ constructor. | |
virtual void | setConfigurationProperties (RuntimeDataObjectSharedPtr properties) |
Stores service configuration properties. | |
virtual void | setConfigurationPropertyChangedCallback (ConfigurationPropertyChangedCallback callback) |
Install a callback to be invoked when configuration property changes. | |
virtual void | setHash (const string hash) |
virtual void | setState (const AbstractService::ServiceState &state)=0 |
Sets the service state. | |
bool | subscribeForRuntimeDataSchemaChanges (GenericSyncObserver<> &observer) |
Start getting notifications of runtime data schema changes. | |
virtual void | uninitialize ()=0 |
cleanup the service. | |
bool | unsubscribeForRuntimeDataSchemaChanges (GenericSyncObserver<> &observer) |
Stop receiving notifications of runtime data schema changes. | |
virtual void | work (ConnectWorkItemSharedPtr workItem)=0 |
Routine that get(s) called periodically or especially when object itself has requested it to be called using the work queue. | |
virtual | ~ServiceHost () |
Destructor. | |
Protected Member Functions | |
virtual void | getServiceDescriptionSchemaImpl (string &output)=0 |
Sub class specific implementation to fetch the service description. | |
Protected Attributes | |
ConfigurationPropertyChangedCallback | m_configurationPropertyChangedCallback |
unique_ptr< RuntimeDataChildChangeMonitor > | m_configurationPropertyChangeMonitor |
ServiceRuntimeDataRegistry::ContentRegistrationToken | m_runtimeDataRegistrationToken |
ServiceRuntimeDataRegistrySharedPtr | m_runtimeDataRegistry |
Runtime data registry for convenient access. | |
GenericSyncPublisher | m_runtimeDataSchemaChangePublisher |
Publisher to use when runtime data schema changes within the ServiceHost. | |
AbstractService::RuntimeDataSchemaChangeSubscriptionToken | m_runtimeDataSchemaChangeSubscriptionToken |
Abstract base class that abstracts the origin of the service and simplifies the service management.
Services can be hosted locally in server or remotely in client. This class simplifies the server-side service management by abstracting the actual origin of the service. See LocalServiceHost and RemoteServiceHost for local and remote variants.
typedef function<void(ServiceHost*, RuntimeDataObjectSharedPtr) kanzi::connect::ServiceHost::ConfigurationPropertyChangedCallback) |
Callback prototype to invoke when service configuration properties change.
|
inline |
C++ constructor.
registry | runtime data registry. |
|
virtual |
Destructor.
|
pure virtual |
Creates a session to this service.
client | identifies the client. |
sessionId | identifies the session. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Changes the interface name at runtime.
type | new type for the interface. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Returns the client identifier.
Relevant only for remote clients. Will return -1 for local clients.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Returns amount of sessions towards this service.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
inlinevirtual |
Ensure that service instance (if local) has domain set.
If not set earlier will put the provided domain.
domain | which domain to put the service in case not previously bind. |
|
pure virtual |
Return the client descriptor.
Relevant only for remote services.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Retrieve service configuration properties.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Retrieve the service description from service host.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
virtual |
|
pure virtual |
Retrieve interface identifier.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
inlinevirtual |
Internal API for across service scripting, not for public use.
Request a pointer to service host runtime data. Returned data (if any) may be a mirror to a service registry so modifying values here may not be visible for the hosted service itself.
Reimplemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Returns a service instance.
Relevant only for local services.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
virtual |
Retrieve service description schema.
details | if true more detailed description is provided. if false then only limited set of information that kanzi studio can handle is provided. |
|
protectedpure virtual |
Sub class specific implementation to fetch the service description.
output | The target to set the description to |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Must be overridden by the corresponding implementation.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Returns a session to remote service.
Relevant only for remote services.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Retrieve the service state information.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Initialize the service.
domain | environment where the service is run in. |
contentClient | access to content system |
workQueue | interface to work queue used to dispatch work service is ready will eventually cause the services work() method to be invoked. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Is this service local or not.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
inlinevirtual |
Internal API for across service scripting, not for public use.
Notify all client sessions with message.
Reimplemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Invoked to inform that specific client has disconnected.
clientId | Identifies the client. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
pure virtual |
Invoked for each message this service should handle.
client | identifies the message sender |
message | the message to process. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
virtual |
Invoked to register service runtime data.
schema | the schema (xml) |
|
virtual |
Invoked to change runtime data schema at runtime.
xml | the xml structure |
|
pure virtual |
Releases a session.
clientId | identifies the client |
sessionId | identifies the session |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
inlinevirtual |
Can be called, mainly for remote services, to inform about new service information that was received.
Reimplemented in kanzi::connect::RemoteServiceHost.
|
inlinevirtual |
Stores service configuration properties.
Default implementation is empty, should be overridden by the remote service host implementation
properties | data object describing the properties. |
Reimplemented in kanzi::connect::RemoteServiceHost.
|
virtual |
Install a callback to be invoked when configuration property changes.
callback | to be invoked. |
|
virtual |
|
pure virtual |
Sets the service state.
Relevant only for remote clients.
state | new state for remote clients. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
bool kanzi::connect::ServiceHost::subscribeForRuntimeDataSchemaChanges | ( | GenericSyncObserver<> & | observer | ) |
Start getting notifications of runtime data schema changes.
observer | The instance which will start receiving notifications |
|
pure virtual |
cleanup the service.
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
bool kanzi::connect::ServiceHost::unsubscribeForRuntimeDataSchemaChanges | ( | GenericSyncObserver<> & | observer | ) |
Stop receiving notifications of runtime data schema changes.
observer | The instance which will stop receiving notifications |
|
pure virtual |
Routine that get(s) called periodically or especially when object itself has requested it to be called using the work queue.
workItem | Item to be processed. |
Implemented in kanzi::connect::LocalServiceHost, and kanzi::connect::RemoteServiceHost.
|
protected |
|
protected |
|
protected |
|
protected |
Runtime data registry for convenient access.
|
protected |
Publisher to use when runtime data schema changes within the ServiceHost.
|
protected |