Content Providers provide a mechanism to query, filter and monitor changes in their encapsulated set of data. More...
#include <content_provider.hpp>
Classes | |
class | Observer |
Allows to monitor changes in Content Provider. More... | |
Public Member Functions | |
void | addObserver (Observer *observer) |
Adds new observer for this instance. | |
void | addSubscription (ContentSubscriptionSharedPtr subscription) |
Adds new subscription to this instance. | |
ContentProvider (WorkQueueInterface *workQueue) | |
Constructor. | |
ContentProvider (WorkQueueInterface *workQueue, AbstractServiceSharedPtr owningService) | |
Constructor. | |
vector< ContentSubscriptionSharedPtr > | getAllSubscriptions () const |
Retrieves all subscriptions for this provider. | |
AbstractServiceSharedPtr | getOwningService () |
Retrieves the service this content provider is bound to. | |
AbstractSessionSharedPtr | getOwningSession () const |
Retrieve the session that owns this content provider. | |
const string & | getSchema () const |
Retrieve the Schema. | |
virtual size_t | getSubProviderCount ()=0 |
Returns the amount of URI's held by the content provider. | |
virtual ContentProviderDescriptionSharedPtr | getSubProviderDescription (size_t index)=0 |
Retrieves the description of specific sub content provider. | |
ContentSubscriptionSharedPtr | getSubscription (shared_ptr< ContentServiceConcept::Session > session) const |
Retrieves content subscription for given session. | |
const string & | getUri () const |
Retrieve the URI. | |
bool | hasSchema () const |
Determines whether this particular content provider has schema defined. | |
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. | |
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. | |
void | notifyChangedEx (const string &uri=string()) |
Informs that specific URI is changed. | |
virtual void | query (ContentQueryArgumentsSharedPtr arguments, ContentQuerySharedPtr contentQuery)=0 |
Performs asynchronous query to data, hosted by this instance. | |
void | releaseAllSubscriptions () |
Releases all subscriptions from this instance. | |
void | removeObserver (Observer *observer) |
Removes observer from this instance. | |
void | removeSubscription (const ContentSubscription &subscription) |
Removes subscription from this instance. | |
void | setOwningService (AbstractServiceSharedPtr service) |
Sets the owning service. | |
void | setOwningSession (AbstractSessionSharedPtr session) |
Store the owning session. | |
void | setSchema (const string &schema) |
Save the Schema (xml). | |
void | setUri (const string &uri) |
Save the URI. | |
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. | |
virtual | ~ContentProvider () |
Destructor. | |
Protected Member Functions | |
void | notifyChanged (const string &uri=string(), bool processAsync=false) |
Allows derived classes to notify that there are changes in content. | |
void | notifyWork () |
Allows derived classes to notify that there is work to be done. | |
Content Providers provide a mechanism to query, filter and monitor changes in their encapsulated set of data.
kanzi::connect::ContentProvider::ContentProvider | ( | WorkQueueInterface * | workQueue, |
AbstractServiceSharedPtr | owningService ) |
Constructor.
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. |
kanzi::connect::ContentProvider::ContentProvider | ( | WorkQueueInterface * | workQueue | ) |
Constructor.
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. |
|
virtual |
Destructor.
void kanzi::connect::ContentProvider::addObserver | ( | Observer * | observer | ) |
Adds new observer for this instance.
observer | Observer to add. |
void kanzi::connect::ContentProvider::addSubscription | ( | ContentSubscriptionSharedPtr | subscription | ) |
Adds new subscription to this instance.
subscription | Subscription to add. |
vector< ContentSubscriptionSharedPtr > kanzi::connect::ContentProvider::getAllSubscriptions | ( | ) | const |
Retrieves all subscriptions for this provider.
AbstractServiceSharedPtr kanzi::connect::ContentProvider::getOwningService | ( | ) |
Retrieves the service this content provider is bound to.
AbstractSessionSharedPtr kanzi::connect::ContentProvider::getOwningSession | ( | ) | const |
Retrieve the session that owns this content provider.
will return nullptr for server-local content providers.
const string & kanzi::connect::ContentProvider::getSchema | ( | ) | const |
Retrieve the Schema.
Present only for remote services.
|
pure virtual |
Returns the amount of URI's held by the content provider.
Implemented in kanzi::connect::ContentProviderCollection.
|
pure virtual |
Retrieves the description of specific sub content provider.
index | the position where from to retrieve. |
Implemented in kanzi::connect::ContentProviderCollection.
ContentSubscriptionSharedPtr kanzi::connect::ContentProvider::getSubscription | ( | shared_ptr< ContentServiceConcept::Session > | session | ) | const |
Retrieves content subscription for given session.
session | Session instance. |
const string & kanzi::connect::ContentProvider::getUri | ( | ) | const |
Retrieve the URI.
|
inline |
Determines whether this particular content provider has schema defined.
|
inlinevirtual |
Called by the Content Service. Initializes this instance.
void kanzi::connect::ContentProvider::invalidate | ( | const string & | uri, |
int | reason, | ||
int | beginRow = 0, | ||
int | endRow = -1 ) |
Invalidates the content and causes subscribed clients to refresh their data completely.
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 kanzi::connect::ContentProvider::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.
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. |
|
protected |
Allows derived classes to notify that there are changes in content.
NOTE: Using this notification will not work if elements are removed from the provider. For removal scenario the invalidate(...) must be called instead.
uri | Content uri that was changed. |
processAsync | Boolean that tells whether changes can be propagated asynchronously saving potentially time on complex and chained providers. |
void kanzi::connect::ContentProvider::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.
uri | defines the uri. optional. |
|
protected |
Allows derived classes to notify that there is work to be done.
|
pure virtual |
Performs asynchronous query to data, hosted by this instance.
Needs to be implemented by the derived class.
arguments | the arguments used to query |
contentQuery | Content query that will be notified when the data has been retrieved. |
Implemented in kanzi::connect::ContentProviderCollection.
void kanzi::connect::ContentProvider::releaseAllSubscriptions | ( | ) |
Releases all subscriptions from this instance.
void kanzi::connect::ContentProvider::removeObserver | ( | Observer * | observer | ) |
Removes observer from this instance.
observer | Observer to remove. |
void kanzi::connect::ContentProvider::removeSubscription | ( | const ContentSubscription & | subscription | ) |
Removes subscription from this instance.
subscription | Content subscription to remove. |
void kanzi::connect::ContentProvider::setOwningService | ( | AbstractServiceSharedPtr | service | ) |
Sets the owning service.
Only weak pointer to service is stored thus content provider does not affect on the owning service lifeline.
service | the service to set. |
void kanzi::connect::ContentProvider::setOwningSession | ( | AbstractSessionSharedPtr | session | ) |
Store the owning session.
session | the session. ownership not transfered. |
void kanzi::connect::ContentProvider::setSchema | ( | const string & | schema | ) |
Save the Schema (xml).
schema |
void kanzi::connect::ContentProvider::setUri | ( | const string & | uri | ) |
Save the URI.
uri | the uri |
|
inlinevirtual |
Called by the Content Service. Un-initializes this instance.
|
virtual |
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.