FV3 Bundle
ObsTestsFixture.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 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 TEST_INTERFACE_OBSTESTSFIXTURE_H_
9 #define TEST_INTERFACE_OBSTESTSFIXTURE_H_
10 
11 #include <string>
12 
13 #include <boost/noncopyable.hpp>
14 #include <boost/scoped_ptr.hpp>
15 
16 #include "eckit/config/LocalConfiguration.h"
17 #include "oops/base/ObsSpaces.h"
18 #include "oops/runs/Test.h"
19 #include "oops/util/DateTime.h"
20 #include "oops/util/Logger.h"
21 #include "test/TestEnvironment.h"
22 
23 namespace test {
24 
25 // -----------------------------------------------------------------------------
26 
27 template <typename MODEL>
28 class ObsTestsFixture : private boost::noncopyable {
30 
31  public:
32  static const util::DateTime & tbgn() {return *getInstance().tbgn_;}
33  static const util::DateTime & tend() {return *getInstance().tend_;}
34  static ObsSpaces_ & obspace() {return *getInstance().ospaces_;}
35 
36  private:
38  tbgn_.reset(new util::DateTime(TestEnvironment::config().getString("window_begin")));
39  tend_.reset(new util::DateTime(TestEnvironment::config().getString("window_end")));
40 
41  const eckit::LocalConfiguration conf(TestEnvironment::config(), "Observations");
42  ospaces_.reset(new ObsSpaces_(conf, *tbgn_, *tend_));
43  }
44 
46 
48  static ObsTestsFixture<MODEL> theObsTestsFixture;
49  return theObsTestsFixture;
50  }
51 
52  boost::scoped_ptr<const util::DateTime> tbgn_;
53  boost::scoped_ptr<const util::DateTime> tend_;
54  boost::scoped_ptr<ObsSpaces_> ospaces_;
55 };
56 
57 // -----------------------------------------------------------------------------
58 
59 } // namespace test
60 
61 #endif // TEST_INTERFACE_OBSTESTSFIXTURE_H_
oops::ObsSpaces< MODEL > ObsSpaces_
boost::scoped_ptr< ObsSpaces_ > ospaces_
Definition: conf.py:1
static ObsSpaces_ & obspace()
static const eckit::Configuration & config()
boost::scoped_ptr< const util::DateTime > tbgn_
static ObsTestsFixture< MODEL > & getInstance()
boost::scoped_ptr< const util::DateTime > tend_
static const util::DateTime & tbgn()
static const util::DateTime & tend()