Phoxonics  1.0
Object Oriented FDTD Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CellsFactory.hpp
Go to the documentation of this file.
1 /*
2  * CellsFactory.hpp
3  *
4  * Created on: Oct 23, 2014
5  * Author: cuda
6  */
7 
8 #ifndef CELLSFACTORY_HPP_
9 #define CELLSFACTORY_HPP_
10 
11 #include "CellsBase.hpp"
12 #include "../config/SimulationConfig.hpp"
13 #include "../common/FactoryBase.hpp"
14 #include "../../../common/common.hpp"
15 
16 #include <memory>
17 #include <string>
18 #include <map>
19 #include <functional>
20 
21 namespace phoxonics {
22 namespace core {
23 
24 // The factory - implements singleton pattern!
25 class CellsFactory : public FactoryBase {
26 public:
27  virtual ~CellsFactory();
28 
29  // Get the single instance of the factory
30  static CellsFactory* instance();
31 
32  // register a factory function to create an instance of class_name
33  void register_factory_function(std::string class_name,
34  std::function<CellsBase*(void)> class_factory_function);
35 
36  // create an instance of a registered class
37  std::shared_ptr<CellsBase> create(std::string class_name,
38  std::shared_ptr<phoxonics::core::SimulationConfig> sim_config);
39 
40 private:
41  // a private ctor
42  inline CellsFactory() {
43  };
44 
45  // the registry of factory functions
46  std::map<std::string, std::function<CellsBase*(void)>> factory_function_registry_;
47 };
48 
49 } /* namespace core */
50 } /* namespace phoxonics */
51 
52 #endif /* CELLSFACTORY_HPP_ */
std::shared_ptr< CellsBase > create(std::string class_name, std::shared_ptr< phoxonics::core::SimulationConfig > sim_config)
Definition: CellsFactory.cpp:30
static CellsFactory * instance()
Definition: CellsFactory.cpp:17
Definition: CellsBase.hpp:20
void register_factory_function(std::string class_name, std::function< CellsBase *(void)> class_factory_function)
Definition: CellsFactory.cpp:22
Definition: CommonBase.hpp:14
Definition: FactoryBase.hpp:16
virtual ~CellsFactory()
Definition: CellsFactory.cpp:13
Definition: CellsFactory.hpp:25