ALBA
albaDevice.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaDevice
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaDevice_h
17#define __albaDevice_h
18
19#include "albaAgentThreaded.h"
20#include "albaStorable.h"
21
22//----------------------------------------------------------------------------
23// forward declarations :
24//----------------------------------------------------------------------------
25class albaGUI;
26
39class ALBA_EXPORT albaDevice : public albaAgentThreaded, public albaStorable
40{
41public:
45 enum DEVICE_MINIMUM_ID {MIN_DEVICE_ID=1000000};
46
47 //------------------------------------------------------------------------------
48 // Events
49 //------------------------------------------------------------------------------
52 ALBA_ID_DEC(DEVICE_NAME_CHANGED)
53 ALBA_ID_DEC(DEVICE_STARTED);
54 ALBA_ID_DEC(DEVICE_STOPPED);
57 //----------------------------------------------------------------------------
58 // GUI Constants
59 //----------------------------------------------------------------------------
61 {
62 ID_NAME=MINID,
66 ID_LAST
67 };
68
70
73 unsigned long GetID() {return m_ID;};
74
77 void SetID(unsigned long id) {m_ID=id;};
78
80 virtual void SetName(const char *name);
81
84 void SetAutoStart(bool flag) {m_AutoStart=flag;}
85 bool GetAutoStart() { return m_AutoStart!=0;}
86
89 void AutoStartOn() {m_AutoStart=true;}
90
93 void AutoStartOff() {m_AutoStart=false;}
94
96 virtual int Start();
97
99 virtual void Stop();
100
104 virtual int StartUp() { return m_AutoStart?Start():0;}
105
111 void SetPersistentFlag(bool flag) { m_PersistentFalg = flag; }
112 bool GetPersistentFlag() {return m_PersistentFalg;}
113
115 bool IsPersistent() {return m_PersistentFalg;}
116
119
121 virtual void UpdateGui();
122
124 virtual void OnEvent(albaEventBase *event);
125
126protected:
128 virtual ~albaDevice();
129
131 virtual int InternalInitialize();
132
134 virtual void CreateGui();
135
142
148
149
153 int m_Start; //SIL. 07-jun-2006 : -- connected to a Bool in the Gui
156
157private:
158 albaDevice(const albaDevice&); // Not implemented.
159 void operator=(const albaDevice&); // Not implemented.
160
162 int Initialize() {return Superclass::Initialize();}
163
165 void Shutdown() {Superclass::Shutdown();}
166};
167
168#endif
MINID
Definition: albaDecl.h:420
#define ALBA_ID_DEC(idname)
This macros is used to define a new Id and should be placed in a .cpp file.
Definition: albaDefines.h:214
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:58
An agent processing the queued events on a separate thread.
void Shutdown()
Shutdown the agent, Subclasses can redefine InternalShutdown() to customize actions for shutting down...
int Initialize()
Initialize this agent.
This abstract class manages function calls coming from devices and issue specific events to interacto...
Definition: albaDevice.h:40
void SetID(unsigned long id)
Set ID for this device.
Definition: albaDevice.h:77
virtual void SetName(const char *name)
Set the Device name and rise an event to advise consumers.
virtual int InternalRestore(albaStorageElement *node)
This function fills in the device with settings restored from the node.
albaTypeMacro(albaDevice, albaAgentThreaded)
virtual int StartUp()
This checks AutoStart flag and if true Initialize the device Return false if AutoStart is OFF or init...
Definition: albaDevice.h:104
virtual ~albaDevice()
bool GetAutoStart()
Definition: albaDevice.h:85
unsigned long GetID()
Get the ID for this device.
Definition: albaDevice.h:73
virtual int Start()
use this function to start (initialize) the device
bool m_Locked
Definition: albaDevice.h:154
void SetPersistentFlag(bool flag)
set peristent flag: a persistent device is not stored/restored and neither removed when settings are ...
Definition: albaDevice.h:111
void SetAutoStart(bool flag)
Set the AutoStart flag.
Definition: albaDevice.h:84
void AutoStartOff()
Disable autostarting of this device.
Definition: albaDevice.h:93
virtual int InternalInitialize()
start device
int m_AutoStart
Definition: albaDevice.h:152
albaID m_ID
Definition: albaDevice.h:151
bool m_PersistentFalg
Definition: albaDevice.h:155
bool GetPersistentFlag()
Definition: albaDevice.h:112
virtual void CreateGui()
Create the dialog that show the interface for settings.
virtual int InternalStore(albaStorageElement *node)
This is used to allow nested serialization of subclasses.
virtual void UpdateGui()
used to force Gui to update its content
virtual void Stop()
use this function to stop (shutdown) the device
DEVICE_MINIMUM_ID
non persistent device IDs start from ALBA_MIN_DEVICE_ID.
Definition: albaDevice.h:45
virtual void OnEvent(albaEventBase *event)
process events sent to the device
albaGUI * m_Gui
Definition: albaDevice.h:150
@ ID_AUTO_START
Definition: albaDevice.h:65
albaGUI * GetGui()
Return pointer to the GUI.
void AutoStartOn()
Enable autostarting of this device.
Definition: albaDevice.h:89
bool IsPersistent()
return true if it's a persistent device.
Definition: albaDevice.h:115
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
albaStorable is an interface for serializable objects.
Definition: albaStorable.h:41
Abstract class representing the interface for the unit of information stored in the storage.