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