Alsvinn  0.5.3
The fast FVM simulator with UQ support
Factory.hpp
Go to the documentation of this file.
1 #pragma once
3 namespace alsutils {
4 namespace base {
5 
37 template<class T, class ... Args>
38 class Factory {
39 public:
40 
41  typedef typename impl::FactoryRegistry<T, Args...>::PointerType PointerType;
42  typedef typename impl::FactoryRegistry<T, Args...>::CreatorType CreatorType;
43 
45  static PointerType createInstance(const std::string& name, Args... args) {
47  args...);
48  }
49 
53  static bool registerClass(const std::string& name,
54  CreatorType creator) {
56  creator);
57  }
58 
59 
63  template<class C>
64  static bool registerClassWithOnlyConstructor(const std::string& name) {
66  registerClassWithOnlyConstructor<C>(name);
67  }
68 };
69 } // namespace base
70 } // namespace alsutils
bool registerClass(const std::string &name, CreatorType creator)
Definition: FactoryRegistry.hpp:36
Definition: FactoryRegistry.hpp:23
PointerType createInstance(const std::string &name, Args... args)
Creates a new instance of the class with the given name and arguments.
Definition: FactoryRegistry.hpp:62
static bool registerClassWithOnlyConstructor(const std::string &name)
Definition: Factory.hpp:64
impl::FactoryRegistry< T, Args... >::PointerType PointerType
Definition: Factory.hpp:41
Definition: Factory.hpp:38
static PointerType createInstance(const std::string &name, Args... args)
Creates a new instance of the class with the given name and arguments.
Definition: Factory.hpp:45
std::string name
Definition: EquationParameterFactory.cpp:39
Various utilities for mpi and cuda.
Definition: Factory.hpp:3
static FactoryRegistry & getInstance()
Gets the singleton instance of this class.
Definition: FactoryRegistry.hpp:72
impl::FactoryRegistry< T, Args... >::CreatorType CreatorType
Definition: Factory.hpp:42
static bool registerClass(const std::string &name, CreatorType creator)
Definition: Factory.hpp:53