DABC (Data Acquisition Backbone Core)  2.9.9
Factory.cxx
Go to the documentation of this file.
1 #include "verbs/Factory.h"
2 
3 #include "dabc/Manager.h"
4 
5 #include "verbs/Device.h"
6 #include "verbs/Thread.h"
7 
9 
10 dabc::Reference verbs::Factory::CreateObject(const std::string &classname, const std::string &objname, dabc::Command cmd)
11 {
12  return 0;
13 }
14 
15 dabc::Device* verbs::Factory::CreateDevice(const std::string &classname,
16  const std::string &devname,
17  dabc::Command cmd)
18 {
19  if (classname == verbs::typeDevice) {
20  DOUT1("Creating verbs device");
21  return new verbs::Device(devname);
22  }
23 
24  return 0;
25 }
26 
27 dabc::Reference verbs::Factory::CreateThread(dabc::Reference parent, const std::string &classname, const std::string &thrdname, const std::string &thrddev, dabc::Command cmd)
28 {
29  if (classname != verbs::typeThread) return dabc::Reference();
30 
31  if (thrddev.empty()) {
32  EOUT("Device name not specified to create verbs thread");
33  return dabc::Reference();
34  }
35 
37 
38  if (dev.null()) {
39  EOUT("Did not found verbs device with name %s", thrddev.c_str());
40  return dabc::Reference();
41  }
42 
43  verbs::Thread* thrd = new verbs::Thread(parent, thrdname, cmd, dev()->IbContext());
44 
45  return dabc::Reference(thrd);
46 }
Represents command with its arguments.
Definition: Command.h:99
Base class for device implementation.
Definition: Device.h:43
Small helper class to correctly instantiate user-specific factories.
Definition: Factory.h:106
WorkerRef FindDevice(const std::string &name)
Definition: Manager.cxx:2013
Reference on the arbitrary object
Definition: Reference.h:73
bool null() const
Returns true if reference contains nullptr.
Definition: Reference.h:151
Refernce on verbs::Device
Definition: Device.h:89
Device for VERBS
Definition: Device.h:42
Factory for VERBS classes
Definition: Factory.h:14
virtual dabc::Reference CreateThread(dabc::Reference parent, const std::string &classname, const std::string &thrdname, const std::string &thrddev, dabc::Command cmd)
Factory method to create thread.
Definition: Factory.cxx:27
virtual dabc::Device * CreateDevice(const std::string &classname, const std::string &devname, dabc::Command cmd)
Factory method to create device.
Definition: Factory.cxx:15
virtual dabc::Reference CreateObject(const std::string &classname, const std::string &objname, dabc::Command cmd)
Factory method to create object.
Definition: Factory.cxx:10
VERBS thread.
Definition: Thread.h:46
#define EOUT(args ...)
Definition: logging.h:150
#define DOUT1(args ...)
Definition: logging.h:162
ManagerRef mgr
Definition: Manager.cxx:42
const char * typeThread
Definition: Context.cxx:36
const char * typeDevice
Definition: Context.cxx:37
dabc::FactoryPlugin verbsfactory(new verbs::Factory("verbs"))