| 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 <array> |
| 14 |
#include <string> |
| 15 |
#include <vector> |
| 16 |
|
| 17 |
#include "atlas/util/Object.h" |
| 18 |
|
| 19 |
namespace eckit { |
| 20 |
class Parametrisation; |
| 21 |
} |
| 22 |
|
| 23 |
namespace atlas { |
| 24 |
namespace util { |
| 25 |
class Config; |
| 26 |
} |
| 27 |
} // namespace atlas |
| 28 |
|
| 29 |
namespace atlas { |
| 30 |
namespace grid { |
| 31 |
namespace spacing { |
| 32 |
|
| 33 |
class Spacing : public util::Object { |
| 34 |
public: |
| 35 |
using const_iterator = std::vector<double>::const_iterator; |
| 36 |
using Interval = std::array<double, 2>; |
| 37 |
using Spec = atlas::util::Config; |
| 38 |
|
| 39 |
public: |
| 40 |
static const Spacing* create(const eckit::Parametrisation& params); |
| 41 |
|
| 42 |
virtual std::string type() const = 0; |
| 43 |
|
| 44 |
double operator[](size_t i) const { return x_[i]; } |
| 45 |
|
| 46 |
size_t size() const { return x_.size(); } |
| 47 |
|
| 48 |
const double* data() const { return x_.data(); } |
| 49 |
|
| 50 |
const_iterator begin() const { return x_.begin(); } |
| 51 |
const_iterator end() const { return x_.end(); } |
| 52 |
|
| 53 |
double front() const { return x_.front(); } |
| 54 |
double back() const { return x_.back(); } |
| 55 |
|
| 56 |
Interval interval() const { return {{min_, max_}}; } |
| 57 |
|
| 58 |
double min() const { return min_; } |
| 59 |
double max() const { return max_; } |
| 60 |
|
| 61 |
virtual Spec spec() const = 0; |
| 62 |
|
| 63 |
protected: |
| 64 |
std::vector<double> x_; |
| 65 |
double min_; |
| 66 |
double max_; |
| 67 |
}; |
| 68 |
|
| 69 |
} // namespace spacing |
| 70 |
} // namespace grid |
| 71 |
} // namespace atlas |