OOPS
PostBase.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_POSTBASE_H_
12 #define OOPS_BASE_POSTBASE_H_
13 
14 #include <boost/noncopyable.hpp>
15 
16 #include "eckit/config/Configuration.h"
17 #include "oops/base/PostTimer.h"
18 #include "oops/util/DateTime.h"
19 #include "oops/util/Duration.h"
20 
21 namespace oops {
22 
23 // -----------------------------------------------------------------------------
24 
25 /// Handles post-processing of model fields.
26 /*!
27  * PostBase is the base class for all state post processors, it
28  * is mostly used so that PostProcessor can hold a vector of such
29  * processors.
30  * By default processing is performed on every call.
31  */
32 
33 template <typename FLDS> class PostBase : private boost::noncopyable {
34  public:
35 /// Constructors and basic operators
36  PostBase() : timer_() {}
37  explicit PostBase(const eckit::Configuration & conf) : timer_(conf) {}
38  PostBase(const util::DateTime & start, const util::DateTime & finish,
39  const util::Duration & freq = util::Duration(0))
40  : timer_(start, finish, freq) {}
41 
42  virtual ~PostBase() {}
43 
44 /// Setup
45  void initialize(const FLDS & xx, const util::DateTime & end,
46  const util::Duration & tstep) {
47  timer_.initialize(xx.validTime(), end);
48  this->doInitialize(xx, end, tstep);
49  }
50 
51 /// Process state or increment
52  void process(const FLDS & xx) {
53  if (timer_.itIsTime(xx.validTime())) this->doProcessing(xx);
54  }
55 
56 /// Final
57  void finalize(const FLDS & xx) {
58  this->doFinalize(xx);
59  }
60 
61  private:
63 
64 /// Actual processing
65  virtual void doProcessing(const FLDS &) = 0;
66  virtual void doInitialize(const FLDS &, const util::DateTime &,
67  const util::Duration &) {}
68  virtual void doFinalize(const FLDS &) {}
69 };
70 
71 // -----------------------------------------------------------------------------
72 
73 } // namespace oops
74 
75 #endif // OOPS_BASE_POSTBASE_H_
Handles post-processing of model fields.
Definition: PostBase.h:33
virtual void doProcessing(const FLDS &)=0
Actual processing.
PostBase(const util::DateTime &start, const util::DateTime &finish, const util::Duration &freq=util::Duration(0))
Definition: PostBase.h:38
virtual void doFinalize(const FLDS &)
Definition: PostBase.h:68
PostBase(const eckit::Configuration &conf)
Definition: PostBase.h:37
void finalize(const FLDS &xx)
Final.
Definition: PostBase.h:57
void initialize(const FLDS &xx, const util::DateTime &end, const util::Duration &tstep)
Setup.
Definition: PostBase.h:45
virtual void doInitialize(const FLDS &, const util::DateTime &, const util::Duration &)
Definition: PostBase.h:66
PostBase()
Constructors and basic operators.
Definition: PostBase.h:36
virtual ~PostBase()
Definition: PostBase.h:42
PostTimer timer_
Definition: PostBase.h:62
void process(const FLDS &xx)
Process state or increment.
Definition: PostBase.h:52
Handles timing of post-processing and similar actions.
bool itIsTime(const util::DateTime &)
void initialize(const util::DateTime &, const util::DateTime &)
The namespace for the main oops code.