00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CListOfClasses_H 00029 #define CListOfClasses_H 00030 00031 #include <mrpt/utils/CSerializable.h> 00032 #include <mrpt/system/string_utils.h> 00033 00034 namespace mrpt 00035 { 00036 namespace utils 00037 { 00038 /** A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the mechanism of CSerializable classes. 00039 */ 00040 class BASE_IMPEXP CListOfClasses 00041 { 00042 private: 00043 typedef std::set<const mrpt::utils::TRuntimeClassId*> TSet; 00044 00045 TSet m_data; 00046 00047 public: 00048 typedef TSet::iterator iterator; 00049 typedef TSet::const_iterator const_iterator; 00050 00051 inline iterator begin() {return m_data.begin(); } 00052 inline const_iterator begin() const {return m_data.begin(); } 00053 00054 inline iterator end() {return m_data.end(); } 00055 inline const_iterator end() const {return m_data.end(); } 00056 00057 /** Insert a class in the list. Example of usage: 00058 * \code 00059 * myList.insert(CLASS_ID(CObservationImage)); 00060 * \endcode 00061 */ 00062 inline void insert( const mrpt::utils::TRuntimeClassId* id ) { m_data.insert(id); } 00063 00064 /** Does the list contains this class? */ 00065 inline bool contains( const mrpt::utils::TRuntimeClassId* id ) const { return m_data.find(id)!=m_data.end(); } 00066 00067 /** Does the list contains a class derived from...? */ 00068 bool containsDerivedFrom( const mrpt::utils::TRuntimeClassId* id ) const; 00069 00070 /** Empty the list */ 00071 inline void clear() { m_data.clear(); } 00072 00073 /** Is the list empty? */ 00074 inline bool empty() const { return m_data.empty(); } 00075 00076 /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D". 00077 */ 00078 std::string toString() const; 00079 00080 /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D". 00081 * \exception std::exception On unregistered class name found. 00082 */ 00083 void fromString(const std::string &s); 00084 00085 }; // end of class 00086 00087 } // End of namespace 00088 } // end of namespace 00089 #endif
Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011 |