DABC (Data Acquisition Backbone Core)  2.9.9
Device.h
Go to the documentation of this file.
1 // $Id: Device.h 4781 2021-07-14 12:28:15Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_Device
17 #define DABC_Device
18 
19 #ifndef DABC_Worker
20 #include "dabc/Worker.h"
21 #endif
22 
23 namespace dabc {
24 
25  class Transport;
26 
27  class DeviceRef;
28 
43  class Device : public Worker {
44 
45  friend class DeviceRef;
46 
47  protected:
49 
50  bool fDeviceDestroyed;
51 
52  Device(const std::string &name);
53 
54  virtual bool Find(ConfigIO &cfg);
55 
57  Mutex* DeviceMutex() const { return ObjectMutex(); }
58 
59  virtual void ObjectCleanup();
60 
61  public:
62  virtual ~Device();
63 
64  virtual int ExecuteCommand(Command cmd);
65 
66  virtual Transport* CreateTransport(Command cmd, const Reference& port) { return 0; }
67 
68  virtual const char* ClassName() const { return dabc::typeDevice; }
69  };
70 
71 
79  class DeviceRef : public WorkerRef {
80 
81  DABC_REFERENCE(DeviceRef, WorkerRef, Device)
82 
83  bool DeviceDestroyed() const { return null() ? false : GetObject()->fDeviceDestroyed; }
84  };
85 
86 };
87 
88 #endif
#define DABC_REFERENCE(RefClass, ParentClass, T)
Definition: Reference.h:222
bool DeviceDestroyed() const
Definition: Device.h:83
@ eventDeviceLast
Definition: Device.h:48
virtual void ObjectCleanup()
Central cleanup method for worker.
Definition: Device.cxx:35
virtual const char * ClassName() const
Returns class name of the object instance.
Definition: Device.h:68
virtual bool Find(ConfigIO &cfg)
Method to locate object in xml file.
Definition: Device.cxx:87
bool fDeviceDestroyed
if true, device and all transports should not be used
Definition: Device.h:50
Mutex * DeviceMutex() const
Returns device mutex - it is just object mutex.
Definition: Device.h:57
virtual Transport * CreateTransport(Command cmd, const Reference &port)
Definition: Device.h:66
friend class DeviceRef
Definition: Device.h:45
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
Definition: Device.cxx:43
virtual ~Device()
Definition: Device.cxx:29
Device(const std::string &name)
Definition: Device.cxx:22
friend class Reference
Definition: Object.h:118
Mutex * ObjectMutex() const
Returns mutex, used for protection of Object data members.
Definition: Object.h:190
Object * GetObject() const
Return pointer on the object.
Definition: Reference.h:129
friend class Command
Definition: Worker.h:128
@ evntFirstUser
Definition: Worker.h:203
Event manipulation API.
Definition: api.h:23
const char * typeDevice
Definition: Object.cxx:78