Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::AbstractService Class Referenceabstract

Abstract base class for Kanzi Connect services. More...

#include <abstract_service.hpp>

Inheritance diagram for kanzi::connect::AbstractService:
kanzi::connect::ExternalServiceAdapter

Classes

class  ServiceDescription
 
class  ServiceState
 

Public Types

typedef map< string, EnumValuesEnumMap
 
typedef map< string, int > EnumValues
 
enum  InvokableOperationResult {
  Success = 0, AlreadyExists = -1, ValidationFailed = -2, NotFound = -3,
  NotReady = -4
}
 
typedef function< void(AbstractService *)> RuntimeDataSchemaChangeCallback
 Callback prototype to be invoked when runtime data schema changes. More...
 
typedef shared_ptr< void > RuntimeDataSchemaChangeSubscriptionToken
 Handle given as return value to runtime data schema change callback registration. More...
 
enum  ServiceControlResult { ServiceControlSuccess, ServiceControlFailed, ServiceControlNotSupported }
 
typedef enum kanzi::connect::AbstractService::ServiceControlResult ServiceControlResult
 
enum  ServiceControlSource { ServiceControlSourceManual, ServiceControlSourceLogic }
 
typedef enum kanzi::connect::AbstractService::ServiceControlSource ServiceControlSource
 
typedef vector< AbstractSessionSharedPtrSessionContainer
 Container type for all connected sessions. More...
 
typedef function< void(AbstractService *)> StateCallbackFunction
 Function prototype to be invoked when state changes. More...
 
typedef shared_ptr< void > StateChangedSubscriptionToken
 Handle given as return value to state callback registration. More...
 

Public Member Functions

 AbstractService ()
 Constructor. More...
 
AbstractSessionSharedPtr acquireSession (int clientId, int sessionId, MessageDispatcher *dispatcher, const string &instanceName)
 Session factorization method. More...
 
virtual InvokableOperationResult addCustomType (const string &xml)
 Add a custom type to the service. More...
 
virtual InvokableOperationResult addCustomTypeDecoded (const string &decodedXml)
 Add a custom type to the service. More...
 
virtual int addEvent (const string &identifier, const string &description)
 
virtual int addMethod (const string &identifier, const string &description)
 
virtual int addProperty (const string &identifier, const string &description)
 
virtual InvokableOperationResult addRoute (const string &xml)
 Add new P2P route(s) for the service. More...
 
virtual InvokableOperationResult addRouteDecoded (const string &decodedXml)
 Add new P2P route(s) for the service. More...
 
RuntimeDataSchemaChangeSubscriptionToken addRuntimeDataSchemaChangeSubscription (RuntimeDataSchemaChangeCallback function)
 Adds a callback to invoke when runtime data schema changes. More...
 
StateChangedSubscriptionToken addStateChangeSubscription (StateCallbackFunction function)
 Adds a state change callback subscription. More...
 
bool addSubscription (const string &identifier, AbstractSessionSharedPtr session)
 Add subscription to the given session for this service. More...
 
virtual void cancelTimer (int64_t timerId)
 Cancels ongoing timer. More...
 
int countSessions () const
 Amount of allocated sessions. More...
 
size_t countSessions ()
 Return the amount of sessions towards this service amount of sessions. More...
 
virtual InvokableOperationResult createRuntimedata (const string &parentIdentifier, const string &xml)
 Create a new runtime data element for the service runtime data. More...
 
EnumMap::const_iterator enumerationValuesBegin ()
 
EnumMap::const_iterator enumerationValuesEnd ()
 
vector< AbstractSessionSharedPtrfindSubscribers (const string &identifier)
 Find all subscribers for the given identifier. More...
 
const SessionContainergetAllSessions () const
 Returns all currently active sessions. More...
 
SessionContainer getAllSessionsOfClient (int clientId)
 Returns all sessions for a given client. More...
 
KanziStringVectorSharedPtr getAttributes ()
 Lists all service attributes. More...
 
RuntimeDataObjectSharedPtr getConfigurationProperties ()
 Retrieves configuration properties as a runtime data object to allow more convenient access to data. More...
 
ContentClientSharedPtr getContentClient () const
 Access to content system. More...
 
virtual ContentProviderCollectionSharedPtr getContentProvider ()
 Returns content provider for this service. More...
 
const vector< unique_ptr< CustomType > > & getCustomTypes () const
 Get the custom types defined for this service. More...
 
KanziStringVectorSharedPtr getDisabledInvokables ()
 
ConnectDomaingetDomain () const
 Retrieves the connect domain. More...
 
optional< int > getEnumValue (const string &name, const string &enumerator)
 Find out value for enumeration string. More...
 
ServiceExtensionContainergetExtensions ()
 
string getFullyQualifiedConfigurationPropertyName (const string &name)
 Constructs a fully qualified configuration property name, usually the fully qualified name is something like "Connect.Service.MyService.ConfigurationProperties.MyPropertyName". More...
 
