ContentProvider¶
-
class
kanzi::connect
::
ContentProvider
: public enable_shared_from_this<ContentProvider>¶ Content Providers provide a mechanism to query, filter and monitor changes in their encapsulated set of data.
Subclassed by ContentProviderCollection
Public Functions
-
ContentProvider
(WorkQueueInterface *workQueue)¶ Constructor.
- Parameters
workQueue – interface to system work queue. Allows the content provider to dispatch work items to event loop. is not directly bound to any specific service.
Constructor.
- Parameters
workQueue – interface to system work queue. Allows the content provider to dispatch work items to event loop.
owningService – the owners service. pass AbstractServiceSharedPtr() in case this content provider is not directly bound to any specific service.
-
virtual
~ContentProvider
()¶ Destructor.
-
void
addObserver
(Observer *observer)¶ Adds new observer for this instance.
- Parameters
observer – Observer to add.
Adds new subscription to this instance.
- Parameters
subscription – Subscription to add.
-
vector<ContentSubscriptionSharedPtr>
getAllSubscriptions
() const¶ Retrieves all subscriptions for this provider.
- Returns
Array containing all active subscriptions.
-
AbstractServiceSharedPtr
getOwningService
()¶ Retrieves the service this content provider is bound to.
- Returns
shared pointer to owning service.
-
AbstractSessionSharedPtr
getOwningSession
() const¶ Retrieve the session that owns this content provider.
will return nullptr for server-local content providers.
- Returns
abstract session. ownership not transfered.
-
const string &
getSchema
() const¶ Retrieve the Schema.
Present only for remote services.
- Returns
schema.
-
virtual size_t
getSubProviderCount
() = 0¶ Returns the amount of URI’s held by the content provider.
- Returns
amount of individual URIs
-
virtual ContentProviderDescriptionSharedPtr
getSubProviderDescription
(size_t index) = 0¶ Retrieves the description of specific sub content provider.
- Parameters
index – the position where from to retrieve.
- Returns
description.
Retrieves content subscription for given session.
- Parameters
session – Session instance.
- Returns
The subscription that was initiated from given session.
-
const string &
getUri
() const¶ Retrieve the URI.
- Returns
uri
-
inline bool
hasSchema
() const¶ Determines whether this particular content provider has schema defined.
-
inline virtual void
initialize
()¶ Called by the Content Service. Initializes this instance.
-
void
invalidate
(const string &uri, int reason, int beginRow = 0, int endRow = -1)¶ Invalidates the content and causes subscribed clients to refresh their data completely.
- Parameters
uri – the uri that got invalidated.
reason – the reason code for change. Currently not used.
beginRow – inclusive start row. Currently not used.
endRow – inclusive end row. Currently not used.
-
void
invalidateEx
(const string &uri, int reason, int beginRow = 0, int endRow = -1)¶ Invalidates the content and causes subscribed clients to refresh their data completely.
Used from external language bindings and is thread safe call.
- Parameters
uri – the uri that got invalidated.
reason – the reason code for change. Currently not used.
beginRow – inclusive start row. Currently not used.
endRow – inclusive end row. Currently not used.
-
void
notifyChangedEx
(const string &uri = string())¶ Informs that specific URI is changed.
Used from external language bindings and is thread safe call. NOTE: Using this notification will not work if elements are removed from the provider. For removal scenario the invalidateEx(…) must be called instead.
- Parameters
uri – defines the uri. optional.
Performs asynchronous query to data, hosted by this instance.
Needs to be implemented by the derived class.
- Parameters
arguments – the arguments used to query
contentQuery – Content query that will be notified when the data has been retrieved.
-
void
releaseAllSubscriptions
()¶ Releases all subscriptions from this instance.
-
void
removeObserver
(Observer *observer)¶ Removes observer from this instance.
- Parameters
observer – Observer to remove.
-
void
removeSubscription
(const ContentSubscription &subscription)¶ Removes subscription from this instance.
- Parameters
subscription – Content subscription to remove.
Sets the owning service.
Only weak pointer to service is stored thus content provider does not affect on the owning service lifeline.
- Parameters
service – the service to set.
Store the owning session.
- Parameters
session – the session. ownership not transfered.
-
void
setSchema
(const string &schema)¶ Save the Schema (xml).
- Parameters
schema –
-
void
setUri
(const string &uri)¶ Save the URI.
- Parameters
uri – the uri
-
inline virtual void
uninitialize
()¶ Called by the Content Service. Un-initializes this instance.
-
virtual void
work
()¶ Called by the Content Service. Allows this instance to perform work such as push data from external threads to content system or procedurally generate data.
-
class
Observer
¶ Allows to monitor changes in Content Provider.
Subclassed by ContentProviderCollection, ContentSubscription
Public Functions
-
inline virtual
~Observer
()¶ Virtual destructor (for SWIG).
-
inline virtual void
onChanged
(ContentProvider*, const string&, bool)¶ Callback to notify that change has occurred in given content provider.
- Parameters
provider – Content Provider that changed.
uri – Uri within Content Provider domain that changed.
async – Boolean indicating whether changes need to propagate to subscribers immediately, or is it ok to process the queries asynchronously.
-
inline virtual void
onInvalidated
(ContentProvider*, const string&, int, int, int)¶ Callback to notify invalidation of content provider.
- Parameters
provider – Content provider that changed.
reason – the reason for invalidation. Not currently used.
beginRow – inclusive start row of the change. Not currently used.
endRow – inclusive end row of the change. Not currently used.
-
inline virtual
-