Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
14namespace mrpt
15{
16namespace 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
#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)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:40
This class represents a std::string derived class which is also CSerializable.
Definition: CTypeSelector.h:26
unsigned int selection
The selected one:
Definition: CTypeSelector.h:36
CTypeSelector(std::string posibilitiesList="", std::string defaultType="")
Default constructor.
bool isType(const std::string &type) const
Fast check for a given type, returns true if the selection is exactly the specified type name.
bool isType(const char *type) const
Fast check for a given type, returns true if the selection is exactly the specified type name.
void setType(const std::string &type)
Sets the currently selected type.
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...
virtual ~CTypeSelector()
Destructor.
std::string getType() const
Gets the currently selected type, from the set of posibilities.
void getTypePosibilities(std::vector< std::string > &outPosibilities) const
Returns the set of posibilities in the "type" represented by this class.
std::vector< std::string > possibleTypes
The possibilities.
Definition: CTypeSelector.h:32
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.2 for MRPT 1.4.0 SVN: at Mon Sep 20 00:47:55 UTC 2021