virtual GenericInvokergetGenericInvoker ()
 Retrieve a generic invoker bound to this service. More...
 
virtual string getIdentifier () const =0
 
InterfaceDomainBasegetInterfaceDomain () const
 Access to interface domain. More...
 
virtual RuntimeDataObjectSharedPtr getModifiedConfigurationProperties ()
 Retrieves modified configuration properties as runtime data object. More...
 
virtual string getName ()
 Returns the override name. More...
 
WorkQueueInterfacegetProxyWorkQueue ()
 Returns a proxied work queue instance that can be used by composited classes to to assign work to this service. More...
 
AbstractSessionSharedPtr getRunningSession ()
 
virtual string getSchema ()
 Returns service schema in XML format. More...
 
virtual const ServiceDescriptiongetServiceDescription () const
 Access the static service description info. More...
 
virtual p2p::RoutingRulesSharedPtr getServiceRoutingInformation ()
 Return service routing information. More...
 
virtual const ServiceStategetServiceState () const
 Gets service state information. More...
 
AbstractSessionSharedPtr getSession (int clientId, int sessionId)
 Returns session by client & session id. More...
 
int getStopInterval () const
 Retrieve service stop interval. More...
 
WorkQueueInterfacegetWorkQueue () const
 Access to signal that allows to invoke work(). More...
 
bool hasEnumValues (const string &name)
 Checks if enum has been defined on this service. More...
 
bool hasSubscriptions (const string &identifier)
 Check if the given identifier has any subscriptions. More...
 
virtual void initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue)
 Initialize this service. More...
 
bool manualPersistenceOverride () const
 Defines whether manual persistence override is active, i.e. More...
 
virtual AbstractSessionSharedPtr onAcquireSession (int clientId, int sessionId, MessageDispatcher *dispatcher, const string &instanceName)=0
 Session factorization method interface. More...
 
virtual void onReleaseSession (AbstractSessionSharedPtr session)
 Virtual method that inheriting classes can implement. More...
 
void releaseAllSessions ()
 Unconditionally releases all sessions. use carefully. More...
 
void releaseSession (AbstractSessionSharedPtr session)
 Releases previously allocated session. More...
 
virtual InvokableOperationResult removeCustomType (const string &typeName)
 Remove a custom type from a service. More...
 
virtual int removeEvent (const string &identifier)
 
virtual int removeMethod (const string &identifier)
 
virtual int removeProperty (const string &identifier)
 
virtual InvokableOperationResult removeRoute (const string &subjectName)
 Remove a route from a service. More...
 
virtual InvokableOperationResult removeRuntimedataElement (const string &elementIdentifier)
 Remove runtime data element from the service runtime data. More...
 
void removeRuntimeDataSchemaChangeSubscription (RuntimeDataSchemaChangeSubscriptionToken token)
 Remove schema change subscription. More...
 
void removeStateChangeSubscription (StateChangedSubscriptionToken token)
 Remove state change subscription. More...
 
vector< string > removeSubscriptions (AbstractSessionSharedPtr session, const string &identifier="")
 Remove subscription to the given session for this service. More...
 
AbstractService::ServiceControlResult resetService (ServiceArgumentsSharedPtr arguments)
 Tries to reset service. More...
 
bool runScript (const MessagePackage &message, AbstractSessionSharedPtr session, shared_ptr< GenericRPCReplyMessage > &ret)
 Run a script using configured script plugin. Intended for internal use. More...
 
ServiceRuntimeDataruntimeData ()
 Retrieve service runtime data. More...
 
void setAttribute (const string &key, const string &value)
 Add service attributes as key value pairs. More...
 
void setDomain (ConnectDomain *domain)
 Set the connect domain. More...
 
void setFileClient (VirtualFileClient *client)
 Set the client instance to access VirtualFileService. More...
 
virtual void setName (const string &name)
 Defines a override name used to identify the service. More...
 
void setPersistence (AbstractService::ServiceDescription::Persistence persistence)
 Sets the service persistence. More...
 
virtual void setRunningSession (AbstractSessionSharedPtr session)
 Stores the currently running session. More...
 
virtual InvokableOperationResult setRuntimedataValue (const string &elementIdentifier, const string &value)
 Set runtime data value for the given element in the service runtime data. More...
 
bool setServiceRuntimeDataSchema (const string &xml)
 Set service runtime data schema. More...
 
void setServiceState (AbstractService::ServiceState state)
 sets service state information. More...
 
void setServiceVersion (AbstractService::ServiceDescription::Version version, AbstractService::ServiceDescription::Version minCompatibleVersion=AbstractService::ServiceDescription::Version())
 Configures the service version information. More...
 
void setSettingFactory (const persistence::SettingFactory *factory)
 Set the setting factory instance to allow using persistence service. More...
 
void setStopInterval (int seconds)
 Configures the stop interval. More...
 
virtual int64_t setTimer (int64_t milliseconds, ConnectWorkItem::Executor callback)
 Installs a timer to be called after a specified timeout in milliseconds. More...
 
