Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::LocalContentClient Class Reference

A content client variant that provides direct access to the content manager without any extra overhead. More...

#include <content_client_local.hpp>

Inheritance diagram for kanzi::connect::LocalContentClient:
kanzi::connect::ContentClient kanzi::connect::AbstractServiceClient

Public Member Functions

virtual ~LocalContentClient ()
 Destructor. More...
 
virtual ContentToken acquireContentToken () override
 
virtual void releaseContentToken (ContentToken token) override
 Release content token and unregister from content service. More...
 
virtual bool subscribe (ContentToken token, ContentQueryArgumentsSharedPtr args, ResultCallbackFunction callback, ContentInvalidationFunction invalidationCallback) override
 Subscribe to a table based content. More...
 
virtual bool subscribeEx (ContentToken token, ContentQueryArgumentsSharedPtr args, ContentClientObserver *callback) override
 Subscribe to content. More...
 
virtual void unsubscribe (ContentToken token, const string &uri) override
 Unsubscribe from content URI. More...
 
virtual bool addContentProvider (ContentToken token, const string &uri, ContentProviderSharedPtr contentProvider) override
 Adds content provider to content system. More...
 
virtual void removeContentProvider (ContentToken token, ContentProviderSharedPtr contentProvider) override
 Removes content provider from content system. More...
 
virtual bool subscribeRuntimeData (ContentToken token, const string uri, RuntimeDataResultCallbackFunction callback, int credits, int creditreturninterval) override
 Subscribes to a service runtime data. More...
 
virtual bool subscribeRuntimeDataEx (ContentToken token, const string uri, ContentClientRuntimeDataObserver *observer, int credits, int creditreturninterval) override
 Subscribe to service runtime data. More...
 
virtual void unsubscribeRuntimeData (ContentToken token, const string &uri) override
 Unsubscribe from runtime data. More...
 
virtual bool hasSession (ContentToken token) override
 Determine whether specific content token has session currently available. More...
 
virtual void setVerboseLog (bool verbose) override
 Configures verbose logging for the content client. More...
 
virtual bool getVerboseLog () const override
 Return the current state of log verbosity. More...
 
- Public Member Functions inherited from kanzi::connect::ContentClient
virtual string getIdentifier () const
 Returns the type of the service. More...
 
virtual void work ()
 See AbstractServiceClient::work() More...
 
virtual ~ContentClient ()
 Destructor. More...
 
- Public Member Functions inherited from kanzi::connect::AbstractServiceClient
 AbstractServiceClient ()
 Constructor. More...
 
AbstractSession::MessageSubscriptionToken addMessageSubscription (const string &messageType, AbstractSession::MessageReceivedFunction function)
 
SessionRunningSubscriptionToken addSessionRunningSubscription (SessionRunningFunction function)
 
SessionRunningSubscriptionToken addSessionStoppedSubscription (SessionStoppedFunction function)
 
optional< int > getActiveSessionIdentifier ()
 
optional< const AbstractSession::ServiceAttributesgetServiceAttributes ()
 
virtual void onSessionRunning ()
 
virtual void onSessionStopped ()
 
void removeMessageSubscription (const string &messageType, AbstractSession::MessageSubscriptionToken token)
 
void removeSessionRunningSubscription (SessionRunningSubscriptionToken token)
 
void removeSessionStoppedSubscription (SessionRunningSubscriptionToken token)
 
void setEnabledState (bool newEnabledState)
 Enable/disable the service by allowing or blocking traffic between client and server. More...
 
bool transmit (const MessagePackage &message)
 
virtual ~AbstractServiceClient ()
 Destructor. More...
 

Static Public Member Functions

static LocalContentClientSharedPtr create (ContentManagerSharedPtr contentManager)
 Creates a new instance of LocalContentClient class. More...
 
- Static Public Member Functions inherited from kanzi::connect::ContentClient
static string Type ()
 Type accessors. More...
 

