OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WColoredVertices.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCOLOREDVERTICES_H
26 #define WCOLOREDVERTICES_H
27 
28 #include <map>
29 #include <string>
30 
31 #include "../WTransferable.h"
32 #include "../WColor.h"
33 
34 #include "../WExportCommon.h"
35 
36 /**
37  * Represents a std::map where for each vertex ID a color is stored.
38  */
39 class OWCOMMON_EXPORT WColoredVertices : public WTransferable // NOLINT
40 {
41 public:
42  /**
43  * Default constructor.
44  */
46 
47  /**
48  * Initialize this with the given map.
49  *
50  * \param data The map
51  */
52  explicit WColoredVertices( const std::map< size_t, WColor >& data );
53 
54  /**
55  * Cleans up this instance.
56  */
57  virtual ~WColoredVertices();
58 
59  /**
60  * Gets the name of this prototype.
61  *
62  * \return the name.
63  */
64  virtual const std::string getName() const;
65 
66  /**
67  * Gets the description for this prototype.
68  *
69  * \return the description
70  */
71  virtual const std::string getDescription() const;
72 
73  /**
74  * Returns a prototype instantiated with the true type of the deriving class.
75  *
76  * \return the prototype.
77  */
78  static boost::shared_ptr< WPrototyped > getPrototype();
79 
80  /**
81  * Reference to the data.
82  *
83  * \return Reference to the map of ids and colors.
84  */
85  const std::map< size_t, WColor >& getData() const;
86 
87  /**
88  * Replace (copies) the internal data with the given one.
89  *
90  * \param data The ID-Color map
91  */
92  void setData( const std::map< size_t, WColor >& data );
93 
94 protected:
95  static boost::shared_ptr< WPrototyped > m_prototype; //!< The prototype as singleton.
96 
97 private:
98  std::map< size_t, WColor > m_data; //!< stores the vertex ids and colors
99 };
100 
101 inline const std::string WColoredVertices::getName() const
102 {
103  return "WColoredVertices";
104 }
105 
106 inline const std::string WColoredVertices::getDescription() const
107 {
108  return "Represents a std::map where for each vertex ID a color is stored.";
109 }
110 
111 inline const std::map< size_t, WColor >& WColoredVertices::getData() const
112 {
113  return m_data;
114 }
115 
116 inline void WColoredVertices::setData( const std::map< size_t, WColor >& data )
117 {
118  m_data = data;
119 }
120 
121 #endif // WCOLOREDVERTICES_H