UFO
ObsOperatorBase.cc
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 #include "ufo/ObsOperatorBase.h"
9 
10 #include "eckit/config/Configuration.h"
11 #include "ioda/ObsSpace.h"
12 #include "oops/util/abor1_cpp.h"
13 #include "oops/util/Logger.h"
14 #include "ufo/Locations.h"
15 
16 namespace ufo {
17 
18 // -----------------------------------------------------------------------------
19 
20 std::unique_ptr<Locations> ObsOperatorBase::locations(const util::DateTime & t1,
21  const util::DateTime & t2) const {
22  return std::unique_ptr<Locations>(new Locations(odb_, t1, t2));
23 }
24 
25 // -----------------------------------------------------------------------------
26 
27 ObsOperatorFactory::ObsOperatorFactory(const std::string & name) {
28  if (getMakers().find(name) != getMakers().end()) {
29  oops::Log::error() << name << " already registered in ufo::ObsOperatorFactory." << std::endl;
30  ABORT("Element already registered in ufo::ObsOperatorFactory.");
31  }
32  getMakers()[name] = this;
33 }
34 
35 // -----------------------------------------------------------------------------
36 
37 ObsOperatorBase * ObsOperatorFactory::create(const ioda::ObsSpace & odb,
38  const eckit::Configuration & conf) {
39  oops::Log::trace() << "ObsOperatorBase::create starting" << std::endl;
40  const std::string id = conf.getString("name");
41  typename std::map<std::string, ObsOperatorFactory*>::iterator jloc = getMakers().find(id);
42  if (jloc == getMakers().end()) {
43  oops::Log::error() << id << " does not exist in ufo::ObsOperatorFactory." << std::endl;
44  ABORT("Element does not exist in ufo::ObsOperatorFactory.");
45  }
46  ObsOperatorBase * ptr = jloc->second->make(odb, conf);
47  oops::Log::trace() << "ObsOperatorBase::create done" << std::endl;
48  return ptr;
49 }
50 
51 // -----------------------------------------------------------------------------
52 
53 } // namespace ufo
ufo::ObsOperatorFactory::ObsOperatorFactory
ObsOperatorFactory(const std::string &)
Definition: ObsOperatorBase.cc:27
ufo::Locations
Locations class to handle locations for UFO.
Definition: src/ufo/Locations.h:32
ufo
Definition: RunCRTM.h:27
ObsOperatorBase.h
ufo::ObsOperatorBase
Base class for observation operators.
Definition: ObsOperatorBase.h:37
ufo::ObsOperatorBase::locations
virtual std::unique_ptr< Locations > locations(const util::DateTime &, const util::DateTime &) const
Locations for GeoVaLs.
Definition: ObsOperatorBase.cc:20
ufo::ObsOperatorBase::odb_
const ioda::ObsSpace & odb_
Definition: ObsOperatorBase.h:55
ufo::ObsOperatorFactory::getMakers
static std::map< std::string, ObsOperatorFactory * > & getMakers()
Definition: ObsOperatorBase.h:69
ufo::ObsOperatorFactory::create
static ObsOperatorBase * create(const ioda::ObsSpace &, const eckit::Configuration &)
Definition: ObsOperatorBase.cc:37
conf
Definition: conf.py:1