Debian Codegraph @

src/atlas/projection/detail/ProjectionFactory.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/projection/Projection.h"
16 #include "atlas/util/Factory.h"
17
18 namespace eckit {
19 class Parametrisation;
20 }
21
22 namespace atlas {
23 namespace projection {
24
25 //----------------------------------------------------------------------------------------------------------------------
26
27 class ProjectionFactory : public util::Factory<ProjectionFactory> {
28 public:
29 static std::string className() { return "ProjectionFactory"; }
30 static const Projection::Implementation* build(const std::string&);
31 static const Projection::Implementation* build(const std::string&, const eckit::Parametrisation&);
32 using Factory::Factory;
33
34 private:
35 virtual const Projection::Implementation* make(const eckit::Parametrisation&) = 0;
36 };
37
38 //----------------------------------------------------------------------------------------------------------------------
39
40 template <class T>
41 class ProjectionBuilder : public ProjectionFactory {
42 private:
43 virtual const Projection::Implementation* make(const eckit::Parametrisation& param) { return new T(param); }
44
45 public:
46 using ProjectionFactory::ProjectionFactory;
47 };
48
49 //----------------------------------------------------------------------------------------------------------------------
50
51 } // namespace projection
52 } // namespace atlas