virtual int64_t setTimer (int64_t milliseconds, ConnectWorkItem::Executor callback, ConnectWorkItem::ExecutionContext executionContext)
 Installs a timer to be called after a specified timeout in milliseconds. More...
 
bool simulateEvent (const string &messageName, const MessagePackage &message)
 Post a message to all running sessions as event. Intended for internal use. More...
 
AbstractService::ServiceControlResult startService (ServiceControlSource serviceControlSource, ServiceArgumentsSharedPtr arguments)
 Tries to start the service. More...
 
AbstractService::ServiceControlResult stopService (ServiceControlSource serviceControlSource)
 Tries to stop the service. More...
 
virtual void uninitialize ()
 Uninitialize this service. More...
 
virtual void work (ConnectWorkItemSharedPtr workItem)
 Asks service to perform work. More...
 
virtual ~AbstractService ()
 Destructor. More...
 

Protected Member Functions

void addEnumValue (const string &name, const string &enumerator, int value)
 Store value for enumeration string. More...
 
VirtualFileClientgetFileClient () const
 Get instance to access the VirtualFileService. More...
 
ScriptContextSharedPtr getScriptContext ()
 Get shared script context. More...
 
const persistence::SettingFactory * getSettingFactory () const
 Get the setting factory instance. More...
 
void notifyRuntimeSchemaChange ()
 Notify all observers that service schema has changed. More...
 
virtual void notifyWork ()
 Allows the derived class to invoke work(). More...
 
virtual void notifyWork (ConnectWorkItemSharedPtr workItem)
 Called notify that this service would have a work item to be processed later on. More...
 
void notifyWork (const ConnectWorkItem::Executor executor)
 Call to notify that provided executor should be run the kanzi connect main thread context. More...
 
virtual void notifyWork (ConnectWorkItemSharedPtr workItem, const ConnectWorkItem::Executor executor)
 Called to notify this service has work to do and for that work use the attached executor. More...
 
virtual AbstractService::ServiceControlResult onResetServiceRequest (ServiceArgumentsSharedPtr arguments)
 Inherited classes should implements this method that is invoked when service is requested to reset itself. More...
 
virtual AbstractService::ServiceControlResult onStartServiceRequest (ServiceArgumentsSharedPtr arguments)
 Inherited classes should implement this method that is invoked when service is to be started. More...
 
virtual AbstractService::ServiceControlResult onStopServiceRequest ()
 Inherited classes should implement this method that is invoked when service is to be stopped. More...
 
bool prepareScriptContext ()
 Prepare script plugin for use. More...
 
virtual string provideServiceRoutingInformationOverride ()
 Service should override this in order to provide a custom routing information structure. More...
 
virtual string provideServiceRuntimeDataOverride ()
 Service should override this in order to provide a runtime data structure. More...
 
void setConfigurationPropertyPrefix (const string &prefix)
 Configures the configuration property name prefix used to build fully qualified configuration property names. More...
 
bool writeConfigurationPropertyInternal (const string &stream)
 Writes a configuration property value. More...
 

Detailed Description

Abstract base class for Kanzi Connect services.

Member Typedef Documentation

◆ EnumMap

◆ EnumValues

◆ RuntimeDataSchemaChangeCallback

Callback prototype to be invoked when runtime data schema changes.

◆ RuntimeDataSchemaChangeSubscriptionToken

Handle given as return value to runtime data schema change callback registration.

◆ ServiceControlResult

◆ ServiceControlSource

◆ SessionContainer

Container type for all connected sessions.

◆ StateCallbackFunction

Function prototype to be invoked when state changes.

◆ StateChangedSubscriptionToken

Handle given as return value to state callback registration.

Member Enumeration Documentation

◆ InvokableOperationResult

Enumerator
Success 
AlreadyExists 
ValidationFailed 
NotFound 
NotReady 

◆ ServiceControlResult

Enumerator
ServiceControlSuccess 
ServiceControlFailed 
ServiceControlNotSupported 

◆ ServiceControlSource

Enumerator
ServiceControlSourceManual 
ServiceControlSourceLogic 

Constructor & Destructor Documentation

◆ AbstractService()

kanzi::connect::AbstractService::AbstractService ( )

Constructor.

◆ ~AbstractService()

virtual kanzi::connect::AbstractService::~AbstractService ( )
virtual

Destructor.

Member Function Documentation

◆ acquireSession()

AbstractSessionSharedPtr kanzi::connect::AbstractService::acquireSession ( int  clientId,
int  sessionId,
MessageDispatcher dispatcher,
const string &  instanceName 
)

Session factorization method.

Parameters
clientIdclient identifier number
sessionIdsession identifier number
dispatchermessage dispatching functionality for the session.
instanceNamename for the service/session instance
Returns
newly allocated session. ownership not transfered.

◆ addCustomType()

virtual InvokableOperationResult kanzi::connect::AbstractService::addCustomType ( const string &  xml)
virtual

Add a custom type to the service.

