FV3 Bundle
WeightingFct.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 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 nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_BASE_WEIGHTINGFCT_H_
12 #define OOPS_BASE_WEIGHTINGFCT_H_
13 
14 #include <map>
15 #include <string>
16 
17 #include "oops/util/DateTime.h"
18 
19 namespace eckit {
20  class Configuration;
21 }
22 
23 namespace util {
24  class Duration;
25 }
26 
27 namespace oops {
28 
29 // -----------------------------------------------------------------------------
30 
31 /// Weighting Function
32 /*!
33  * Abstract base class for weighting functions for various filters.
34  */
35 
36 class WeightingFct {
37  public:
38  virtual ~WeightingFct() {}
39 
40  virtual std::map< util::DateTime, double > setWeights(const util::DateTime &,
41  const util::DateTime &,
42  const util::Duration &) = 0;
43 };
44 
45 // -----------------------------------------------------------------------------
46 
47 /// Factory
49  public:
50  static WeightingFct * create(const eckit::Configuration &);
51  virtual ~WeightFactory() { makers_->clear(); }
52 
53  protected:
54  explicit WeightFactory(const std::string &);
55  private:
56  virtual WeightingFct * make(const eckit::Configuration &) = 0;
57  static std::map < std::string, WeightFactory * > * makers_;
58 };
59 
60 template<class FCT>
61 class WeightMaker : public WeightFactory {
62  virtual WeightingFct * make(const eckit::Configuration & config)
63  {return new FCT(config);}
64  public:
65  explicit WeightMaker(const std::string & name) : WeightFactory(name) {}
66 };
67 
68 // -----------------------------------------------------------------------------
69 
70 } // namespace oops
71 
72 #endif // OOPS_BASE_WEIGHTINGFCT_H_
virtual std::map< util::DateTime, double > setWeights(const util::DateTime &, const util::DateTime &, const util::Duration &)=0
virtual WeightingFct * make(const eckit::Configuration &)=0
virtual WeightingFct * make(const eckit::Configuration &config)
Definition: WeightingFct.h:62
static std::map< std::string, WeightFactory *> * makers_
Definition: WeightingFct.h:57
character(len=32) name
The namespace for the main oops code.
virtual ~WeightingFct()
Definition: WeightingFct.h:38
WeightMaker(const std::string &name)
Definition: WeightingFct.h:65
virtual ~WeightFactory()
Definition: WeightingFct.h:51
WeightFactory(const std::string &)
Definition: WeightingFct.cc:33
Weighting Function.
Definition: WeightingFct.h:36
static WeightingFct * create(const eckit::Configuration &)
Definition: WeightingFct.cc:45