ALBA
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
albaDeviceManager Class Reference

#include <albaDeviceManager.h>

Inheritance diagram for albaDeviceManager:
Inheritance graph
[legend]
Collaboration diagram for albaDeviceManager:
Collaboration graph
[legend]

Public Member Functions

 albaDeviceManager ()
 
virtual ~albaDeviceManager ()
 
 albaTypeMacro (albaDeviceManager, albaAgentEventHandler)
 
virtual albaID AddDevice (albaDevice *device)
 
virtual albaDeviceAddDevice (const char *type, bool persistent=false)
 
int RemoveDevice (albaDevice *device, bool force=false)
 
int RemoveDevice (const char *name, bool force=false)
 
albaDeviceGetDevice (const char *name)
 
albaDeviceGetDevice (albaID id)
 
int GetNumberOfDevices ()
 
void RemoveAllDevices (bool force=false)
 
std::list< albaDevice * > * GetDevices ()
 
albaDeviceSetGetDeviceSet ()
 
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)
 
albaEventBasePeekEvent ()
 
albaEventBasePeekLastEvent ()
 
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 albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () 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)
 
albaObserverCallbackAddObserverCallback (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 albaObserverGetListener ()
 
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)
 
albaObjectCastToObject ()
 
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 ()
 
albaEventBasePopEvent ()
 
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

albaDeviceSetm_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
 
albaMutexLockm_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
albaObserverm_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 albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 
- Static Public Member Functions inherited from albaStorable
static albaStorableSafeCastToObject (albaObject *o)
 
- Protected Types inherited from albaEventBroadcaster
typedef std::list< albaObserver * > albaObserversList
 

Detailed Description

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

See also
albaAgentEventThreaded.

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.

See also
albaDevice albaDeviceSet
Todo:

Definition at line 52 of file albaDeviceManager.h.

Constructor & Destructor Documentation

◆ ~albaDeviceManager()

virtual albaDeviceManager::~albaDeviceManager ( )
virtual

Member Function Documentation

◆ albaTypeMacro()

albaDeviceManager::albaTypeMacro ( albaDeviceManager  ,
albaAgentEventHandler   
)

◆ AddDevice() [1/2]

virtual albaID albaDeviceManager::AddDevice ( albaDevice device)
virtual

Add a new device.

If the returned value is 0 the operation has failed!

◆ AddDevice() [2/2]

virtual albaDevice * albaDeviceManager::AddDevice ( const char *  type,
bool  persistent = false 
)
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

◆ RemoveDevice() [1/2]

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

◆ RemoveDevice() [2/2]

int albaDeviceManager::RemoveDevice ( const char *  name,
bool  force = false 
)

Remove a device with the given name from the manager's list.

◆ GetDevice() [1/2]

albaDevice * albaDeviceManager::GetDevice ( const char *  name)

Return a device handler given its name.

◆ GetDevice() [2/2]

albaDevice * albaDeviceManager::GetDevice ( albaID  id)

Return a device handler given its ID.

Persistent devices have ID < MIN_DEVICE_ID

◆ GetNumberOfDevices()

int albaDeviceManager::GetNumberOfDevices ( )

Return the number of devices assigned to this manager.

◆ RemoveAllDevices()

void albaDeviceManager::RemoveAllDevices ( bool  force = false)

Remove all devices (as as RemoveAllSenders()), the "force" flag must be used to remove also persistent devices.

◆ GetDevices()

std::list< albaDevice * > * albaDeviceManager::GetDevices ( )

return the list of active devices

◆ GetDeviceSet()

albaDeviceSet * albaDeviceManager::GetDeviceSet ( )
inline

return the device set storing first level devices

Definition at line 103 of file albaDeviceManager.h.

◆ OnEvent()

virtual void albaDeviceManager::OnEvent ( albaEventBase event)
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.

◆ DispatchEvents()

virtual bool albaDeviceManager::DispatchEvents ( )
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.

◆ InternalStore()

virtual int albaDeviceManager::InternalStore ( albaStorageElement node)
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.

◆ InternalRestore()

virtual int albaDeviceManager::InternalRestore ( albaStorageElement node)
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.

◆ InternalInitialize()

virtual int albaDeviceManager::InternalInitialize ( )
protectedvirtual

This function is overridden by subclasses to perform custom initialization.

Reimplemented from albaAgent.

◆ InternalShutdown()

virtual void albaDeviceManager::InternalShutdown ( )
protectedvirtual

to be redefined by subclasses to define the shutdown actions

Reimplemented from albaAgent.

Member Data Documentation

◆ m_DeviceSet

albaDeviceSet* albaDeviceManager::m_DeviceSet
protected

container for first level devices

Definition at line 124 of file albaDeviceManager.h.

◆ m_DeviceIdCounter

albaID albaDeviceManager::m_DeviceIdCounter
protected

number of plugged devices

Definition at line 125 of file albaDeviceManager.h.

◆ m_PersistentDeviceIdCounter

albaID albaDeviceManager::m_PersistentDeviceIdCounter
protected

number of persistent plugged devices

Definition at line 126 of file albaDeviceManager.h.

◆ m_RestoringFlag

bool albaDeviceManager::m_RestoringFlag
protected

Definition at line 127 of file albaDeviceManager.h.


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