IFactory.h
Go to the documentation of this file.
1 #ifndef WIRECELL_IFACTORY
2 #define WIRECELL_IFACTORY
3 
5 
6 namespace WireCell {
7 
8  class IFactory : public IComponent<IFactory> {
9  public:
10  virtual ~IFactory();
11 
12  /// Create an instance of what we know how to create.
13  virtual Interface::pointer create() = 0;
14 
15  /// Return existing instance or nullptr if not found.
16  virtual Interface::pointer find(const std::string& name) = 0;
17  };
18 
19  class INamedFactory : public IFactory {
20  public:
21 
22  typedef std::shared_ptr<INamedFactory> pointer;
23 
24  virtual ~INamedFactory();
25 
26  /// Set name of class this factory can make
27  virtual void set_classname(const std::string& name) = 0;
28  /// Access name of class this factory can make
29  virtual const std::string& classname() = 0;
30 
31  /// Create an instance by name.
32  virtual Interface::pointer create(const std::string& name) = 0;
33  using IFactory::create;
34 
35  /// Return existing instance or nullptr if not found.
36  virtual Interface::pointer find(const std::string& name) = 0;
37 
38  };
39 
40 }
41 
42 #endif
43 
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::shared_ptr< INamedFactory > pointer
Definition: IFactory.h:22
virtual Interface::pointer create()=0
Create an instance of what we know how to create.
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
Definition: Main.h:22
virtual Interface::pointer find(const std::string &name)=0
Return existing instance or nullptr if not found.