Debian Codegraph @

src/atlas/meshgenerator/detail/MeshGeneratorFactory.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <string>
14
15 #include "atlas/util/Config.h"
16 #include "atlas/util/Factory.h"
17
18 namespace atlas {
19 namespace meshgenerator {
20
21 //----------------------------------------------------------------------------------------------------------------------
22
23 class MeshGeneratorImpl;
24 class MeshGeneratorFactory : public util::Factory<MeshGeneratorFactory> {
25 public:
26 static std::string className() { return "MeshGeneratorFactory"; }
27 static const MeshGeneratorImpl* build(const std::string&);
28 static const MeshGeneratorImpl* build(const std::string&, const eckit::Parametrisation&);
29 using Factory::Factory;
30
31 private:
32 virtual const MeshGeneratorImpl* make(const eckit::Parametrisation&) = 0;
33 };
34
35 //----------------------------------------------------------------------------------------------------------------------
36
37 template <class T>
38 class MeshGeneratorBuilder : public MeshGeneratorFactory {
39 private:
40 virtual const MeshGeneratorImpl* make(const eckit::Parametrisation& param) { return new T(param); }
41
42 public:
43 using MeshGeneratorFactory::MeshGeneratorFactory;
44 };
45
46 //----------------------------------------------------------------------------------------------------------------------
47
48 } // namespace meshgenerator
49 } // namespace atlas