Main MRPT website > C++ reference for MRPT 1.9.9
TMetricMapTypesRegistry.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precomp header
11 
12 #include <mrpt/maps/CMetricMap.h>
16 
17 using namespace std;
18 using namespace mrpt;
19 using namespace mrpt::maps;
20 using namespace mrpt::maps::internal;
21 
22 TMetricMapTypesRegistry& TMetricMapTypesRegistry::Instance()
23 {
24  static TMetricMapTypesRegistry reg;
25  return reg;
26 }
27 
28 size_t TMetricMapTypesRegistry::doRegister(
29  const std::string& names, MapDefCtorFunctor func1,
31 {
32  std::vector<std::string> lstNames;
33  mrpt::system::tokenize(names, " \t\r\n,", lstNames);
34  for (size_t i = 0; i < lstNames.size(); i++)
35  m_registry[lstNames[i]] = std::make_pair(func1, func2);
36  return m_registry.size();
37 }
38 
40  TMetricMapTypesRegistry::factoryMapDefinition(
41  const std::string& className) const
42 {
43  TListRegisteredMaps::const_iterator it = m_registry.find(className);
44  if (it == m_registry.end()) return nullptr;
45  ASSERT_(it->second.first);
46  return (it->second.first)();
47 }
48 
49 mrpt::maps::CMetricMap* TMetricMapTypesRegistry::factoryMapObjectFromDefinition(
50  const mrpt::maps::TMetricMapInitializer& mi) const
51 {
53  m_registry.find(mi.getMetricMapClassType()->className);
54  if (it == m_registry.end())
55  {
57  "[TMetricMapTypesRegistry] Error: Cannot create map of "
58  "unregistered map type '%s'",
59  mi.getMetricMapClassType()->className);
60  }
61 
62  ASSERT_(it->second.second);
63  mrpt::maps::CMetricMap* theMap = (it->second.second)(mi);
64 
65  // Common params for all maps:
67 
68  return theMap;
69 }
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
STL namespace.
TMapGenericParams genericMapParams
Common params to all maps.
Definition: CMetricMap.h:282
const mrpt::rtti::TRuntimeClassId::Ptr & getMetricMapClassType() const
Query the map type (C++ class), as set by the factory method MapDefinition()
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
mrpt::maps::TMapGenericParams genericMapParams
Common params for all maps: These are automatically set in TMetricMapTypesRegistry::factoryMapObjectF...
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
GLsizei const GLchar ** string
Definition: glext.h:4101
std::vector< string > names
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:56
std::function< mrpt::maps::CMetricMap *(const mrpt::maps::TMetricMapInitializer &)> MapCtorFromDefFunctor
Class factory & registry for map classes.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
Definition: exceptions.h:43
const Scalar * const_iterator
Definition: eigen_plugins.h:27
std::function< mrpt::maps::TMetricMapInitializer *(void)> MapDefCtorFunctor



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019