Debian Codegraph @

src/atlas/interpolation/method/MethodFactory.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 <iosfwd>
14 #include <string>
15 #include <vector>
16
17 #include "atlas/interpolation/method/Method.h"
18 #include "atlas/util/Factory.h"
19 #include "atlas/util/Object.h"
20
21 #include "eckit/config/Configuration.h"
22
23 namespace atlas {
24 class Field;
25 class FieldSet;
26 class FunctionSpace;
27 class Grid;
28 } // namespace atlas
29
30 namespace atlas {
31 namespace interpolation {
32
33 struct MethodFactory : public util::Factory<MethodFactory> {
34 public:
35 static std::string className() { return "MethodFactory"; }
36 static Method* build(const std::string& name, const Method::Config&);
37
38 protected:
39 virtual Method* make(const Method::Config&) = 0;
40 using Factory::Factory;
41 };
42
43 template <class T>
44 struct MethodBuilder : public MethodFactory {
45 using MethodFactory::MethodFactory;
46
47 private:
48 virtual Method* make(const Method::Config& config) { return new T(config); }
49 };
50
51 } // namespace interpolation
52 } // namespace atlas