Parameters
xmlContains the xml definition for the custom type
Returns
InvokableOperationResult defining the success

◆ addCustomTypeDecoded()

virtual InvokableOperationResult kanzi::connect::AbstractService::addCustomTypeDecoded ( const string &  decodedXml)
virtual

Add a custom type to the service.

Parameters
decodedXmlContains the xml definition for the custom type in clear xml without base64 encoding
Returns
InvokableOperationResult defining the success

◆ addEnumValue()

void kanzi::connect::AbstractService::addEnumValue ( const string &  name,
const string &  enumerator,
int  value 
)
protected

Store value for enumeration string.

Overwrites existing value if one exists.

Parameters
nameName of the enum definition.
enumeratorEnumerator string, identifies the value
valueValue to be stored.

◆ addEvent()

virtual int kanzi::connect::AbstractService::addEvent ( const string &  identifier,
const string &  description 
)
virtual

◆ addMethod()

virtual int kanzi::connect::AbstractService::addMethod ( const string &  identifier,
const string &  description 
)
virtual

◆ addProperty()

virtual int kanzi::connect::AbstractService::addProperty ( const string &  identifier,
const string &  description 
)
virtual

◆ addRoute()

virtual InvokableOperationResult kanzi::connect::AbstractService::addRoute ( const string &  xml)
virtual

Add new P2P route(s) for the service.

Parameters
xmlContains the xml definition for the route
Returns
InvokableOperationResult defining the success

◆ addRouteDecoded()

virtual InvokableOperationResult kanzi::connect::AbstractService::addRouteDecoded ( const string &  decodedXml)
virtual

Add new P2P route(s) for the service.

Parameters
decodedXmlContains the xml definition for the route
Returns
InvokableOperationResult defining the success

◆ addRuntimeDataSchemaChangeSubscription()

RuntimeDataSchemaChangeSubscriptionToken kanzi::connect::AbstractService::addRuntimeDataSchemaChangeSubscription ( RuntimeDataSchemaChangeCallback  function)

Adds a callback to invoke when runtime data schema changes.

Parameters
functionfunction to be called on schema change.
Returns
token that can be used to remove subscription
Note
It is not allowed to destroy the service from the registered callback.

◆ addStateChangeSubscription()

StateChangedSubscriptionToken kanzi::connect::AbstractService::addStateChangeSubscription ( StateCallbackFunction  function)

Adds a state change callback subscription.

Parameters
functionfunction to be called on state change
Returns
token that can be used to remove subscription
Note
It is not allowed to destroy the service from the registered callback.

◆ addSubscription()

bool kanzi::connect::AbstractService::addSubscription ( const string &  identifier,
AbstractSessionSharedPtr  session 
)

Add subscription to the given session for this service.

Parameters
identifierIdentifies the subscription, what this means is implementation specific
sessionThe session to subscribe
Returns
True if subscription was added successfully, double subscription is not accepted

◆ cancelTimer()

virtual void kanzi::connect::AbstractService::cancelTimer ( int64_t  timerId)
virtual

Cancels ongoing timer.

Parameters
timerIdidentifier returned by the setTimer function.

◆ countSessions() [1/2]

int kanzi::connect::AbstractService::countSessions ( ) const

Amount of allocated sessions.

Returns
amount of sessions

◆ countSessions() [2/2]

size_t kanzi::connect::AbstractService::countSessions ( )

Return the amount of sessions towards this service amount of sessions.

◆ createRuntimedata()

virtual InvokableOperationResult kanzi::connect::AbstractService::createRuntimedata ( const string &  parentIdentifier,
const string &  xml 
)
virtual

Create a new runtime data element for the service runtime data.

Parameters
parentIdentifierSpecifies the parent under which create the element in the hierarchy
xmlContains the xml defining the element contents
Returns
Is the operation successful or not

◆ enumerationValuesBegin()

EnumMap::const_iterator kanzi::connect::AbstractService::enumerationValuesBegin ( )

◆ enumerationValuesEnd()

EnumMap::const_iterator kanzi::connect::AbstractService::enumerationValuesEnd ( )

◆ findSubscribers()

vector<AbstractSessionSharedPtr> kanzi::connect::AbstractService::findSubscribers ( const string &  identifier)

Find all subscribers for the given identifier.

Parameters
identifierIdentifies the subscriptions, what this means is implementation specific
Returns
vector listing all subscribers

◆ getAllSessions()

const SessionContainer& kanzi::connect::AbstractService::getAllSessions ( ) const

Returns all currently active sessions.

Returns
All sessions that are currently active.

◆ getAllSessionsOfClient()

SessionContainer kanzi::connect::AbstractService::getAllSessionsOfClient ( int  clientId)

Returns all sessions for a given client.

Parameters
clientIdId of the client.
Returns
All sessions that were acquired for given client.

◆ getAttributes()

KanziStringVectorSharedPtr kanzi::connect::AbstractService::getAttributes ( )

Lists all service attributes.

Returns
flat list of service attributes, key and value follow in subsequent entries.

