#ifndef INMOST_SOLVER_MASTER #define INMOST_SOLVER_MASTER #include #include namespace INMOST { struct SolverBaseFactory { virtual SolverInterface *create() = 0; virtual SolverInterface *copy(const SolverInterface *other) = 0; virtual ~SolverBaseFactory() {}; }; template struct SolverCreateFactory : SolverBaseFactory { SolverInterface *create() { return new C(); }; SolverInterface *copy(const SolverInterface *other) { return new C(other); }; }; class SolverMaster { private: static std::map solvers; template static void registerSolver(std::string name) { solvers.insert(std::make_pair(name, new SolverCreateFactory)); }; static SolverInterface *getSolver(std::string name); static SolverInterface *copySolver(const SolverInterface *other); static std::vector getAvailableSolvers(); static bool isSolverAvailable(std::string name); friend Solver::Solver(std::string solverName, std::string prefix, INMOST_MPI_Comm _comm); friend Solver::Solver(const Solver &other); friend void Solver::Initialize(int *argc, char ***argv, const char *database); friend bool Solver::isSolverAvailable(std::string name); friend std::vector Solver::getAvailableSolvers(); }; typedef std::map::iterator solvers_map_iterator_t; } #endif //INMOST_SOLVER_MASTER