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;
26class albaView;
27class vtkRenderer;
28
41class ALBA_EXPORT albaDevice : public albaAgentThreaded, public albaStorable
42{
43public:
47 enum DEVICE_MINIMUM_ID {MIN_DEVICE_ID=1000000};
48
49 //------------------------------------------------------------------------------
50 // Events
51 //------------------------------------------------------------------------------
54 ALBA_ID_DEC(DEVICE_NAME_CHANGED)
55 ALBA_ID_DEC(DEVICE_STARTED);
56 ALBA_ID_DEC(DEVICE_STOPPED);
59 //----------------------------------------------------------------------------
60 // GUI Constants
61 //----------------------------------------------------------------------------
63 {
64 ID_NAME=MINID,
68 ID_LAST
69 };
70
72
75 unsigned long GetID() {return m_ID;};
76
79 void SetID(unsigned long id) {m_ID=id;};
80
82 virtual void SetName(const char *name);
83
86 void SetAutoStart(bool flag) {m_AutoStart=flag;}
87 bool GetAutoStart() { return m_AutoStart!=0;}
88
91 void AutoStartOn() {m_AutoStart=true;}
92
95 void AutoStartOff() {m_AutoStart=false;}
96
98 virtual int Start();
99
101 virtual void Stop();
102
106 virtual int StartUp() { return m_AutoStart?Start():0;}
107
113 void SetPersistentFlag(bool flag) { m_PersistentFalg = flag; }
114 bool GetPersistentFlag() {return m_PersistentFalg;}
115
117 bool IsPersistent() {return m_PersistentFalg;}
118
121
123 virtual void UpdateGui();
124
126 virtual void OnEvent(albaEventBase *event);
127
129 virtual albaView *GetView() {return NULL;}
130
132 virtual vtkRenderer *GetRenderer() {return NULL;}
133
134protected:
136 virtual ~albaDevice();
137
139 virtual int InternalInitialize();
140
142 virtual void CreateGui();
143
150
156
157
161 int m_Start; //SIL. 07-jun-2006 : -- connected to a Bool in the Gui
164
165private:
166 albaDevice(const albaDevice&); // Not implemented.
167 void operator=(const albaDevice&); // Not implemented.
168
170 int Initialize() {return Superclass::Initialize();}
171
173 void Shutdown() {Superclass::Shutdown();}
174};
175
176#endif
MINID
Definition: albaDecl.h:416
#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:217
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:61
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:42
void SetID(unsigned long id)
Set ID for this device.
Definition: albaDevice.h:79
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:106
virtual ~albaDevice()
bool GetAutoStart()
Definition: albaDevice.h:87
unsigned long GetID()
Get the ID for this device.
Definition: albaDevice.h:75
virtual int Start()
use this function to start (initialize) the device
virtual vtkRenderer * GetRenderer()
Return the renderer the device is interacting with, NULL if none.
Definition: albaDevice.h:132
bool m_Locked
Definition: albaDevice.h:162
void SetPersistentFlag(bool flag)
set peristent flag: a persistent device is not stored/restored and neither removed when settings are ...
Definition: albaDevice.h:113
void SetAutoStart(bool flag)
Set the AutoStart flag.
Definition: albaDevice.h:86
void AutoStartOff()
Disable autostarting of this device.
Definition: albaDevice.h:95
virtual int InternalInitialize()
start device
int m_AutoStart
Definition: albaDevice.h:160
albaID m_ID
Definition: albaDevice.h:159
bool m_PersistentFalg
Definition: albaDevice.h:163
bool GetPersistentFlag()
Definition: albaDevice.h:114
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:47
virtual void OnEvent(albaEventBase *event)
process events sent to the device
albaGUI * m_Gui
Definition: albaDevice.h:158
@ ID_AUTO_START
Definition: albaDevice.h:67
albaGUI * GetGui()
Return pointer to the GUI.
void AutoStartOn()
Enable autostarting of this device.
Definition: albaDevice.h:91
virtual albaView * GetView()
Return the view the device is interacting with, NULL if none.
Definition: albaDevice.h:129
bool IsPersistent()
return true if it's a persistent device.
Definition: albaDevice.h:117
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.
albaView is the base class for Views in alba.
Definition: albaView.h:78