Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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(const std::string &names,MapDefCtorFunctor func1,MapCtorFromDefFunctor func2)
29 {
30  std::vector<std::string> lstNames;
31  mrpt::system::tokenize(names," \t\r\n,",lstNames);
32  for (size_t i=0;i<lstNames.size();i++)
33  m_registry[lstNames[i]] = std::make_pair(func1,func2);
34  return m_registry.size();
35 }
36 
37 mrpt::maps::TMetricMapInitializer* TMetricMapTypesRegistry::factoryMapDefinition(const std::string &className) const
38 {
39  TListRegisteredMaps::const_iterator it=m_registry.find(className);
40  if (it==m_registry.end()) return NULL;
41  ASSERT_(it->second.first!=NULL)
42  return (*it->second.first)();
43 }
44 
45 mrpt::maps::CMetricMap* TMetricMapTypesRegistry::factoryMapObjectFromDefinition(
46  const mrpt::maps::TMetricMapInitializer&mi) const
47 {
48  TListRegisteredMaps::const_iterator it=m_registry.find( mi.getMetricMapClassType()->className );
49  if (it==m_registry.end()) {
50  THROW_EXCEPTION_FMT("[TMetricMapTypesRegistry] Error: Cannot create map of unregistered map type '%s'",mi.getMetricMapClassType()->className);
51  }
52 
53  ASSERT_(it->second.second!=NULL)
54  mrpt::maps::CMetricMap* theMap = (*it->second.second)(mi);
55 
56  // Common params for all maps:
58 
59  return theMap;
60 }
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
STL namespace.
TMapGenericParams genericMapParams
Common params to all maps.
const Scalar * const_iterator
Definition: eigen_plugins.h:24
const mrpt::utils::TRuntimeClassIdPtr & getMetricMapClassType() const
Query the map type (C++ class), as set by the factory method MapDefinition()
mrpt::maps::TMapGenericParams genericMapParams
Common params for all maps: These are automatically set in TMetricMapTypesRegistry::factoryMapObjectF...
GLsizei const GLchar ** string
Definition: glext.h:3919
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Declares a virtual base class for all metric maps storage classes.
mrpt::maps::TMetricMapInitializer *(* MapDefCtorFunctor)(void)
#define ASSERT_(f)
Class factory & registry for map classes.
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters.
mrpt::maps::CMetricMap *(* MapCtorFromDefFunctor)(const mrpt::maps::TMetricMapInitializer &)



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019