FV3 Bundle
oops/src/oops/interface/Locations.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_INTERFACE_LOCATIONS_H_
12 #define OOPS_INTERFACE_LOCATIONS_H_
13 
14 #include <string>
15 
16 #include <boost/shared_ptr.hpp>
17 
18 #include "oops/util/Logger.h"
19 #include "oops/util/ObjectCounter.h"
20 #include "oops/util/Printable.h"
21 #include "oops/util/Timer.h"
22 
23 namespace eckit {
24  class Configuration;
25 }
26 
27 namespace oops {
28 
29 // -----------------------------------------------------------------------------
30 
31 template <typename MODEL>
32 class Locations : public util::Printable,
33  private util::ObjectCounter<Locations<MODEL> > {
34  typedef typename MODEL::Locations Locations_;
35 
36  public:
37  static const std::string classname() {return "oops::Locations";}
38 
39  explicit Locations(const Locations_ *);
40  explicit Locations(const eckit::Configuration &);
41  Locations(const Locations &);
42  ~Locations();
43 
44 /// Interfacing
45  const Locations_ & locations() const {return *locs_;}
46 
47  private:
48  void print(std::ostream &) const;
49  boost::shared_ptr<const Locations_> locs_;
50 };
51 
52 // -----------------------------------------------------------------------------
53 
54 template <typename MODEL>
55 Locations<MODEL>::Locations(const Locations_ * locs) : locs_(locs)
56 {
57  Log::trace() << "Locations<MODEL>::Locations constructed" << std::endl;
58 }
59 
60 // -----------------------------------------------------------------------------
61 
62 template <typename MODEL>
63 Locations<MODEL>::Locations(const eckit::Configuration & conf) {
64  Log::trace() << "Locations<MODEL>::Locations starting" << std::endl;
65  util::Timer timer(classname(), "Locations");
66  locs_.reset(new Locations_(conf));
67  Log::trace() << "Locations<MODEL>::Locations done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 template <typename MODEL>
74  : locs_(other.locs_)
75 {
76  Log::trace() << "Locations<MODEL>::Locations copied" << std::endl;
77 }
78 
79 // -----------------------------------------------------------------------------
80 
81 template <typename MODEL>
83  Log::trace() << "Locations<MODEL>::~Locations starting" << std::endl;
84  util::Timer timer(classname(), "~Locations");
85  locs_.reset();
86  Log::trace() << "Locations<MODEL>::~Locations done" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
91 template<typename MODEL>
92 void Locations<MODEL>::print(std::ostream & os) const {
93  Log::trace() << "Locations<MODEL>::print starting" << std::endl;
94  util::Timer timer(classname(), "print");
95  os << *locs_;
96  Log::trace() << "Locations<MODEL>::print done" << std::endl;
97 }
98 
99 // -----------------------------------------------------------------------------
100 
101 } // namespace oops
102 
103 #endif // OOPS_INTERFACE_LOCATIONS_H_
Definition: conf.py:1
const Locations_ & locations() const
Interfacing.
The namespace for the main oops code.
boost::shared_ptr< const Locations_ > locs_
void print(std::ostream &) const
static const std::string classname()