| 1 |
/* |
| 2 |
* (C) Copyright 1996- 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 |
* |
| 7 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 8 |
* granted to it by virtue of its status as an intergovernmental organisation nor |
| 9 |
* does it submit to any jurisdiction. |
| 10 |
*/ |
| 11 |
|
| 12 |
|
| 13 |
#pragma once |
| 14 |
|
| 15 |
#include <string> |
| 16 |
|
| 17 |
#include "eckit/config/Parametrisation.h" |
| 18 |
|
| 19 |
#include "atlas/runtime/Exception.h" |
| 20 |
#include "atlas/util/Factory.h" |
| 21 |
#include "atlas/util/Object.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace atlas { |
| 25 |
class Field; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
namespace atlas { |
| 30 |
namespace field { |
| 31 |
namespace detail { |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* @brief Missing values indicator base class |
| 36 |
*/ |
| 37 |
struct MissingValue : util::Object { |
| 38 |
using Config = eckit::Parametrisation; |
| 39 |
virtual ~MissingValue() = default; |
| 40 |
virtual bool isnan() const = 0; |
| 41 |
virtual void metadata(Field&) const = 0; |
| 42 |
|
| 43 |
virtual bool operator()(const double&) const { ATLAS_NOTIMPLEMENTED; } |
| 44 |
virtual bool operator()(const float&) const { ATLAS_NOTIMPLEMENTED; } |
| 45 |
virtual bool operator()(const int&) const { ATLAS_NOTIMPLEMENTED; } |
| 46 |
virtual bool operator()(const long&) const { ATLAS_NOTIMPLEMENTED; } |
| 47 |
virtual bool operator()(const unsigned long&) const { ATLAS_NOTIMPLEMENTED; } |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
/** |
| 52 |
* @brief Missing values indicator factory |
| 53 |
*/ |
| 54 |
struct MissingValueFactory : util::Factory<MissingValueFactory> { |
| 55 |
using Config = MissingValue::Config; |
| 56 |
using Factory::Factory; |
| 57 |
static std::string className() { return "MissingValueFactory"; } |
| 58 |
static const MissingValue* build(const std::string&, const Config&); |
| 59 |
|
| 60 |
private: |
| 61 |
virtual const MissingValue* make(const Config&) = 0; |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
/** |
| 66 |
* @brief Missing values indicator builder for factory registration |
| 67 |
*/ |
| 68 |
template <class T> |
| 69 |
class MissingValueFactoryBuilder : public MissingValueFactory { |
| 70 |
private: |
| 71 |
virtual const MissingValue* make(const Config& config) override { return new T(config); } |
| 72 |
|
| 73 |
public: |
| 74 |
using MissingValueFactory::MissingValueFactory; |
| 75 |
}; |
| 76 |
|
| 77 |
|
| 78 |
} // namespace detail |
| 79 |
} // namespace field |
| 80 |
} // namespace atlas |