◆ getConfigurationProperties()

RuntimeDataObjectSharedPtr kanzi::connect::AbstractService::getConfigurationProperties ( )

Retrieves configuration properties as a runtime data object to allow more convenient access to data.

Returns
shared pointer to runtime data containing configuration properties.

◆ getContentClient()

ContentClientSharedPtr kanzi::connect::AbstractService::getContentClient ( ) const

Access to content system.

Returns
Content client instance.

◆ getContentProvider()

virtual ContentProviderCollectionSharedPtr kanzi::connect::AbstractService::getContentProvider ( )
virtual

Returns content provider for this service.

Returns
Collection of content providers, created by this service.

Reimplemented in kanzi::connect::ExternalServiceAdapter.

◆ getCustomTypes()

const vector<unique_ptr<CustomType> >& kanzi::connect::AbstractService::getCustomTypes ( ) const

Get the custom types defined for this service.

Returns
Vector containing the custom types

◆ getDisabledInvokables()

KanziStringVectorSharedPtr kanzi::connect::AbstractService::getDisabledInvokables ( )

◆ getDomain()

ConnectDomain* kanzi::connect::AbstractService::getDomain ( ) const

Retrieves the connect domain.

Returns
the domain.

◆ getEnumValue()

optional<int> kanzi::connect::AbstractService::getEnumValue ( const string &  name,
const string &  enumerator 
)

Find out value for enumeration string.

Parameters
nameName of the enum definition. Can be empty, first matching enumerator value is returned from all enums
enumeratorEnumerator string, identifies the value
Returns
value if found.

◆ getExtensions()

ServiceExtensionContainer* kanzi::connect::AbstractService::getExtensions ( )

◆ getFileClient()

VirtualFileClient* kanzi::connect::AbstractService::getFileClient ( ) const
protected

Get instance to access the VirtualFileService.

◆ getFullyQualifiedConfigurationPropertyName()

string kanzi::connect::AbstractService::getFullyQualifiedConfigurationPropertyName ( const string &  name)

Constructs a fully qualified configuration property name, usually the fully qualified name is something like "Connect.Service.MyService.ConfigurationProperties.MyPropertyName".

Parameters
namethe name where the fully qualified name is to be composed
Returns
fully qualified configuration property name.

◆ getGenericInvoker()

virtual GenericInvoker* kanzi::connect::AbstractService::getGenericInvoker ( )
virtual

Retrieve a generic invoker bound to this service.

Lifetime of the object is the same as the service lifetime. Can be overridden by a class to rewrite functionality.

Returns
pointer to generic invoker. ownership not transfered.

Reimplemented in kanzi::connect::ExternalServiceAdapter.

◆ getIdentifier()

virtual string kanzi::connect::AbstractService::getIdentifier ( ) const
pure virtual

◆ getInterfaceDomain()

InterfaceDomainBase* kanzi::connect::AbstractService::getInterfaceDomain ( ) const

Access to interface domain.

Returns
Interface domain pointer.

◆ getModifiedConfigurationProperties()

virtual RuntimeDataObjectSharedPtr kanzi::connect::AbstractService::getModifiedConfigurationProperties ( )
inlinevirtual

Retrieves modified configuration properties as runtime data object.

Overriden by corresponding Concept class.

Returns
shared pointer to configuration properties that were modified since last called.

◆ getName()

virtual string kanzi::connect::AbstractService::getName ( )
virtual

Returns the override name.

Returns
the name that was explicitly set for the service.

◆ getProxyWorkQueue()

WorkQueueInterface* kanzi::connect::AbstractService::getProxyWorkQueue ( )

Returns a proxied work queue instance that can be used by composited classes to to assign work to this service.

Note
Returned interface will become invalid immediately when uninitialize() gets called for this Service.
Returns
pointer to interface that can be used dispatch event(s) to this particular service.

◆ getRunningSession()

AbstractSessionSharedPtr kanzi::connect::AbstractService::getRunningSession ( )
inline

◆ getSchema()

virtual string kanzi::connect::AbstractService::getSchema ( )
virtual

Returns service schema in XML format.

Returns
schema as xml.

◆ getScriptContext()

ScriptContextSharedPtr kanzi::connect::AbstractService::getScriptContext ( )
protected

Get shared script context.

Returns
Prepared script context if any.

◆ getServiceDescription()

virtual const ServiceDescription& kanzi::connect::AbstractService::getServiceDescription ( ) const
virtual

Access the static service description info.

Returns
reference to service information.

◆ getServiceRoutingInformation()

virtual p2p::RoutingRulesSharedPtr kanzi::connect::AbstractService::getServiceRoutingInformation ( )
inlinevirtual

Return service routing information.

Returns
XML format string describing the preferred routing instructions.

◆ getServiceState()

virtual const ServiceState& kanzi::connect::AbstractService::getServiceState ( ) const
virtual

Gets service state information.

Returns
the state.

◆ getSession()

AbstractSessionSharedPtr kanzi::connect::AbstractService::getSession ( int  clientId,
int  sessionId 
)

