Main MRPT website > C++ reference for MRPT 1.5.7
CTypeSelector.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 #ifndef CTypeSelector_H
10 #define CTypeSelector_H
11 
13 
14 namespace mrpt
15 {
16 namespace utils
17 {
18  // This must be added to any CSerializable derived class:
20 
21  /** This class represents a std::string derived class which is also CSerializable
22  * \sa CSerializable
23  * \ingroup mrpt_base_grp
24  */
26  {
27  // This must be added to any CSerializable derived class:
29  protected:
30  /** The possibilities
31  */
32  std::vector<std::string> possibleTypes;
33 
34  /** The selected one:
35  */
36  unsigned int selection;
37 
38  public:
39  /** Default constructor.
40  * \param posibilitiesList The list of options, as a comma-separated-string, for example: "type 1,other type 2,type_3"
41  * \param defaultType Default type value
42  */
43  CTypeSelector(std::string posibilitiesList = "", std::string defaultType = "");
44 
45  /** Destructor
46  */
47  virtual ~CTypeSelector();
48 
49  /** Returns the set of posibilities in the "type" represented by this class.
50  */
51  void getTypePosibilities( std::vector<std::string> &outPosibilities)const;
52 
53  /** Gets the currently selected type, from the set of posibilities.
54  * \sa setType,getTypePosibilities
55  * \exception std::exception If currently there is not a valid selection.
56  */
57  std::string getType() const;
58 
59  /** Fast check for a given type, returns true if the selection is exactly the specified type name.
60  */
61  bool isType(const char *type) const;
62 
63  /** Fast check for a given type, returns true if the selection is exactly the specified type name.
64  */
65  bool isType(const std::string &type) const;
66 
67  /** Sets the currently selected type.
68  * \sa getType,getTypePosibilities
69  * \exception std::exception On trying to select a type not in the list of posible values.
70  */
71  void setType(const std::string &type);
72 
73  /** Returns the index of a given type within the list of all possible types, or -1 if the given string is not a valid type.
74  */
75  int checkTypeIndex(const std::string &type) const;
76 
77  }; // End of class def.
79 
80  } // End of namespace
81 } // End of namespace
82 #endif
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
unsigned int selection
The selected one:
Definition: CTypeSelector.h:36
std::vector< std::string > possibleTypes
The possibilities.
Definition: CTypeSelector.h:32
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
GLsizei const GLchar ** string
Definition: glext.h:3919
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
This class represents a std::string derived class which is also CSerializable.
Definition: CTypeSelector.h:25
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3512



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019