Main MRPT website > C++ reference for MRPT 1.5.7
CParameterizedTrajectoryGenerator_factory.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 "nav-precomp.h" // Precomp header
11 
15 
16 using namespace mrpt::nav;
17 
18 /*---------------------------------------------------------------
19  Class factory
20  ---------------------------------------------------------------*/
22 {
24 
26 
27  // Special names for backwards compatibility with MRPT < 1.5.0
28  std::string ptgClassName = mrpt::system::trim(ptgClassName_);
29  if (ptgClassName.size()==1) {
30  switch (ptgClassName[0])
31  {
32  case '1': ptgClassName="CPTG_DiffDrive_C"; break;
33  case '2': ptgClassName="CPTG_DiffDrive_alpha"; break;
34  case '3': ptgClassName="CPTG_DiffDrive_CCS"; break;
35  case '4': ptgClassName="CPTG_DiffDrive_CC"; break;
36  case '5': ptgClassName="CPTG_DiffDrive_CS"; break;
37  };
38  }
39 
40  // Factory:
41  const mrpt::utils::TRuntimeClassId *classId = mrpt::utils::findRegisteredClass( ptgClassName );
42  if (!classId) {
43  THROW_EXCEPTION_FMT("[CreatePTG] No PTG named `%s` is registered!",ptgClassName.c_str());
44  }
45 
47  if (!ptg) {
48  THROW_EXCEPTION_FMT("[CreatePTG] Object of type `%s` seems not to be a PTG!",ptgClassName.c_str());
49  }
50 
51  // Wrapper to transparently add prefixes to all config keys:
53  cfp.bind(cfg);
54  cfp.setPrefixes("", sKeyPrefix );
55 
56  ptg->loadFromConfigFile(cfp,sSection);
57  return ptg;
58  MRPT_END
59 }
A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or sec...
void BASE_IMPEXP registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
mrpt::utils::CObject * createObject() const
Definition: CObject.cpp:89
This class allows loading and storing values and vectors of different types from a configuration text...
This is the base class for any user-defined PTG.
#define MRPT_END
const TRuntimeClassId BASE_IMPEXP * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or NULL if the class is not registered.
#define MRPT_START
GLsizei const GLcharARB ** string
Definition: glew.h:3293
std::string BASE_IMPEXP trim(const std::string &str)
Removes leading and trailing spaces.
A structure that holds runtime class type information.
Definition: CObject.h:46
static CParameterizedTrajectoryGenerator * CreatePTG(const std::string &ptgClassName, const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection, const std::string &sKeyPrefix)
The class factory for creating a PTG from a list of parameters in a section of a given config file (p...
void bind(const CConfigFileBase &o)
Make this object to wrap the given existing CConfigFileBase object.



Page generated by Doxygen 1.8.11 for MRPT 1.5.7 Git: 2190203 Tue May 15 02:01:15 2018 +0200 at miƩ may 16 12:40:16 CEST 2018