Returns session by client & session id.

Parameters
clientIdId of the client.
sessionIdId of the session.
Returns
Session that was acquired with given parameters, or 0 if there was no such session.

◆ getSettingFactory()

const persistence::SettingFactory* kanzi::connect::AbstractService::getSettingFactory ( ) const
protected

Get the setting factory instance.

◆ getStopInterval()

int kanzi::connect::AbstractService::getStopInterval ( ) const

Retrieve service stop interval.

Returns
stop interval in seconds.

◆ getWorkQueue()

WorkQueueInterface* kanzi::connect::AbstractService::getWorkQueue ( ) const

Access to signal that allows to invoke work().

Returns
The signal.

◆ hasEnumValues()

bool kanzi::connect::AbstractService::hasEnumValues ( const string &  name)

Checks if enum has been defined on this service.

Parameters
nameName of the enum definition.
Returns
True if values have been registered for the name.

◆ hasSubscriptions()

bool kanzi::connect::AbstractService::hasSubscriptions ( const string &  identifier)

Check if the given identifier has any subscriptions.

Parameters
identifierThe identifier to check, what this means is implementation specific
Returns
True if at least one subscriber is found

◆ initialize()

virtual void kanzi::connect::AbstractService::initialize ( InterfaceDomainBase domain,
ContentClientSharedPtr  contentClient,
WorkQueueInterface workQueue 
)
virtual

Initialize this service.

Parameters
domainInterface domain.
contentClientContent Client that can be used to expose runtime state of this service to clients.
workQueueInterface to system work queue used to dispatch work to services.

◆ manualPersistenceOverride()

bool kanzi::connect::AbstractService::manualPersistenceOverride ( ) const

Defines whether manual persistence override is active, i.e.

user has manually configured service to a state and thus automatic shutdown is not active.

Returns
true if current state is set manually.

◆ notifyRuntimeSchemaChange()

void kanzi::connect::AbstractService::notifyRuntimeSchemaChange ( )
protected

Notify all observers that service schema has changed.

See also
addRuntimeDataSchemaChangeSubscription
removeRuntimeDataSchemaChangeSubscription

◆ notifyWork() [1/4]

virtual void kanzi::connect::AbstractService::notifyWork ( )
protectedvirtual

Allows the derived class to invoke work().

◆ notifyWork() [2/4]

virtual void kanzi::connect::AbstractService::notifyWork ( ConnectWorkItemSharedPtr  workItem)
protectedvirtual

Called notify that this service would have a work item to be processed later on.

◆ notifyWork() [3/4]

void kanzi::connect::AbstractService::notifyWork ( const ConnectWorkItem::Executor  executor)
protected

Call to notify that provided executor should be run the kanzi connect main thread context.

Parameters
executorthe executor to be executed in main thread context.

◆ notifyWork() [4/4]

virtual void kanzi::connect::AbstractService::notifyWork ( ConnectWorkItemSharedPtr  workItem,
const ConnectWorkItem::Executor  executor 
)
protectedvirtual

Called to notify this service has work to do and for that work use the attached executor.

Parameters
workItemdescribes the work to be done
executorthe executor for work item.

◆ onAcquireSession()

virtual AbstractSessionSharedPtr kanzi::connect::AbstractService::onAcquireSession ( int  clientId,
int  sessionId,
MessageDispatcher dispatcher,
const string &  instanceName 
)
pure virtual

Session factorization method interface.

To be overrided by concrete services

Parameters
clientIdclient identifier number
sessionIdsession identifier number
dispatchermessage dispatching functionality for the session.
instanceNamename for the service/session instance
Returns
newly allocated session. ownership is transfered.

Implemented in kanzi::connect::ExternalServiceAdapter.

◆ onReleaseSession()

virtual void kanzi::connect::AbstractService::onReleaseSession ( AbstractSessionSharedPtr  session)
virtual

Virtual method that inheriting classes can implement.

Can be used to receive notifications when sessions are destroyed.

Parameters
sessionidentifies the session to be released. ownership not transfered.

Reimplemented in kanzi::connect::ExternalServiceAdapter.

◆ onResetServiceRequest()

virtual AbstractService::ServiceControlResult kanzi::connect::AbstractService::onResetServiceRequest ( ServiceArgumentsSharedPtr  arguments)
protectedvirtual

Inherited classes should implements this method that is invoked when service is requested to reset itself.

return status indicating whether reset was succeeded or not.

◆ onStartServiceRequest()

virtual AbstractService::ServiceControlResult kanzi::connect::AbstractService::onStartServiceRequest ( ServiceArgumentsSharedPtr  arguments)
protectedvirtual

Inherited classes should implement this method that is invoked when service is to be started.

Parameters
argumentspossible arguments for the service.
Returns
status indicating whether start succeeded or not.

◆ onStopServiceRequest()

virtual AbstractService::ServiceControlResult kanzi::connect::AbstractService::onStopServiceRequest ( )
protectedvirtual

