8 #ifndef OOPS_BASE_OBSLOCALIZATIONBASE_H_
9 #define OOPS_BASE_OBSLOCALIZATIONBASE_H_
15 #include <boost/noncopyable.hpp>
17 #include "eckit/config/Configuration.h"
20 #include "oops/util/Printable.h"
27 template<
typename OBS>
29 private boost::noncopyable {
41 template <
typename OBS>
45 static std::unique_ptr<ObsLocalizationBase<OBS>>
create(
const eckit::Configuration &,
52 static std::map < std::string, ObsLocalizationFactory<OBS> * > &
getMakers() {
53 static std::map < std::string, ObsLocalizationFactory<OBS> * > makers_;
60 template<
class OBS,
class T>
65 {
return new T(conf, obsspace); }
73 template <
typename OBS>
75 if (getMakers().find(name) != getMakers().end()) {
76 throw std::runtime_error(name +
" already registered in obs localization factory.");
78 getMakers()[name] =
this;
83 template <
typename OBS>
85 const eckit::Configuration & conf,
const ObsSpace_ & obsspace) {
86 Log::trace() <<
"ObsLocalizationBase<OBS>::create starting" << std::endl;
87 const std::string
id = conf.getString(
"localization method");
88 typename std::map<std::string, ObsLocalizationFactory<OBS>*>::iterator
89 jloc = getMakers().find(
id);
90 if (jloc == getMakers().end()) {
91 throw std::runtime_error(
id +
" does not exist in obs localization factory.");
93 std::unique_ptr<ObsLocalizationBase<OBS>> ptr(jloc->second->make(conf, obsspace));
94 Log::trace() <<
"ObsLocalizationBase<OBS>::create done" << std::endl;
102 #endif // OOPS_BASE_OBSLOCALIZATIONBASE_H_