Protected Member Functions

 LocalContentClient (ContentManagerSharedPtr contentManager)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::connect::ContentClient
 ContentClient ()
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::connect::AbstractServiceClient
virtual AbstractSessionSharedPtr getSession ()
 

Additional Inherited Members

- Public Types inherited from kanzi::connect::ContentClient
typedef function< void(const string &uri, int reason, int startRow, int endRow)> ContentInvalidationFunction
 Callback function for content invalidation. More...
 
typedef shared_ptr< void > ContentToken
 A token that identifies the content session / consumer. More...
 
typedef function< void(const string &uri, ContentDataSharedPtr data)> ResultCallbackFunction
 Callback function for content result. More...
 
typedef function< void(const string &uri, RuntimeDataObjectSharedPtr data)> RuntimeDataResultCallbackFunction
 callback function for runtimedata content result. More...
 
- Public Types inherited from kanzi::connect::AbstractServiceClient
typedef function< void(void)> SessionRunningFunction
 
typedef shared_ptr< void > SessionRunningSubscriptionToken
 
typedef function< void(void)> SessionStoppedFunction
 
- Protected Types inherited from kanzi::connect::AbstractServiceClient
enum  SessionState { INITIALIZED = 0, RUNNING = 1, STOPPED = 2 }
 
- Protected Attributes inherited from kanzi::connect::AbstractServiceClient
SessionState m_sessionState
 

Detailed Description

A content client variant that provides direct access to the content manager without any extra overhead.

This class can be used in Kanzi Connect server to directly operate with the Content Service. It introduces certain constraints to the usage:

  • Since content manager is a core service of Kanzi Connect server, this class is only useful on server-side development.
  • The Content Service and the user of this class (content subscriber) need to operate in the same process and thread.
  • The access to the Content Service is synchronous and is not protected in any way (ie. it is not thread safe). To get around these constraints, use RemoteContentClient class instead.

Constructor & Destructor Documentation

◆ ~LocalContentClient()

virtual kanzi::connect::LocalContentClient::~LocalContentClient ( )
virtual

Destructor.

◆ LocalContentClient()

kanzi::connect::LocalContentClient::LocalContentClient ( ContentManagerSharedPtr  contentManager)
protected

Constructor.

Member Function Documentation

◆ acquireContentToken()

virtual ContentToken kanzi::connect::LocalContentClient::acquireContentToken ( )
overridevirtual

◆ addContentProvider()

virtual bool kanzi::connect::LocalContentClient::addContentProvider ( ContentToken  token,
const string &  uri,
ContentProviderSharedPtr  contentProvider 
)
overridevirtual

Adds content provider to content system.

Parameters
tokenContent token, identifies the user of content API, needs to be acquired first.
uriContent URI that is handled by the content provider.
contentProviderContent provider to add.
Returns
true if succeeded, false on error.

Implements kanzi::connect::ContentClient.

◆ create()

static LocalContentClientSharedPtr kanzi::connect::LocalContentClient::create ( ContentManagerSharedPtr  contentManager)
static

Creates a new instance of LocalContentClient class.

Parameters
contentManagerContent Manager that is used to access to content.
Returns
Shared pointer to new LocalContentClient instance.

◆ getVerboseLog()

virtual bool kanzi::connect::LocalContentClient::getVerboseLog ( ) const
overridevirtual

Return the current state of log verbosity.

Returns
log verbosity.

Implements kanzi::connect::ContentClient.

◆ hasSession()

virtual bool kanzi::connect::LocalContentClient::hasSession ( ContentToken  token)
overridevirtual

Determine whether specific content token has session currently available.

Parameters
tokencontent token
Returns
true if session exists

Implements kanzi::connect::ContentClient.

◆ releaseContentToken()

virtual void kanzi::connect::LocalContentClient::releaseContentToken ( ContentToken  token)
overridevirtual

Release content token and unregister from content service.

Parameters
tokenthe content token to release.

Implements kanzi::connect::ContentClient.

◆ removeContentProvider()

virtual void kanzi::connect::LocalContentClient::removeContentProvider ( ContentToken  token,
ContentProviderSharedPtr  contentProvider 
)
overridevirtual

