UFO
PredictorBase.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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 
9 
10 #include <map>
11 
12 #include "eckit/config/LocalConfiguration.h"
13 
14 #include "oops/util/abor1_cpp.h"
15 #include "oops/util/Logger.h"
16 
17 namespace ufo {
18 
19 // -----------------------------------------------------------------------------
20 
21 PredictorBase::PredictorBase(const eckit::Configuration & conf, const std::vector<int> & jobs)
22  : func_name_(conf.getString("predictor.name")),
23  geovars_(), hdiags_(), jobs_(jobs) {
24 }
25 
26 // -----------------------------------------------------------------------------
27 
28 PredictorFactory::PredictorFactory(const std::string & name) {
29  if (predictorExists(name)) {
30  oops::Log::error() << name << " already registered in ufo::PredictorFactory."
31  << std::endl;
32  ABORT("Element already registered in ufo::PredictorFactory.");
33  }
34  getMakers()[name] = this;
35 }
36 
37 // -----------------------------------------------------------------------------
38 
39 PredictorBase * PredictorFactory::create(const eckit::Configuration & conf,
40  const std::vector<int> & jobs) {
41  oops::Log::trace() << "PredictorBase::create starting" << std::endl;
42  const std::string name = conf.getString("predictor.name");
43  if (!predictorExists(name)) {
44  oops::Log::error() << name << " does not exist in ufo::PredictorFactory."
45  << std::endl;
46  ABORT("Element does not exist in ufo::PredictorFactory.");
47  }
48  typename std::map<std::string, PredictorFactory*>::iterator jloc =
49  getMakers().find(name);
50  PredictorBase * ptr = jloc->second->make(conf, jobs);
51  oops::Log::trace() << "PredictorBase::create done" << std::endl;
52  return ptr;
53 }
54 
55 // -----------------------------------------------------------------------------
56 
57 bool PredictorFactory::predictorExists(const std::string & name) {
58  return (getMakers().find(name) != getMakers().end());
59 }
60 
61 // -----------------------------------------------------------------------------
62 
63 } // namespace ufo
ufo::PredictorFactory::predictorExists
static bool predictorExists(const std::string &)
Definition: PredictorBase.cc:57
PredictorBase.h
ufo
Definition: RunCRTM.h:27
ufo::PredictorFactory::PredictorFactory
PredictorFactory(const std::string &)
Definition: PredictorBase.cc:28
ufo::PredictorBase
Base class for computing predictors.
Definition: PredictorBase.h:38
ufo::PredictorFactory::create
static PredictorBase * create(const eckit::Configuration &, const std::vector< int > &)
Definition: PredictorBase.cc:39
ufo::PredictorFactory::getMakers
static std::map< std::string, PredictorFactory * > & getMakers()
Definition: PredictorBase.h:80
conf
Definition: conf.py:1
ufo::PredictorBase::PredictorBase
PredictorBase(const eckit::Configuration &, const std::vector< int > &)
Definition: PredictorBase.cc:21