Belle II Software  release-08-01-10
CreatorManager.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <string>
12 #include <map>
13 
14 namespace Belle2 {
19  namespace geometry {
20 
21  class CreatorBase;
22 
25  public:
28 
35  static void registerCreatorFactory(const std::string& name, CreatorFactory* factory);
36 
51  static CreatorBase* getCreator(const std::string& name, const std::string& library = "");
52 
53  protected:
57  CreatorManager(const CreatorManager&) = delete;
59  void operator=(const CreatorManager&) = delete;
61  static CreatorManager& getInstance();
63  std::map<std::string, CreatorFactory*> m_creatorFactories;
64  };
65 
66  }
68 } //end of namespace Belle2
Pure virtual base class for all geometry creators.
Definition: CreatorBase.h:28
Class to manage all creators and provide factory access.
static void registerCreatorFactory(const std::string &name, CreatorFactory *factory)
Register a new creator by providing a name and a pointer to a factory for this kind of creator.
static CreatorBase * getCreator(const std::string &name, const std::string &library="")
Return a new instance of a creator with the given name.
void operator=(const CreatorManager &)=delete
singleton, hide assignment operator
std::map< std::string, CreatorFactory * > m_creatorFactories
Static map to hold all registered factories.
CreatorManager()
singleton, hide constructor
static CreatorManager & getInstance()
getter for the singleton instance
CreatorManager(const CreatorManager &)=delete
singleton, hide copy constructor
CreatorBase * CreatorFactory()
Typedef for a factory function.
Abstract base class for different kinds of events.
Very simple class to provide an easy way to register creators with the CreatorManager.