Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Subscriber to follow an arbitrary set of resources.
A subscriber monitors any number of resources. The resources can be specified by their real URIs or alias names. Wildcards as well as presently unkown resources are allowed. Events can be fetched using the CRcEventProcessor mechanisms, typically Select() and PollEvent().
Note: All public methods must be called from the same thread. Subscribers are generally managed by the user/owner object. Internally, each remote host object owns one subscriber to serve subscriptions from the remote host to local resources.
Definition at line 1907 of file resources.H.
#include "resources.H"
Friends | |
class | CResource |
Properties and stringification ... | |
const char * | Lid () |
const char * | Gid () |
virtual const char * | TypeId () |
(optional) Hint for the main event loop: object type | |
virtual const char * | InstId () |
(optional) Hint for the main event loop: object instance | |
const char * | ToStr (CString *ret) |
bool | IsEmpty () |
Adding/removing resources ... | |
CResource * | AddResource (CResource *rc) |
CResource * | AddResources (const char *pattern) |
Add new resources by pattern. The pattern is also stored internally to catch possible resources added in the future. More... | |
void | DelResource (CResource *rc) |
void | DelResources (const char *pattern) |
Remove resources by pattern. See AddResources() for details on possible patterns. More... | |
void | Clear () |
Remove all resources. | |
Synonyms for adding/removing resources (mainly for the Python wrappers) ... | |
CResource * | Subscribe (CResource *rc) |
CResource * | Subscribe (const char *uri) |
void | Unsubscribe (CResource *rc) |
void | Unsubscribe (const char *pattern) |
For directory services ... | |
void | GetInfo (CString *ret, int verbosity=1) |
Get Info. 'verbosity == 0': single line, 1: list entries / resources. | |
void | GetPatternSet (CKeySet *retPatternSet) |
Get current pattern set. Patterns from the watch set are followed by a "?". | |
void | PrintInfo (FILE *f=stdout, int verbosity=1) |
static void | GetInfoAll (CString *ret, int verbosity=1) |
Get info for all subscribers of this instance (see GetInfo() for info on 'verbosity'). | |
Additional Inherited Members | |
Public Member Functions inherited from CRcEventProcessor | |
void | PutEvent (CRcEvent *ev) |
Enqueue/process an event; caller remains owner of 'ev'. | |
bool | PollEvent (CRcEvent *ev) |
Check for an event (non-blocking) and return it at '*ev'. More... | |
bool | WaitEvent (CRcEvent *ev, TTicks *maxTime=NULL) |
Wait for an event and return it at '*ev'. More... | |
void | Interrupt () |
Request a running WaitEvent() to stop now. | |
void | FlushEvents () |
Remove all presently queued events; also waits until a concurrently running OnEvent() invocation returns. | |
virtual bool | OnEvent (CRcEvent *ev) |
Handle an event asynchronously (may have been called from any thread) More... | |
void | SetCbOnEvent (FRcEventFunc *_cbEvent, void *_cbEventData=NULL) |
void | ClearCbOnEvent () |
void | SetInSelectSet (bool _inSelectSet) |
Set whether or not the event processor is contained in the set of upcoming Select() operations. | |
bool | InSelectSet () |
const char * | ToStr (CString *ret) |
Static Public Member Functions inherited from CRcEventProcessor | |
static CRcEventProcessor * | Select (TTicks maxTime=-1) |
Wait until any of the existing 'CRcEventProcessor' objects has an event available. More... | |
CResource * CRcSubscriber::AddResources | ( | const char * | pattern | ) |
Add new resources by pattern. The pattern is also stored internally to catch possible resources added in the future.
pattern | is a single or be a comma- or whitespace-separated list of URIs (expressions). |
Within the resource expressions, both MQTT-style and filename-style wildcards can be used to select multiple resources:
void CRcSubscriber::DelResources | ( | const char * | pattern | ) |
Remove resources by pattern. See AddResources() for details on possible patterns.
Note: When using wildcards, all patterns previously passed to AddResources() must either be covered completely or be identical. Otherwise, it may happen that not all resources covered by 'pattern' here are unsuscribed. For example, in the following sequence, the DelResources() call has no effect: