OpenWalnut  1.4.0
WColoredVertices.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WCOLOREDVERTICES_H
00026 #define WCOLOREDVERTICES_H
00027 
00028 #include <map>
00029 #include <string>
00030 
00031 #include "../WTransferable.h"
00032 #include "../WColor.h"
00033 
00034 
00035 
00036 /**
00037  * Represents a std::map where for each vertex ID a color is stored.
00038  */
00039 class WColoredVertices : public WTransferable // NOLINT
00040 {
00041 public:
00042     /**
00043      * Default constructor.
00044      */
00045     WColoredVertices();
00046 
00047     /**
00048      * Initialize this with the given map.
00049      *
00050      * \param data The map
00051      */
00052     explicit WColoredVertices( const std::map< size_t, WColor >& data );
00053 
00054     /**
00055      * Cleans up this instance.
00056      */
00057     virtual ~WColoredVertices();
00058 
00059     /**
00060      * Gets the name of this prototype.
00061      *
00062      * \return the name.
00063      */
00064     virtual const std::string getName() const;
00065 
00066     /**
00067      * Gets the description for this prototype.
00068      *
00069      * \return the description
00070      */
00071     virtual const std::string getDescription() const;
00072 
00073     /**
00074      * Returns a prototype instantiated with the true type of the deriving class.
00075      *
00076      * \return the prototype.
00077      */
00078     static boost::shared_ptr< WPrototyped > getPrototype();
00079 
00080     /**
00081      * Reference to the data.
00082      *
00083      * \return Reference to the map of ids and colors.
00084      */
00085     const std::map< size_t, WColor >& getData() const;
00086 
00087     /**
00088      * Replace (copies) the internal data with the given one.
00089      *
00090      * \param data The ID-Color map
00091      */
00092     void setData( const std::map< size_t, WColor >& data );
00093 
00094 protected:
00095     static boost::shared_ptr< WPrototyped > m_prototype; //!< The prototype as singleton.
00096 
00097 private:
00098     std::map< size_t, WColor > m_data; //!< stores the vertex ids and colors
00099 };
00100 
00101 inline const std::string WColoredVertices::getName() const
00102 {
00103     return "WColoredVertices";
00104 }
00105 
00106 inline const std::string WColoredVertices::getDescription() const
00107 {
00108     return "Represents a std::map where for each vertex ID a color is stored.";
00109 }
00110 
00111 inline const std::map< size_t, WColor >& WColoredVertices::getData() const
00112 {
00113     return m_data;
00114 }
00115 
00116 inline void WColoredVertices::setData( const std::map< size_t, WColor >& data )
00117 {
00118     m_data = data;
00119 }
00120 
00121 #endif  // WCOLOREDVERTICES_H