DABC (Data Acquisition Backbone Core)  2.9.9
Factory.h
Go to the documentation of this file.
1 // $Id: Factory.h 4467 2020-04-15 12:35:01Z 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_Factory
17 #define DABC_Factory
18 
19 #ifndef DABC_Command
20 #include "dabc/Command.h"
21 #endif
22 
25 namespace dabc {
26 
27  class Module;
28  class DataInput;
29  class DataOutput;
30  class Command;
31  class Device;
32  class Thread;
33  class Application;
34  class Configuration;
35  class Transport;
36  class FactoryPlugin;
37 
47  class Factory : public Object {
48  friend class Manager;
49  friend class FactoryPlugin;
50 
51  public:
52  Factory(const std::string &name);
53 
55  virtual Application* CreateApplication(const std::string &classname, Command cmd) { return nullptr; }
56 
58  virtual Reference CreateObject(const std::string &classname, const std::string &objname, Command cmd) { return nullptr; }
59 
61  virtual Device* CreateDevice(const std::string &classname, const std::string &devname, Command cmd) { return nullptr; }
62 
64  virtual Reference CreateThread(Reference parent, const std::string &classname, const std::string &thrdname, const std::string &thrddev, Command cmd) { return Reference(); }
65 
67  virtual Module* CreateModule(const std::string &classname, const std::string &modulename, Command cmd) { return nullptr; }
68 
70  virtual Module* CreateTransport(const Reference& port, const std::string &typ, Command cmd);
71 
73  virtual DataInput* CreateDataInput(const std::string &typ) { return nullptr; }
74 
76  virtual DataOutput* CreateDataOutput(const std::string &typ) { return nullptr; }
77 
79  virtual void* CreateAny(const std::string &classname, const std::string &objname, Command cmd) { return nullptr; }
80 
81  static bool LoadLibrary(const std::string &fname);
82 
83  static void* FindSymbol(const std::string &symbol);
84 
85  static bool CreateManager(const std::string &name = "mgr", Configuration* cfg = nullptr);
86 
87  virtual const char* ClassName() const { return "Factory"; }
88 
89  protected:
90 
93  virtual void Initialize() {}
94  };
95 
96 
97  // ==============================================================================
98 
106  class FactoryPlugin {
107  public:
109  };
110 
111 }
112 
113 #endif
FactoryPlugin(dabc::Factory *f)
Definition: Factory.cxx:101
Factory for user-specific classes
Definition: Factory.h:47
virtual Reference CreateThread(Reference parent, const std::string &classname, const std::string &thrdname, const std::string &thrddev, Command cmd)
Factory method to create thread.
Definition: Factory.h:64
friend class FactoryPlugin
Definition: Factory.h:49
virtual const char * ClassName() const
Returns class name of the object instance.
Definition: Factory.h:87
virtual Application * CreateApplication(const std::string &classname, Command cmd)
Factory method to create application.
Definition: Factory.h:55
static void * FindSymbol(const std::string &symbol)
Definition: Factory.cxx:49
virtual Module * CreateTransport(const Reference &port, const std::string &typ, Command cmd)
Factory method to create transport.
Definition: Factory.cxx:61
virtual DataOutput * CreateDataOutput(const std::string &typ)
Factory method to create data output.
Definition: Factory.h:76
virtual void * CreateAny(const std::string &classname, const std::string &objname, Command cmd)
Factory method to create arbitrary object kind.
Definition: Factory.h:79
virtual Device * CreateDevice(const std::string &classname, const std::string &devname, Command cmd)
Factory method to create device.
Definition: Factory.h:61
static bool LoadLibrary(const std::string &fname)
Definition: Factory.cxx:26
virtual DataInput * CreateDataInput(const std::string &typ)
Factory method to create data input.
Definition: Factory.h:73
Factory(const std::string &name)
Definition: Factory.cxx:54
virtual Module * CreateModule(const std::string &classname, const std::string &modulename, Command cmd)
Factory method to create module.
Definition: Factory.h:67
static bool CreateManager(const std::string &name="mgr", Configuration *cfg=nullptr)
Definition: Factory.cxx:40
friend class Manager
Definition: Factory.h:48
virtual Reference CreateObject(const std::string &classname, const std::string &objname, Command cmd)
Factory method to create object.
Definition: Factory.h:58
virtual void Initialize()
Method called by the manager during application start.
Definition: Factory.h:93
friend class Reference
Definition: Object.h:118
Event manipulation API.
Definition: api.h:23