Inherited classes should implement this method that is invoked when service is to be stopped.

Returns
status indicating whether stop was successful or not.

◆ prepareScriptContext()

bool kanzi::connect::AbstractService::prepareScriptContext ( )
protected

Prepare script plugin for use.

Returns
True on success, false if plugin load fails.

◆ provideServiceRoutingInformationOverride()

virtual string kanzi::connect::AbstractService::provideServiceRoutingInformationOverride ( )
protectedvirtual

Service should override this in order to provide a custom routing information structure.

Returns
XML that defines the intended routing structure of service methods, events and runtime information.

◆ provideServiceRuntimeDataOverride()

virtual string kanzi::connect::AbstractService::provideServiceRuntimeDataOverride ( )
protectedvirtual

Service should override this in order to provide a runtime data structure.

Returns
XML that defines the structure

◆ releaseAllSessions()

void kanzi::connect::AbstractService::releaseAllSessions ( )

Unconditionally releases all sessions. use carefully.

◆ releaseSession()

void kanzi::connect::AbstractService::releaseSession ( AbstractSessionSharedPtr  session)

Releases previously allocated session.

Parameters
sessionthe session to release. ownership not transfered.

◆ removeCustomType()

virtual InvokableOperationResult kanzi::connect::AbstractService::removeCustomType ( const string &  typeName)
virtual

Remove a custom type from a service.

Parameters
typeNameThe name of the type
Returns
InvokableOperationResult defining the success

◆ removeEvent()

virtual int kanzi::connect::AbstractService::removeEvent ( const string &  identifier)
virtual

◆ removeMethod()

virtual int kanzi::connect::AbstractService::removeMethod ( const string &  identifier)
virtual

◆ removeProperty()

virtual int kanzi::connect::AbstractService::removeProperty ( const string &  identifier)
virtual

◆ removeRoute()

virtual InvokableOperationResult kanzi::connect::AbstractService::removeRoute ( const string &  subjectName)
virtual

Remove a route from a service.

Parameters
subjectNameThe subject of the route (can be method name, event name or "runtimedata")
Returns
InvokableOperationResult defining the success

◆ removeRuntimedataElement()

virtual InvokableOperationResult kanzi::connect::AbstractService::removeRuntimedataElement ( const string &  elementIdentifier)
virtual

Remove runtime data element from the service runtime data.

Parameters
elementIdentifierSpecifies which element to remove
Returns
Is the operation successful or not

◆ removeRuntimeDataSchemaChangeSubscription()

void kanzi::connect::AbstractService::removeRuntimeDataSchemaChangeSubscription ( RuntimeDataSchemaChangeSubscriptionToken  token)

Remove schema change subscription.

Parameters
tokento remove.

◆ removeStateChangeSubscription()

void kanzi::connect::AbstractService::removeStateChangeSubscription ( StateChangedSubscriptionToken  token)

Remove state change subscription.

Parameters
tokento remove.

◆ removeSubscriptions()

vector<string> kanzi::connect::AbstractService::removeSubscriptions ( AbstractSessionSharedPtr  session,
const string &  identifier = "" 
)

Remove subscription to the given session for this service.

Parameters
sessionThe session whose subscriptions are to be removed
identifierThe subscriptions to remove, if empty all subscriptions for the session are removed
Returns
Vector containing identifiers that no longer have any subscriptions left after this call

◆ resetService()

AbstractService::ServiceControlResult kanzi::connect::AbstractService::resetService ( ServiceArgumentsSharedPtr  arguments)

Tries to reset service.

Returnvalue indicates the status of execution.

Parameters
argumentsoptional arguments passed along with the control request.
Returns
status indicating the success of the operation. It is up to the service to decide what "reset" means to it.

◆ runScript()

bool kanzi::connect::AbstractService::runScript ( const MessagePackage message,
AbstractSessionSharedPtr  session,
shared_ptr< GenericRPCReplyMessage > &  ret 
)

Run a script using configured script plugin. Intended for internal use.

◆ runtimeData()

ServiceRuntimeData& kanzi::connect::AbstractService::runtimeData ( )

Retrieve service runtime data.

Returns
reference to services runtime data.

◆ setAttribute()

void kanzi::connect::AbstractService::setAttribute ( const string &  key,
const string &  value 
)

Add service attributes as key value pairs.

These will be visible on service description, but don't affect runtime state

◆ setConfigurationPropertyPrefix()

void kanzi::connect::AbstractService::setConfigurationPropertyPrefix ( const string &  prefix)
protected

Configures the configuration property name prefix used to build fully qualified configuration property names.

Note
this is meant to be called only by the generated service code.
Parameters
prefixthe prefix to be stored.

◆ setDomain()

void kanzi::connect::AbstractService::setDomain ( ConnectDomain domain)

Set the connect domain.

Parameters
domainthe domain

◆ setFileClient()

void kanzi::connect::AbstractService::setFileClient ( VirtualFileClient client)

Set the client instance to access VirtualFileService.

