DABC (Data Acquisition Backbone Core)  2.9.9
Factory.cxx
Go to the documentation of this file.
1 // $Id: Factory.cxx 3862 2018-05-11 10:06:18Z 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 #include "stream/Factory.h"
17 
18 #include "dabc/Url.h"
19 #include "dabc/Port.h"
20 #include "dabc/Manager.h"
21 
22 #include "stream/RunModule.h"
25 
27 
28 dabc::Module* stream::Factory::CreateModule(const std::string &classname, const std::string &modulename, dabc::Command cmd)
29 {
30  if (classname == "stream::RunModule")
31  return new stream::RunModule(modulename, cmd);
32 
33  if (classname == "stream::TdcCalibrationModule")
34  return new stream::TdcCalibrationModule(modulename, cmd);
35 
36  if (classname == "stream::RecalibrateModule")
37  return new stream::RecalibrateModule(modulename, cmd);
38 
39  return dabc::Factory::CreateModule(classname, modulename, cmd);
40 }
41 
42 
43 dabc::Module* stream::Factory::CreateTransport(const dabc::Reference& port, const std::string &typ, dabc::Command cmd)
44 {
45  dabc::Url url(typ);
46 
47  dabc::PortRef portref = port;
48 
49  if (!portref.IsOutput() || (url.GetProtocol()!="stream"))
50  return dabc::Factory::CreateTransport(port, typ, cmd);
51 
52  cmd.SetBool("use_autotdc", true);
53  cmd.SetStr("fileurl", typ);
54 
55  dabc::mgr.app().AddObject("module", "StreamMonitor");
56 
57  return new stream::RunModule("StreamMonitor", cmd);
58 }
bool AddObject(const std::string &kind, const std::string &name)
Adds object into application list List used when objects must be destroyed or application start/stop ...
Represents command with its arguments.
Definition: Command.h:99
bool SetStr(const std::string &name, const char *value)
Definition: Command.h:134
bool SetBool(const std::string &name, bool v)
Definition: Command.h:141
Small helper class to correctly instantiate user-specific factories.
Definition: Factory.h:106
virtual Module * CreateTransport(const Reference &port, const std::string &typ, Command cmd)
Factory method to create transport.
Definition: Factory.cxx:61
virtual Module * CreateModule(const std::string &classname, const std::string &modulename, Command cmd)
Factory method to create module.
Definition: Factory.h:67
ApplicationRef app()
Definition: Manager.cxx:2074
Base for dabc::ModuleSync and dabc::ModuleAsync classes.
Definition: Module.h:42
Reference on the dabc::Port class
Definition: Port.h:195
bool IsOutput() const
Returns true if it is output port.
Definition: Port.h:202
Reference on the arbitrary object
Definition: Reference.h:73
Uniform Resource Locator interpreter.
Definition: Url.h:33
Factory for HADAQ classes
Definition: Factory.h:29
virtual dabc::Module * CreateModule(const std::string &classname, const std::string &modulename, dabc::Command cmd)
Factory method to create module.
Definition: Factory.cxx:28
virtual dabc::Module * CreateTransport(const dabc::Reference &port, const std::string &typ, dabc::Command cmd)
Factory method to create transport.
Definition: Factory.cxx:43
Runs code of stream framework.
Runs code of stream framework.
Definition: RunModule.h:36
Perform calibration of FPGA TDC data.
ManagerRef mgr
Definition: Manager.cxx:42
dabc::FactoryPlugin streamfactory(new stream::Factory("stream"))