ContentClient¶
-
class
kanzi::connect
::
ContentClient
: public AbstractServiceClient¶ A class that abstracts server-side & client-side access to content manager.
This class makes it possible to acquire or release a token that can be used to subscribe to content in the content database. The content token can also be used to register content to the server-side content database. This abstraction makes it possible to write content providers and consumers that can operate both locally (server-side) and remotely (client-side).
- See
LocalContentClient and RemoteContentClient for server-side and client-side variants.
Subclassed by LocalContentClient, RemoteContentClient
Public Types
-
typedef function<void(const string &uri, int reason, int startRow, int endRow)>
ContentInvalidationFunction
¶ Callback function for content invalidation.
-
typedef shared_ptr<void>
ContentToken
¶ A token that identifies the content session / consumer.
-
typedef function<void(const string &uri, ContentDataSharedPtr data)>
ResultCallbackFunction
¶ Callback function for content result.
-
typedef function<void(const string &uri, RuntimeDataObjectSharedPtr data)>
RuntimeDataResultCallbackFunction
¶ callback function for runtimedata content result.
Public Functions
-
virtual
~ContentClient
()¶ Destructor.
-
virtual ContentToken
acquireContentToken
() = 0¶ Acquire content token and register as user of content service.
- Returns
Content token that is used to identify the content session.
Adds content provider to content system.
- Parameters
token – Content token, identifies the user of content API, needs to be acquired first.
uri – Content URI that is handled by the content provider.
contentProvider – Content provider to add.
- Returns
true if succeeded, false on error.
-
inline virtual string
getIdentifier
() const¶ Returns the type of the service.
- Returns
Identifier of the service, as a string.
-
virtual bool
getVerboseLog
() const = 0¶ Return the current state of log verbosity.
- Returns
log verbosity.
-
virtual bool
hasSession
(ContentToken token) = 0¶ Determine whether specific content token has session currently available.
- Parameters
token – content token
- Returns
true if session exists
-
virtual void
releaseContentToken
(ContentToken token) = 0¶ Release content token and unregister from content service.
- Parameters
token – the content token to release.
Removes content provider from content system.
- Parameters
token – Content token, identifies the user of content API, needs to be acquired first.
contentProvider – Content provider to remove.
-
virtual void
setVerboseLog
(bool verbose) = 0¶ Configures verbose logging for the content client.
- Parameters
verbose – whether to be verbose or not.
Subscribe to a table based content.
- Parameters
token – Content 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).
args – Query Arguments.
callback – Function callback for results.
invalidationCallback – function 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.
Subscribe to content.
- Parameters
token – content content, identifies the user of content API.
args – Query Arguments.
- Returns
true if subscription started, false if there were no session available.
-
virtual bool
subscribeRuntimeData
(ContentToken token, const string uri, RuntimeDataResultCallbackFunction callback, int credits, int creditreturninterval) = 0¶ Subscribes to a service runtime data.
- Parameters
token – Content token, identifies the user of content API.
uri – The content URI where to subscribe. Usually something like service://cluster.
callback – Function callback for results.
credits – amount of transter credits that define the maximum amount of queued items (including both service and client ends) of this type.
creditreturninterval – how 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.
-
virtual bool
subscribeRuntimeDataEx
(ContentToken token, const string uri, ContentClientRuntimeDataObserver *observer, int credits, int creditreturninterval) = 0¶ Subscribe to service runtime data.
- Parameters
token – Content token, identifies the user of content API, needs to be acquired first.
observer – Observer interface to be invoked when subscribed runtime data changes.
credits – amount of transter credits that define the maximum amount of queued items (including both service and client ends) of this type.
creditreturninterval – how 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.
-
virtual void
unsubscribe
(ContentToken token, const string &uri) = 0¶ Unsubscribe from content URI.
- Parameters
token – Content token.
uri – Content URI to unsubscribe. Must be previously subscribed.
-
virtual void
unsubscribeRuntimeData
(ContentToken token, const string &URI) = 0¶ Unsubscribe from runtime data.
- Parameters
token – Content token to unsubscribe.
uri – Service URI where to unsubscribe from.
-
inline virtual void
work
()¶ See AbstractServiceClient::work()
Public Static Functions
-
static inline string
Type
()¶ Type accessors.
-
class
ContentClientObserver
¶ Polymorphic C++ observer interface for table based content subscriptions.
Public Functions
-
inline virtual
~ContentClientObserver
()¶ Virtual destructor (for SWIG).
-
virtual void
contentInvalidationRequest
(const string &uri, int reason, int startRow, int endRow) = 0¶ Invoked when content provider informs that certain part of the content has been invalidated.
- Parameters
uri – The URI
reason – reason code. Currently not used.
startRow – beginning of invalidation (inclusive). Currently not used.
endRow – end of invalidation (inclusive). Currently not used.
Invoked when content subscription provides some data.
- Parameters
uri – The URI
data – The data
-
inline virtual
-
class
ContentClientRuntimeDataObserver
¶ Polymorphic C++ observer interface for runtime data subscriptions.
Public Functions
-
inline virtual
~ContentClientRuntimeDataObserver
()¶ Virtual destructor (for SWIG).
Invoked when content subscription provides some data.
- Parameters
uri – The URI
data – The data
-
inline virtual