Parameters
clientPointer to the instance which is used to access the service

◆ setName()

virtual void kanzi::connect::AbstractService::setName ( const string &  name)
virtual

Defines a override name used to identify the service.

Parameters
namethe name

◆ setPersistence()

void kanzi::connect::AbstractService::setPersistence ( AbstractService::ServiceDescription::Persistence  persistence)

Sets the service persistence.

Parameters
persistencethe persistence type for the service.

◆ setRunningSession()

virtual void kanzi::connect::AbstractService::setRunningSession ( AbstractSessionSharedPtr  session)
inlinevirtual

Stores the currently running session.

Should not be called from 3rd party code - used only internally by the infrastructure.

◆ setRuntimedataValue()

virtual InvokableOperationResult kanzi::connect::AbstractService::setRuntimedataValue ( const string &  elementIdentifier,
const string &  value 
)
virtual

Set runtime data value for the given element in the service runtime data.

Parameters
elementIdentifierIdentifies the element in the service runtime data
valueThe value to set in serialized format

◆ setServiceRuntimeDataSchema()

bool kanzi::connect::AbstractService::setServiceRuntimeDataSchema ( const string &  xml)

Set service runtime data schema.

All previously configured runtime data specific settings are discarded. New schema is also delivered to client(s).

Parameters
xmlXML format schema
Returns
true if succeeded. false if problems.

◆ setServiceState()

void kanzi::connect::AbstractService::setServiceState ( AbstractService::ServiceState  state)

sets service state information.

Parameters
statethe state

◆ setServiceVersion()

void kanzi::connect::AbstractService::setServiceVersion ( AbstractService::ServiceDescription::Version  version,
AbstractService::ServiceDescription::Version  minCompatibleVersion = AbstractService::ServiceDescription::Version() 
)

Configures the service version information.

This should be called in constructor.

Parameters
versionthe main version of the service
minCompatibleVersionminimum compatible version.

◆ setSettingFactory()

void kanzi::connect::AbstractService::setSettingFactory ( const persistence::SettingFactory *  factory)

Set the setting factory instance to allow using persistence service.

Parameters
factoryPointer to the instance which is used to instantiate setting objects

◆ setStopInterval()

void kanzi::connect::AbstractService::setStopInterval ( int  seconds)

Configures the stop interval.

Parameters
secondsthe value to set. Negative values are rounded to 0.

◆ setTimer() [1/2]

virtual int64_t kanzi::connect::AbstractService::setTimer ( int64_t  milliseconds,
ConnectWorkItem::Executor  callback 
)
virtual

Installs a timer to be called after a specified timeout in milliseconds.

Parameters
millisecondstimeout in milliseconds
callbackfunction to be called when timer expires.
Returns
handle that can then be used cancel the timer.

◆ setTimer() [2/2]

virtual int64_t kanzi::connect::AbstractService::setTimer ( int64_t  milliseconds,
ConnectWorkItem::Executor  callback,
ConnectWorkItem::ExecutionContext  executionContext 
)
virtual

Installs a timer to be called after a specified timeout in milliseconds.

Parameters
millisecondstimeout in milliseconds
callbackfunction to be called when timer expires.
executionContextDefines in which thread the callback should be executed.
Returns
handle that can then be used cancel the timer.

◆ simulateEvent()

bool kanzi::connect::AbstractService::simulateEvent ( const string &  messageName,
const MessagePackage message 
)

Post a message to all running sessions as event. Intended for internal use.

◆ startService()

AbstractService::ServiceControlResult kanzi::connect::AbstractService::startService ( ServiceControlSource  serviceControlSource,
ServiceArgumentsSharedPtr  arguments 
)

Tries to start the service.

Returnvalue indicates if operation fails

Parameters
serviceControlSourcewhat caused the service control to be accomplished.
argumentsthe arguments to use when starting the service. Similar to command line arguments on shell - effectively a list of strings.
Returns
true if service got running. false indicates a failure in that operation.

◆ stopService()

AbstractService::ServiceControlResult kanzi::connect::AbstractService::stopService ( ServiceControlSource  serviceControlSource)

Tries to stop the service.

Shall the stop fail or otherwise not supported then scenario must be indicated with return value

Parameters
serviceControlSourcewhat caused the service control to be accomplished.
Returns
true if service got stopped or it was stopped already. false if unable to stop the service.

◆ uninitialize()

virtual void kanzi::connect::AbstractService::uninitialize ( )
virtual

Uninitialize this service.

Note
Classes that inherit AbstractService class must call this base class implementation if their override this method.

◆ work()

virtual void kanzi::connect::AbstractService::work ( ConnectWorkItemSharedPtr  workItem)
virtual

Asks service to perform work.

◆ writeConfigurationPropertyInternal()

bool kanzi::connect::AbstractService::writeConfigurationPropertyInternal ( const string &  stream)
protected

Writes a configuration property value.

Parameters
streamserialized objects where-from to read the value
Returns
true if succeeded.

The documentation for this class was generated from the following file: