Debian Codegraph @

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