Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::ContentProvider Class Referenceabstract

Content Providers provide a mechanism to query, filter and monitor changes in their encapsulated set of data. More...

#include <content_provider.hpp>

Inheritance diagram for kanzi::connect::ContentProvider:
kanzi::connect::ContentProviderCollection

Classes

class  Observer
 Allows to monitor changes in Content Provider. More...
 

Public Member Functions

void addObserver (Observer *observer)
 Adds new observer for this instance. More...
 
void addSubscription (ContentSubscriptionSharedPtr subscription)
 Adds new subscription to this instance. More...
 
 ContentProvider (WorkQueueInterface *workQueue, AbstractServiceSharedPtr owningService)
 Constructor. More...
 
 ContentProvider (WorkQueueInterface *workQueue)
 Constructor. More...
 
vector< ContentSubscriptionSharedPtrgetAllSubscriptions () const
 Retrieves all subscriptions for this provider. More...
 
AbstractServiceSharedPtr getOwningService ()
 Retrieves the service this content provider is bound to. More...
 
AbstractSessionSharedPtr getOwningSession () const
 Retrieve the session that owns this content provider. More...
 
const string & getSchema () const
 Retrieve the Schema. More...
 
virtual size_t getSubProviderCount ()=0
 Returns the amount of URI's held by the content provider. More...
 
virtual ContentProviderDescriptionSharedPtr getSubProviderDescription (size_t index)=0
 Retrieves the description of specific sub content provider. More...
 
ContentSubscriptionSharedPtr getSubscription (shared_ptr< ContentServiceConcept::Session > session) const
 Retrieves content subscription for given session. More...
 
const string & getUri () const
 Retrieve the URI. More...
 
bool hasSchema () const
 Determines whether this particular content provider has schema defined. More...
 
virtual void initialize ()
 Called by the Content Service. Initializes this instance. More...
 
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. More...
 
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. More...
 
void notifyChangedEx (const string &uri=string())
 Informs that specific URI is changed. More...
 
virtual void query (ContentQueryArgumentsSharedPtr arguments, ContentQuerySharedPtr contentQuery)=0
 Performs asynchronous query to data, hosted by this instance. More...
 
void releaseAllSubscriptions ()
 Releases all subscriptions from this instance. More...
 
void removeObserver (Observer *observer)
 Removes observer from this instance. More...
 
void removeSubscription (const ContentSubscription &subscription)
 Removes subscription from this instance. More...
 
void setOwningService (AbstractServiceSharedPtr service)
 Sets the owning service. More...
 
void setOwningSession (AbstractSessionSharedPtr session)
 Store the owning session. More...
 
void setSchema (const string &schema)
 Save the Schema (xml). More...
 
void setUri (const string &uri)
 Save the URI. More...
 
virtual void uninitialize ()
 Called by the Content Service. Un-initializes this instance. More...
 
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. More...
 
virtual ~ContentProvider ()
 Destructor. More...
 

Protected Member Functions

void notifyChanged (const string &uri=string(), bool processAsync=false)
 Allows derived classes to notify that there are changes in content. More...
 
void notifyWork ()
 Allows derived classes to notify that there is work to be done. More...
 

Detailed Description

Content Providers provide a mechanism to query, filter and monitor changes in their encapsulated set of data.

Constructor & Destructor Documentation

◆ ContentProvider() [1/2]

kanzi::connect::ContentProvider::ContentProvider ( WorkQueueInterface workQueue,
AbstractServiceSharedPtr  owningService 
)

Constructor.

Parameters
workQueueinterface to system work queue. Allows the content provider to dispatch work items to event loop.
owningServicethe owners service. pass AbstractServiceSharedPtr() in case this content provider is not directly bound to any specific service.

◆ ContentProvider() [2/2]

kanzi::connect::ContentProvider::ContentProvider ( WorkQueueInterface workQueue)

Constructor.

Parameters
workQueueinterface to system work queue. Allows the content provider to dispatch work items to event loop. is not directly bound to any specific service.

◆ ~ContentProvider()

virtual kanzi::connect::ContentProvider::~ContentProvider ( )
virtual

Destructor.

Member Function Documentation

◆ addObserver()

void kanzi::connect::ContentProvider::addObserver ( Observer observer)

Adds new observer for this instance.

Parameters
observerObserver to add.

◆ addSubscription()

void kanzi::connect::ContentProvider::addSubscription ( ContentSubscriptionSharedPtr  subscription)

Adds new subscription to this instance.

Parameters
subscriptionSubscription to add.

◆ getAllSubscriptions()

vector<ContentSubscriptionSharedPtr> kanzi::connect::ContentProvider::getAllSubscriptions ( ) const

