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, AbstractServiceSharedPtr owningService)

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.

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.

~ContentProvider()

Destructor.

void addObserver(Observer *observer)

Adds new observer for this instance.

Parameters
  • observer: Observer to add.

void addSubscription(ContentSubscriptionSharedPtr subscription)

Adds new subscription to this instance.

Parameters
  • subscription: Subscription to add.

vector<ContentSubscriptionSharedPtr> getAllSubscriptions() const

Retrieves all subscriptions for this provider.

Return

Array containing all active subscriptions.

AbstractServiceSharedPtr getOwningService()

Retrieves the service this content provider is bound to.

Return

shared pointer to owning service.

AbstractSessionSharedPtr getOwningSession() const

Retrieve the session that owns this content provider.

will return nullptr for server-local content providers.

Return

abstract session. ownership not transfered.

const string &getSchema() const

Retrieve the Schema.

Present only for remote services.

Return

schema.

size_t getSubProviderCount() = 0

Returns the amount of URI’s held by the content provider.

Return

amount of individual URIs

ContentProviderDescriptionSharedPtr getSubProviderDescription(size_t index) = 0

Retrieves the description of specific sub content provider.

Return

description.

Parameters
  • index: the position where from to retrieve.

ContentSubscriptionSharedPtr getSubscription(shared_ptr<ContentServiceConcept::Session> session) const

Retrieves content subscription for given session.

Return

The subscription that was initiated from given session.

Parameters
  • session: Session instance.

const string &getUri() const

Retrieve the URI.

Return

uri

bool hasSchema() const

Determines whether this particular content provider has schema defined.

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.

void query(ContentQueryArgumentsSharedPtr arguments, ContentQuerySharedPtr contentQuery) = 0

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.

void 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.

Parameters
  • service: the service to set.

void setOwningSession(AbstractSessionSharedPtr session)

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

void uninitialize()

Called by the Content Service. Un-initializes this instance.

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

~Observer()

Virtual destructor (for SWIG).

void onChanged(ContentProvider *provider, const string &uri, bool async)

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.

void onInvalidated(ContentProvider *provider, const string &uri, int reason, int beginRow, int endRow)

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.