SourceXtractorPlusPlus  0.10
Please provide a description of the project.
LeastSquareEngineManager.cpp
Go to the documentation of this file.
1 
24 #include <boost/algorithm/string.hpp>
26 
27 namespace ModelFitting {
28 
29 // We use this idiom to make sure the map is initialized on the first need
30 // Otherwise, this may be initialized *after* the concrete implementations try to register themselves
33  return engine_factories;
34 }
35 
36 
38  if (getEngineFactories().find(name) != getEngineFactories().end()) {
39  throw Elements::Exception() << "A LeastSquareEngine named " << name << " has already been registered";
40  }
41  getEngineFactories()[boost::algorithm::to_lower_copy(name)] = factory_method;
42 }
43 
46  for (auto &e : getEngineFactories()) {
47  keys.emplace_back(e.first);
48  }
49  return keys;
50 }
51 
53  auto factory = getEngineFactories().find(boost::algorithm::to_lower_copy(name));
54  if (factory == getEngineFactories().end()) {
55  std::ostringstream known_str;
56  if (!getEngineFactories().empty()) {
57  known_str << ". Known engines: ";
58  for (auto &e : getEngineFactories()) {
59  known_str << e.first << " ";
60  }
61  }
62  throw Elements::Exception() << "No LeastSquareEngine named " << name << " has been registered" << known_str.str();
63  }
64  return factory->second(max_iterations);
65 }
66 
67 } // end namespace ModelFitting
STL class.
static std::map< std::string, LeastSquareEngineManager::FactoryMethod > & getEngineFactories()
constexpr double e
static std::vector< std::string > getImplementations()
T end(T... args)
static void registerEngine(const std::string &name, FactoryMethod factory_method)
STL class.
STL class.
T str(T... args)
T find(T... args)
static std::shared_ptr< LeastSquareEngine > create(const std::string &name, unsigned max_iterations=1000)
T emplace_back(T... args)