FV3 Bundle
EnsemblesCollection.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_ENSEMBLESCOLLECTION_H_
12 #define OOPS_BASE_ENSEMBLESCOLLECTION_H_
13 
14 #include <boost/foreach.hpp>
15 #include <boost/shared_ptr.hpp>
16 #include <boost/unordered_map.hpp>
17 
19 #include "oops/util/DateTime.h"
20 
21 namespace oops {
22 
23 // -----------------------------------------------------------------------------
24 
25 /// This class handles access to the ensembles of perturbation with a
26 /// DateTime
27 
28 template<typename MODEL> class EnsemblesCollection {
29  typedef boost::unordered_map<util::DateTime,
30  boost::shared_ptr<StateEnsemble<MODEL> > > EnsemblesMap;
31 
32  public:
33 /// Constructor
34 
35 /// Destructor
37  }
38 
39 /// Accessors
40  boost::shared_ptr<StateEnsemble<MODEL> > operator[](const util::DateTime& d) const {
41  return ensMap_.at(d);
42  }
43 
44  void put(const util::DateTime& d, boost::shared_ptr<StateEnsemble<MODEL> > e) {
45  ensMap_[d] = e;
46  }
47 
49  static boost::shared_ptr<EnsemblesCollection<MODEL> > instance_;
50  if ( instance_.use_count() == 0 )
51  instance_.reset(new EnsemblesCollection<MODEL>());
52  return *instance_;
53  }
54 
55  private:
57  }
58 
60 };
61 
62 // -----------------------------------------------------------------------------
63 
64 } // namespace oops
65 
66 #endif // OOPS_BASE_ENSEMBLESCOLLECTION_H_
boost::unordered_map< util::DateTime, boost::shared_ptr< StateEnsemble< MODEL > > > EnsemblesMap
virtual ~EnsemblesCollection()
Constructor.
static EnsemblesCollection< MODEL > & getInstance()
The namespace for the main oops code.
real(fp), parameter, public e
boost::shared_ptr< StateEnsemble< MODEL > > operator[](const util::DateTime &d) const
Accessors.
void put(const util::DateTime &d, boost::shared_ptr< StateEnsemble< MODEL > > e)