Retrieves all subscriptions for this provider.

Returns
Array containing all active subscriptions.

◆ getOwningService()

AbstractServiceSharedPtr kanzi::connect::ContentProvider::getOwningService ( )

Retrieves the service this content provider is bound to.

Returns
shared pointer to owning service.

◆ getOwningSession()

AbstractSessionSharedPtr kanzi::connect::ContentProvider::getOwningSession ( ) const

Retrieve the session that owns this content provider.

will return nullptr for server-local content providers.

Returns
abstract session. ownership not transfered.

◆ getSchema()

const string& kanzi::connect::ContentProvider::getSchema ( ) const

Retrieve the Schema.

Present only for remote services.

Returns
schema.

◆ getSubProviderCount()

virtual size_t kanzi::connect::ContentProvider::getSubProviderCount ( )
pure virtual

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

Returns
amount of individual URIs

Implemented in kanzi::connect::ContentProviderCollection.

◆ getSubProviderDescription()

virtual ContentProviderDescriptionSharedPtr kanzi::connect::ContentProvider::getSubProviderDescription ( size_t  index)
pure virtual

Retrieves the description of specific sub content provider.

Parameters
indexthe position where from to retrieve.
Returns
description.

Implemented in kanzi::connect::ContentProviderCollection.

◆ getSubscription()

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

Retrieves content subscription for given session.

Parameters
sessionSession instance.
Returns
The subscription that was initiated from given session.

◆ getUri()

const string& kanzi::connect::ContentProvider::getUri ( ) const

Retrieve the URI.

Returns
uri

◆ hasSchema()

bool kanzi::connect::ContentProvider::hasSchema ( ) const
inline

Determines whether this particular content provider has schema defined.

◆ initialize()

virtual void kanzi::connect::ContentProvider::initialize ( )
inlinevirtual

Called by the Content Service. Initializes this instance.

◆ invalidate()

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.

Parameters
urithe uri that got invalidated.
reasonthe reason code for change. Currently not used.
beginRowinclusive start row. Currently not used.
endRowinclusive end row. Currently not used.

◆ invalidateEx()

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.

Parameters
urithe uri that got invalidated.
reasonthe reason code for change. Currently not used.
beginRowinclusive start row. Currently not used.
endRowinclusive end row. Currently not used.

◆ notifyChanged()

void kanzi::connect::ContentProvider::notifyChanged ( const string &  uri = string(),
bool  processAsync = false 
)
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.

Parameters
uriContent uri that was changed.
processAsyncBoolean that tells whether changes can be propagated asynchronously saving potentially time on complex and chained providers.

◆ notifyChangedEx()

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.

Parameters
uridefines the uri. optional.

◆ notifyWork()

void kanzi::connect::ContentProvider::notifyWork ( )
protected

Allows derived classes to notify that there is work to be done.

◆ query()

virtual void kanzi::connect::ContentProvider::query ( ContentQueryArgumentsSharedPtr  arguments,
ContentQuerySharedPtr  contentQuery 
)
pure virtual

Performs asynchronous query to data, hosted by this instance.

Needs to be implemented by the derived class.

Parameters
argumentsthe arguments used to query
contentQueryContent query that will be notified when the data has been retrieved.

Implemented in kanzi::connect::ContentProviderCollection.

◆ releaseAllSubscriptions()

void kanzi::connect::ContentProvider::releaseAllSubscriptions ( )

Releases all subscriptions from this instance.

◆ removeObserver()

void kanzi::connect::ContentProvider::removeObserver ( Observer observer)

Removes observer from this instance.

Parameters
observerObserver to remove.

◆ removeSubscription()

void kanzi::connect::ContentProvider::removeSubscription ( const ContentSubscription subscription)

Removes subscription from this instance.

Parameters
subscriptionContent subscription to remove.

◆ setOwningService()

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.

Parameters
servicethe service to set.

◆ setOwningSession()

void kanzi::connect::ContentProvider::setOwningSession ( AbstractSessionSharedPtr  session)

Store the owning session.

Parameters
sessionthe session. ownership not transfered.

◆ setSchema()

void kanzi::connect::ContentProvider::setSchema ( const string &  schema)

Save the Schema (xml).

Parameters
schema

◆ setUri()

void kanzi::connect::ContentProvider::setUri ( const string &  uri)

Save the URI.

Parameters
urithe uri

◆ uninitialize()

virtual void kanzi::connect::ContentProvider::uninitialize ( )
inlinevirtual

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

◆ work()

virtual void kanzi::connect::ContentProvider::work ( )
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.


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