Main MRPT website > C++ reference
MRPT logo
CListOfClasses.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CListOfClasses_H
29 #define CListOfClasses_H
30 
33 
34 namespace mrpt
35 {
36  namespace utils
37  {
38  /** A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the mechanism of CSerializable classes.
39  * \ingroup mrpt_base_grp
40  */
42  {
43  private:
44  typedef std::set<const mrpt::utils::TRuntimeClassId*> TSet;
45 
47 
48  public:
51 
52  inline iterator begin() {return m_data.begin(); }
53  inline const_iterator begin() const {return m_data.begin(); }
54 
55  inline iterator end() {return m_data.end(); }
56  inline const_iterator end() const {return m_data.end(); }
57 
58  /** Insert a class in the list. Example of usage:
59  * \code
60  * myList.insert(CLASS_ID(CObservationImage));
61  * \endcode
62  */
63  inline void insert( const mrpt::utils::TRuntimeClassId* id ) { m_data.insert(id); }
64 
65  /** Does the list contains this class? */
66  inline bool contains( const mrpt::utils::TRuntimeClassId* id ) const { return m_data.find(id)!=m_data.end(); }
67 
68  /** Does the list contains a class derived from...? */
69  bool containsDerivedFrom( const mrpt::utils::TRuntimeClassId* id ) const;
70 
71  /** Empty the list */
72  inline void clear() { m_data.clear(); }
73 
74  /** Is the list empty? */
75  inline bool empty() const { return m_data.empty(); }
76 
77  /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D".
78  */
79  std::string toString() const;
80 
81  /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D".
82  * \exception std::exception On unregistered class name found.
83  */
84  void fromString(const std::string &s);
85 
86  }; // end of class
87 
88  } // End of namespace
89 } // end of namespace
90 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013