Main MRPT website > C++ reference for MRPT 1.5.6
TMetricMapTypesRegistry.h
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 #pragma once
11 
12 #include <mrpt/utils/core_defs.h>
13 #include <mrpt/obs/link_pragmas.h>
14 #include <mrpt/obs/obs_frwds.h>
15 #include <map>
16 #include <string>
17 
18 namespace mrpt
19 {
20  namespace maps
21  {
22  struct TMetricMapInitializer;
23  namespace internal
24  {
25  typedef mrpt::maps::TMetricMapInitializer* (*MapDefCtorFunctor)(void);
26  typedef mrpt::maps::CMetricMap* (*MapCtorFromDefFunctor)(const mrpt::maps::TMetricMapInitializer&);
27 
28  /** Class factory & registry for map classes. Used from mrpt::maps::TMetricMapInitializer */
30  {
31  public:
32  static TMetricMapTypesRegistry & Instance();
33  size_t doRegister(const std::string &name,MapDefCtorFunctor func1,MapCtorFromDefFunctor func2); //!< Return the index of the class in the list (not important, just used as a trick to initialize static members)
34  mrpt::maps::TMetricMapInitializer* factoryMapDefinition(const std::string &className) const; //!< Return NULL if not found
35  mrpt::maps::CMetricMap* factoryMapObjectFromDefinition(const mrpt::maps::TMetricMapInitializer&mi) const; //!< Return NULL if not found
36  typedef std::map<std::string,std::pair<MapDefCtorFunctor,MapCtorFromDefFunctor> > TListRegisteredMaps;
37  const TListRegisteredMaps & getAllRegistered() const { return m_registry;}
38  private:
39  TMetricMapTypesRegistry() {} // Access thru singleton in Instance()
41  };
42 
43  /** Add a MAP_DEFINITION_START() ... MAP_DEFINITION_END() block inside the declaration of each metric map */
44  #define MAP_DEFINITION_START(_CLASS_NAME_,_LINKAGE_) \
45  public: \
46  /** @name Map Definition Interface stuff (see mrpt::maps::TMetricMapInitializer) @{ */ \
47  struct _LINKAGE_ TMapDefinitionBase : public mrpt::maps::TMetricMapInitializer { \
48  TMapDefinitionBase() : TMetricMapInitializer(CLASS_ID(_CLASS_NAME_)) { } \
49  };\
50  struct _LINKAGE_ TMapDefinition : public TMapDefinitionBase { \
51 
52  #define MAP_DEFINITION_END(_CLASS_NAME_,_LINKAGE_) \
53  TMapDefinition();\
54  protected: \
55  void loadFromConfigFile_map_specific(const mrpt::utils::CConfigFileBase &source, const std::string &sectionNamePrefix) MRPT_OVERRIDE; \
56  void dumpToTextStream_map_specific(mrpt::utils::CStream &out) const MRPT_OVERRIDE; \
57  }; \
58  /** Returns default map definition initializer. See mrpt::maps::TMetricMapInitializer */ \
59  static mrpt::maps::TMetricMapInitializer* MapDefinition(); \
60  /** Constructor from a map definition structure: initializes the map and its parameters accordingly */ \
61  static _CLASS_NAME_* CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def); \
62  static mrpt::maps::CMetricMap* internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def); \
63  /** ID used to initialize class registration (just ignore it) */ \
64  static const size_t m_private_map_register_id; \
65  /** @} */
66 
67  /** Registers one map class into TMetricMapInitializer factory.
68  * One or several alternative class names can be provided, separated with whitespaces or commas */
69  #define MAP_DEFINITION_REGISTER(_CLASSNAME_STRINGS, _CLASSNAME_WITH_NS) \
70  const size_t _CLASSNAME_WITH_NS::m_private_map_register_id = mrpt::maps::internal::TMetricMapTypesRegistry::Instance().doRegister(_CLASSNAME_STRINGS,&_CLASSNAME_WITH_NS::MapDefinition,&_CLASSNAME_WITH_NS::internal_CreateFromMapDefinition); \
71  mrpt::maps::TMetricMapInitializer* _CLASSNAME_WITH_NS::MapDefinition() { return new _CLASSNAME_WITH_NS::TMapDefinition; } \
72  _CLASSNAME_WITH_NS* _CLASSNAME_WITH_NS::CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def) \
73  { return dynamic_cast<_CLASSNAME_WITH_NS*>(_CLASSNAME_WITH_NS::internal_CreateFromMapDefinition(def)); }
74 
75  } // end NS internal
76  } // End of namespace
77 } // End of namespace
78 
mrpt::maps::CMetricMap *(* MapCtorFromDefFunctor)(const mrpt::maps::TMetricMapInitializer &)
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1745
const TListRegisteredMaps & getAllRegistered() const
GLuint const GLchar * name
Definition: glew.h:1721
std::map< std::string, std::pair< MapDefCtorFunctor, MapCtorFromDefFunctor > > TListRegisteredMaps
GLsizei const GLcharARB ** string
Definition: glew.h:3293
Declares a virtual base class for all metric maps storage classes.
Class factory & registry for map classes.
mrpt::maps::TMetricMapInitializer *(* MapDefCtorFunctor)(void)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018