Main MRPT website > C++ reference
MRPT logo
CListOfClasses.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
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                  * \ingroup mrpt_base_grp
00040                   */
00041                 class BASE_IMPEXP CListOfClasses
00042                 {
00043                 private:
00044                         typedef std::set<const mrpt::utils::TRuntimeClassId*>  TSet;
00045                         
00046                         TSet m_data;
00047                         
00048                 public:
00049                         typedef TSet::iterator iterator;
00050                         typedef TSet::const_iterator const_iterator;
00051                         
00052                         inline iterator begin() {return m_data.begin(); }
00053                         inline const_iterator begin() const {return m_data.begin(); }
00054                         
00055                         inline iterator end() {return m_data.end(); }
00056                         inline const_iterator end() const {return m_data.end(); }
00057                 
00058                         /** Insert a class in the list. Example of usage:
00059                           *   \code
00060                           *     myList.insert(CLASS_ID(CObservationImage));
00061                           *   \endcode
00062                           */
00063                         inline void insert( const mrpt::utils::TRuntimeClassId* id ) { m_data.insert(id); }             
00064 
00065                         /** Does the list contains this class? */
00066                         inline bool contains( const mrpt::utils::TRuntimeClassId* id ) const { return m_data.find(id)!=m_data.end(); }
00067 
00068                         /** Does the list contains a class derived from...? */
00069                         bool containsDerivedFrom( const mrpt::utils::TRuntimeClassId* id ) const;
00070                         
00071                         /** Empty the list */
00072                         inline void clear() { m_data.clear(); }
00073                         
00074                         /** Is the list empty? */
00075                         inline bool empty() const  { return m_data.empty(); }
00076                         
00077                         /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D".
00078                           */
00079                         std::string toString() const;
00080                         
00081                         /** Return a string representation of the list, for example: "CPose2D, CObservation, CPose3D".
00082                           * \exception std::exception On unregistered class name found.
00083                           */
00084                         void fromString(const std::string &s);
00085                         
00086                 }; // end of class
00087 
00088         } // End of namespace
00089 } // end of namespace
00090 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011