UFO
ObsFunctionBase.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 UCAR
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 
8 #ifndef UFO_FILTERS_OBSFUNCTIONS_OBSFUNCTIONBASE_H_
9 #define UFO_FILTERS_OBSFUNCTIONS_OBSFUNCTIONBASE_H_
10 
11 #include <map>
12 #include <string>
13 
14 #include <boost/noncopyable.hpp>
15 
16 #include "ioda/ObsDataVector.h"
18 
19 namespace ufo {
20 
21 class Variables;
22 
23 // -----------------------------------------------------------------------------
24 /// Base class for computing functions on observation data
25 
26 class ObsFunctionBase : private boost::noncopyable {
27  public:
28  explicit ObsFunctionBase(const eckit::LocalConfiguration conf = eckit::LocalConfiguration()) {}
29  virtual ~ObsFunctionBase() {}
30 
31 /// compute the result of the function
32  virtual void compute(const ObsFilterData &,
33  ioda::ObsDataVector<float> &) const = 0;
34 
35 /// geovals required to compute the function
36  virtual const ufo::Variables & requiredVariables() const = 0;
37 };
38 
39 // -----------------------------------------------------------------------------
40 
41 /// Obs Function Factory
43  public:
44  static ObsFunctionBase * create(const Variable &);
45  virtual ~ObsFunctionFactory() = default;
46  static bool functionExists(const std::string &);
47  protected:
48  explicit ObsFunctionFactory(const std::string &);
49  private:
50  virtual ObsFunctionBase * make(const eckit::LocalConfiguration conf) = 0;
51  static std::map < std::string, ObsFunctionFactory * > & getMakers() {
52  static std::map < std::string, ObsFunctionFactory * > makers_;
53  return makers_;
54  }
55 };
56 
57 // -----------------------------------------------------------------------------
58 
59 template<class T>
61  virtual ObsFunctionBase * make(const eckit::LocalConfiguration conf)
62  { return new T(conf); }
63  public:
64  explicit ObsFunctionMaker(const std::string & name)
65  : ObsFunctionFactory(name) {}
66 };
67 
68 // -----------------------------------------------------------------------------
69 
70 } // namespace ufo
71 
72 #endif // UFO_FILTERS_OBSFUNCTIONS_OBSFUNCTIONBASE_H_
ufo::Variables
Definition: src/ufo/filters/Variables.h:24
ufo::ObsFunctionBase::requiredVariables
virtual const ufo::Variables & requiredVariables() const =0
geovals required to compute the function
ufo::ObsFunctionFactory::functionExists
static bool functionExists(const std::string &)
Definition: ObsFunctionBase.cc:46
ufo::ObsFunctionBase
Base class for computing functions on observation data.
Definition: ObsFunctionBase.h:26
ufo::ObsFunctionFactory::~ObsFunctionFactory
virtual ~ObsFunctionFactory()=default
ufo
Definition: RunCRTM.h:27
ufo::ObsFunctionFactory::ObsFunctionFactory
ObsFunctionFactory(const std::string &)
Definition: ObsFunctionBase.cc:20
ufo::ObsFunctionMaker
Definition: ObsFunctionBase.h:60
ufo::ObsFunctionBase::compute
virtual void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const =0
compute the result of the function
ufo::ObsFunctionFactory::make
virtual ObsFunctionBase * make(const eckit::LocalConfiguration conf)=0
ufo::ObsFunctionFactory::getMakers
static std::map< std::string, ObsFunctionFactory * > & getMakers()
Definition: ObsFunctionBase.h:51
ufo::ObsFunctionMaker::make
virtual ObsFunctionBase * make(const eckit::LocalConfiguration conf)
Definition: ObsFunctionBase.h:61
ufo::ObsFunctionMaker::ObsFunctionMaker
ObsFunctionMaker(const std::string &name)
Definition: ObsFunctionBase.h:64
ioda::ObsDataVector
Definition: BackgroundCheck.h:26
ufo::ObsFunctionFactory
Obs Function Factory.
Definition: ObsFunctionBase.h:42
ObsFilterData.h
ufo::ObsFunctionBase::~ObsFunctionBase
virtual ~ObsFunctionBase()
Definition: ObsFunctionBase.h:29
ufo::ObsFunctionBase::ObsFunctionBase
ObsFunctionBase(const eckit::LocalConfiguration conf=eckit::LocalConfiguration())
Definition: ObsFunctionBase.h:28
ufo::Variable
Definition: Variable.h:23
ufo::ObsFilterData
ObsFilterData provides access to all data related to an ObsFilter.
Definition: src/ufo/filters/ObsFilterData.h:40
ufo::ObsFunctionFactory::create
static ObsFunctionBase * create(const Variable &)
Definition: ObsFunctionBase.cc:30
conf
Definition: conf.py:1