Removes content provider from content system.

Parameters
tokenContent token, identifies the user of content API, needs to be acquired first.
contentProviderContent provider to remove.

Implements kanzi::connect::ContentClient.

◆ setVerboseLog()

virtual void kanzi::connect::LocalContentClient::setVerboseLog ( bool  verbose)
overridevirtual

Configures verbose logging for the content client.

Parameters
verbosewhether to be verbose or not.

Implements kanzi::connect::ContentClient.

◆ subscribe()

virtual bool kanzi::connect::LocalContentClient::subscribe ( ContentToken  token,
ContentQueryArgumentsSharedPtr  args,
ResultCallbackFunction  callback,
ContentInvalidationFunction  invalidationCallback 
)
overridevirtual

Subscribe to a table based content.

Parameters
tokenContent token, identifies the user of content API, needs to be acquired first. When subscribing to table based content (content:// or service://) new token must be allocated for each content domain (E.g. com.rightware.content).
argsQuery Arguments.
callbackFunction callback for results.
invalidationCallbackfunction to invoke when content provider informs that certain part of the content has been invalidated.
Returns
true if subscription started, false if problems were met. Possible reasons for failure include for example trying to subscribe to same domain twice using same content token.

Implements kanzi::connect::ContentClient.

◆ subscribeEx()

virtual bool kanzi::connect::LocalContentClient::subscribeEx ( ContentToken  token,
ContentQueryArgumentsSharedPtr  args,
ContentClientObserver observer 
)
overridevirtual

Subscribe to content.

Parameters
tokencontent content, identifies the user of content API.
argsQuery Arguments.
Returns
true if subscription started, false if there were no session available.

Implements kanzi::connect::ContentClient.

◆ subscribeRuntimeData()

virtual bool kanzi::connect::LocalContentClient::subscribeRuntimeData ( ContentToken  token,
const string  uri,
RuntimeDataResultCallbackFunction  callback,
int  credits,
int  creditreturninterval 
)
overridevirtual

Subscribes to a service runtime data.

Parameters
tokenContent token, identifies the user of content API.
uriThe content URI where to subscribe. Usually something like service://cluster.
callbackFunction callback for results.
creditsamount of transter credits that define the maximum amount of queued items (including both service and client ends) of this type.
creditreturnintervalhow often functionality will return transfer credits to the content producer. Smaller the value more housekeeping traffic is produced.
Returns
true if subscription started, false if there were no session available.

Implements kanzi::connect::ContentClient.

◆ subscribeRuntimeDataEx()

virtual bool kanzi::connect::LocalContentClient::subscribeRuntimeDataEx ( ContentToken  token,
const string  uri,
ContentClientRuntimeDataObserver observer,
int  credits,
int  creditreturninterval 
)
overridevirtual

Subscribe to service runtime data.

Parameters
tokenContent token, identifies the user of content API, needs to be acquired first.
observerObserver interface to be invoked when subscribed runtime data changes.
creditsamount of transter credits that define the maximum amount of queued items (including both service and client ends) of this type.
creditreturnintervalhow often functionality will return transfer credits to the content producer. Smaller the value more housekeeping traffic is produced.
Returns
true if subscription started, false if there were no session available or subscription for the specific uri is already available.

Implements kanzi::connect::ContentClient.

◆ unsubscribe()

virtual void kanzi::connect::LocalContentClient::unsubscribe ( ContentToken  token,
const string &  uri 
)
overridevirtual

Unsubscribe from content URI.

Parameters
tokenContent token.
uriContent URI to unsubscribe. Must be previously subscribed.

Implements kanzi::connect::ContentClient.

◆ unsubscribeRuntimeData()

virtual void kanzi::connect::LocalContentClient::unsubscribeRuntimeData ( ContentToken  token,
const string &  URI 
)
overridevirtual

Unsubscribe from runtime data.

Parameters
tokenContent token to unsubscribe.
uriService URI where to unsubscribe from.

Implements kanzi::connect::ContentClient.


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