Main MRPT website > C++ reference for MRPT 1.9.9
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 class represents a std::string derived class which is also
19  * CSerializable
20  * \sa CSerializable
21  * \ingroup mrpt_base_grp
22  */
24 {
26  protected:
27  /** The possibilities
28  */
29  std::vector<std::string> possibleTypes;
30 
31  /** The selected one:
32  */
33  unsigned int selection;
34 
35  public:
36  /** Default constructor.
37  * \param posibilitiesList The list of options, as a
38  * comma-separated-string, for example: "type 1,other type 2,type_3"
39  * \param defaultType Default type value
40  */
42  std::string posibilitiesList = "", std::string defaultType = "");
43 
44  /** Destructor
45  */
46  virtual ~CTypeSelector();
47 
48  /** Returns the set of posibilities in the "type" represented by this class.
49  */
50  void getTypePosibilities(std::vector<std::string>& outPosibilities) const;
51 
52  /** Gets the currently selected type, from the set of posibilities.
53  * \sa setType,getTypePosibilities
54  * \exception std::exception If currently there is not a valid selection.
55  */
56  std::string getType() const;
57 
58  /** Fast check for a given type, returns true if the selection is exactly
59  * 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
64  * the specified type name.
65  */
66  bool isType(const std::string& type) const;
67 
68  /** Sets the currently selected type.
69  * \sa getType,getTypePosibilities
70  * \exception std::exception On trying to select a type not in the list of
71  * posible values.
72  */
73  void setType(const std::string& type);
74 
75  /** Returns the index of a given type within the list of all possible types,
76  * or -1 if the given string is not a valid type.
77  */
78  int checkTypeIndex(const std::string& type) const;
79 
80 }; // End of class def.
81 } // End of namespace
82 } // End of namespace
83 #endif
void setType(const std::string &type)
Sets the currently selected type.
virtual ~CTypeSelector()
Destructor.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
unsigned int selection
The selected one:
Definition: CTypeSelector.h:33
std::vector< std::string > possibleTypes
The possibilities.
Definition: CTypeSelector.h:29
int checkTypeIndex(const std::string &type) const
Returns the index of a given type within the list of all possible types, or -1 if the given string is...
CTypeSelector(std::string posibilitiesList="", std::string defaultType="")
Default constructor.
bool isType(const char *type) const
Fast check for a given type, returns true if the selection is exactly the specified type name...
GLsizei const GLchar ** string
Definition: glext.h:4101
std::string getType() const
Gets the currently selected type, from the set of posibilities.
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...
void getTypePosibilities(std::vector< std::string > &outPosibilities) const
Returns the set of posibilities in the "type" represented by this class.
This class represents a std::string derived class which is also CSerializable.
Definition: CTypeSelector.h:23
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3528



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019