ALBA
|
#include <albaDeviceManager.h>
Public Member Functions | |
albaDeviceManager () | |
virtual | ~albaDeviceManager () |
albaTypeMacro (albaDeviceManager, albaAgentEventHandler) | |
virtual albaID | AddDevice (albaDevice *device) |
virtual albaDevice * | AddDevice (const char *type, bool persistent=false) |
int | RemoveDevice (albaDevice *device, bool force=false) |
int | RemoveDevice (const char *name, bool force=false) |
albaDevice * | GetDevice (const char *name) |
albaDevice * | GetDevice (albaID id) |
int | GetNumberOfDevices () |
void | RemoveAllDevices (bool force=false) |
std::list< albaDevice * > * | GetDevices () |
albaDeviceSet * | GetDeviceSet () |
virtual void | OnEvent (albaEventBase *event) |
virtual bool | DispatchEvents () |
Public Member Functions inherited from albaAgentEventHandler | |
albaTypeMacro (albaAgentEventHandler, albaAgentEventQueue) | |
Public Member Functions inherited from albaAgentEventQueue | |
ALBA_ID_DEC (EVENT_DISPATCH) | |
albaTypeMacro (albaAgentEventQueue, albaAgent) | |
bool | PushEvent (albaEventBase &event) |
virtual bool | PushEvent (albaEventBase *event) |
bool | PushEvent (albaID event_id, void *sender, void *data=NULL) |
albaEventBase * | PeekEvent () |
albaEventBase * | PeekLastEvent () |
int | GetQueueSize () |
bool | IsQueueEmpty () |
virtual bool | DispatchEvents () |
void | SetDequeueMode (int mode) |
int | GetDequeueMode () |
void | SetDequeueModeToMultipleEvent () |
void | SetDequeueModeToSingleEvent () |
void | SetDispatchMode (int mode) |
int | GetDispatchMode () |
void | SetDispatchModeToSelfProcess () |
void | SetDispatchModeToBroadcast () |
void | SetPushMode (int mode) |
int | GetPushMode () |
void | SetPushModeToDispatchEvent () |
void | SetPushModeToPolling () |
Public Member Functions inherited from albaAgent | |
albaAbstractTypeMacro (albaAgent, albaReferenceCounted) | |
ALBA_ID_DEC (AGENT_INITIALIZE) | |
void | AddObserver (albaObserver *listener, albaID channel=MCH_UP) |
void | RemoveObserver (albaObserver *listener) |
void | RemoveAllObservers () |
virtual void | OnEvent (albaEventBase *event) |
bool | HasObservers (albaID channel) |
void | GetObservers (albaID channel, std::vector< albaObserver * > &olist) |
int | Initialize () |
void | Shutdown () |
int | IsInitialized () |
virtual void | SetName (const char *name) |
const char * | GetName () |
Public Member Functions inherited from albaReferenceCounted | |
albaReferenceCounted () | |
virtual | ~albaReferenceCounted () |
albaAbstractTypeMacro (albaReferenceCounted, albaObject) | |
virtual void | Delete () |
void | Register (void *obj) |
virtual void | UnRegister (void *obj) |
int | GetReferenceCount () |
void | SetReferenceCount (int) |
Public Member Functions inherited from albaObject | |
albaObject () | |
virtual | ~albaObject () |
virtual void | Delete () |
virtual const char * | GetTypeName () const |
virtual bool | IsA (const char *type_name) const |
virtual bool | IsA (const albaTypeID &type_id) const |
virtual albaObject * | NewObjectInstance () const =0 |
virtual const albaTypeID & | GetTypeId () const |
virtual void | Print (std::ostream &os, const int indent=0) const |
albaObject (const albaObject &c) | |
Public Member Functions inherited from albaObserver | |
albaObserver () | |
virtual | ~albaObserver () |
virtual void | OnEvent (albaEventBase *e)=0 |
Public Member Functions inherited from albaEventBroadcaster | |
albaEventBroadcaster (void *owner=NULL) | |
virtual | ~albaEventBroadcaster () |
albaEventBroadcaster (const albaEventBroadcaster &c) | |
void | AddObserver (albaObserver *obj) |
void | AddObserver (albaObserver &obj) |
albaObserverCallback * | AddObserverCallback (void(*f)(void *sender, albaID eid, void *clientdata, void *calldata)) |
bool | RemoveObserver (albaObserver *obj) |
void | RemoveAllObservers () |
bool | IsObserver (albaObserver *obj) |
bool | HasObservers () |
void | GetObservers (std::vector< albaObserver * > &olist) |
void | InvokeEvent (albaEventBase &e) |
void | InvokeEvent (albaEventBase *e) |
void | InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL) |
void | SetChannel (albaID ch) |
albaID | GetChannel () |
virtual void | SetListener (albaObserver *o) |
Public Member Functions inherited from albaEventSender | |
albaEventSender () | |
virtual void | SetListener (albaObserver *o) |
virtual albaObserver * | GetListener () |
virtual bool | HasListener () |
virtual void | InvokeEvent (albaEventBase &e) |
virtual void | InvokeEvent (albaEventBase *e) |
virtual void | InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL) |
Public Member Functions inherited from albaStorable | |
albaStorable () | |
int | Store (albaStorageElement *element) |
int | Restore (albaStorageElement *element) |
albaObject * | CastToObject () |
bool | IsStorable () |
Protected Member Functions | |
virtual int | InternalStore (albaStorageElement *node) |
virtual int | InternalRestore (albaStorageElement *node) |
virtual int | InternalInitialize () |
virtual void | InternalShutdown () |
Protected Member Functions inherited from albaAgentEventHandler | |
albaAgentEventHandler () | |
virtual | ~albaAgentEventHandler () |
virtual void | RequestForDispatching () |
Protected Member Functions inherited from albaAgentEventQueue | |
albaAgentEventQueue () | |
virtual | ~albaAgentEventQueue () |
albaEventBase * | PopEvent () |
int | PopEvent (albaEventBase &event) |
virtual int | PopEvent (albaEventBase *&event) |
bool | GetDispatched () |
void | SetDispatched (bool value=true) |
virtual void | RequestForDispatching () |
Protected Member Functions inherited from albaAgent | |
albaAgent () | |
virtual | ~albaAgent () |
virtual int | InternalInitialize () |
virtual void | InternalShutdown () |
void | InvokeEvent (albaEventBase &event, albaID channel=-1) |
void | InvokeEvent (albaEventBase *event, albaID channel=-1) |
void | InvokeEvent (void *sender, int id, albaID channel=MCH_UP, void *data=NULL) |
virtual int | InternalStore (albaStorageElement *node)=0 |
virtual int | InternalRestore (albaStorageElement *node)=0 |
Protected Attributes | |
albaDeviceSet * | m_DeviceSet |
albaID | m_DeviceIdCounter |
albaID | m_PersistentDeviceIdCounter |
bool | m_RestoringFlag |
Protected Attributes inherited from albaAgentEventHandler | |
albaWXEventHandler * | m_EventHandler |
Protected Attributes inherited from albaAgentEventQueue | |
InternalEventQueue * | m_EventQueue |
albaMutexLock * | m_Mutex |
int | m_DispatchMode |
int | m_DequeueMode |
int | m_PushMode |
bool | m_Dispatched |
Protected Attributes inherited from albaAgent | |
albaString | m_Name |
bool | m_Initialized |
std::vector< albaEventBroadcaster * > | m_Channels |
Protected Attributes inherited from albaReferenceCounted | |
int | m_ReferenceCount |
Protected Attributes inherited from albaObject | |
bool | m_HeapFlag |
Protected Attributes inherited from albaEventBroadcaster | |
albaObserversList | m_Observers |
albaID | m_Channel |
Protected Attributes inherited from albaEventSender | |
albaObserver * | m_Listener |
Protected Attributes inherited from albaStorable | |
bool | m_Storable |
Additional Inherited Members | |
Public Types inherited from albaAgentEventQueue | |
enum | DispatchModalities { SelfProcessMode = 0 , BroadcastMode } |
enum | PopModalities { SingleEventMode = 0 , MultipleEventMode } |
enum | PushModalities { DispatchEventMode =0 , PollingMode } |
Static Public Member Functions inherited from albaObject | |
static const char * | GetStaticTypeName () |
static bool | IsStaticType (const char *type_name) |
static bool | IsStaticType (const albaTypeID &type_id) |
static const albaTypeID & | GetStaticTypeId () |
static albaObject * | SafeDownCast (albaObject *o) |
Static Public Member Functions inherited from albaStorable | |
static albaStorable * | SafeCastToObject (albaObject *o) |
Protected Types inherited from albaEventBroadcaster | |
typedef std::list< albaObserver * > | albaObserversList |
Class managing the devices inside a ALBA application and the synchronization with wxWindows message pump.
This class is used both as a container for all active devices and manages synchronization of events coming from input devices with wxWindows message pump. The synchronization mechanisms is accomplished by executing the "dispatching" on a separate thread, and this is currently imlemented by sending an event on the GUI message pump with a request for dispatching the events. This make dispatching to occurs on the right thread
Device instances can be of two different types: persistent and non-persistent. The first class of devices are typically created by the application code, while the seconds are created by user using the Interaction Settings configuration dialog. Persistent devices are not stored to disk and neither they are stopped or destroyed when a new device configuration is loaded from disk. Typically a non persistent device object pointer should not be stored by other componenents, since when loading new configuration these devices are destroyed a new one are created. An example of persistent device is the mouse, which is created at application start.
To store devices a albaDeviceSet object is internally used as the root of the devices tree. Devices that could have subdevices can inherit from albaDeviceSet to correctly manage the start/stop mechanisms of all subdevices.
Definition at line 52 of file albaDeviceManager.h.
|
virtual |
albaDeviceManager::albaTypeMacro | ( | albaDeviceManager | , |
albaAgentEventHandler | |||
) |
|
virtual |
Add a new device.
If the returned value is 0 the operation has failed!
|
virtual |
Add a new device specifying only its class name.
If the returned pointer is NULL the operation has failed! "persistent" flag must be used to add persistent devices
int albaDeviceManager::RemoveDevice | ( | albaDevice * | device, |
bool | force = false |
||
) |
Remove a device from the manager's list.
force flag must be used to remove persistent devices
int albaDeviceManager::RemoveDevice | ( | const char * | name, |
bool | force = false |
||
) |
Remove a device with the given name from the manager's list.
albaDevice * albaDeviceManager::GetDevice | ( | const char * | name | ) |
Return a device handler given its name.
albaDevice * albaDeviceManager::GetDevice | ( | albaID | id | ) |
Return a device handler given its ID.
Persistent devices have ID < MIN_DEVICE_ID
int albaDeviceManager::GetNumberOfDevices | ( | ) |
Return the number of devices assigned to this manager.
void albaDeviceManager::RemoveAllDevices | ( | bool | force = false | ) |
Remove all devices (as as RemoveAllSenders()), the "force" flag must be used to remove also persistent devices.
std::list< albaDevice * > * albaDeviceManager::GetDevices | ( | ) |
return the list of active devices
|
inline |
return the device set storing first level devices
Definition at line 103 of file albaDeviceManager.h.
|
virtual |
Process an event: the event is processed immediately and synchronously, i.e.
the function doesn't return until the event is processed by someone. If the class cannot manage the event it is passed to its listeners on the same channel and so on, until it's processed.
Reimplemented from albaAgent.
|
virtual |
Redefined to manage the synchronization with display rendering: during the event dispatching all rendering requests must be queued.
For this reason at dispatching start a StartDispatchingEvent is (synchronously) sent on the default channel, and StopDispatchingEvent is sent when dispatching is finished
Reimplemented from albaAgentEventQueue.
|
protectedvirtual |
Implement storing and restoring of this object.
To store an XML Writer must be passed as argument, while to restore the node of the XML structure from where starting the restoring must must be passed.
Implements albaStorable.
|
protectedvirtual |
This is called by Restore() and must be reimplemented by subclasses The element from which the object should restore itself is passed as argument.
Implements albaStorable.
|
protectedvirtual |
This function is overridden by subclasses to perform custom initialization.
Reimplemented from albaAgent.
|
protectedvirtual |
to be redefined by subclasses to define the shutdown actions
Reimplemented from albaAgent.
|
protected |
container for first level devices
Definition at line 124 of file albaDeviceManager.h.
|
protected |
number of plugged devices
Definition at line 125 of file albaDeviceManager.h.
|
protected |
number of persistent plugged devices
Definition at line 126 of file albaDeviceManager.h.
|
protected |
Definition at line 127 of file albaDeviceManager.h.