OpenWalnut  1.5.0dev
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 <memory>
30 #include <string>
31 
32 #include "../WColor.h"
33 #include "../WTransferable.h"
34 
35 
36 
37 /**
38  * Represents a std::map where for each vertex ID a color is stored.
39  */
40 class WColoredVertices : public WTransferable // NOLINT
41 {
42 public:
43  /**
44  * Default constructor.
45  */
47 
48  /**
49  * Initialize this with the given map.
50  *
51  * \param data The map
52  */
53  explicit WColoredVertices( const std::map< size_t, WColor >& data );
54 
55  /**
56  * Cleans up this instance.
57  */
58  virtual ~WColoredVertices();
59 
60  /**
61  * Gets the name of this prototype.
62  *
63  * \return the name.
64  */
65  virtual const std::string getName() const;
66 
67  /**
68  * Gets the description for this prototype.
69  *
70  * \return the description
71  */
72  virtual const std::string getDescription() const;
73 
74  /**
75  * Returns a prototype instantiated with the true type of the deriving class.
76  *
77  * \return the prototype.
78  */
79  static std::shared_ptr< WPrototyped > getPrototype();
80 
81  /**
82  * Reference to the data.
83  *
84  * \return Reference to the map of ids and colors.
85  */
86  const std::map< size_t, WColor >& getData() const;
87 
88  /**
89  * Replace (copies) the internal data with the given one.
90  *
91  * \param data The ID-Color map
92  */
93  void setData( const std::map< size_t, WColor >& data );
94 
95 protected:
96  static std::shared_ptr< WPrototyped > m_prototype; //!< The prototype as singleton.
97 
98 private:
99  std::map< size_t, WColor > m_data; //!< stores the vertex ids and colors
100 };
101 
102 inline const std::string WColoredVertices::getName() const
103 {
104  return "WColoredVertices";
105 }
106 
107 inline const std::string WColoredVertices::getDescription() const
108 {
109  return "Represents a std::map where for each vertex ID a color is stored.";
110 }
111 
112 inline const std::map< size_t, WColor >& WColoredVertices::getData() const
113 {
114  return m_data;
115 }
116 
117 inline void WColoredVertices::setData( const std::map< size_t, WColor >& data )
118 {
119  m_data = data;
120 }
121 
122 #endif // WCOLOREDVERTICES_H
Represents a std::map where for each vertex ID a color is stored.
const std::map< size_t, WColor > & getData() const
Reference to the data.
virtual ~WColoredVertices()
Cleans up this instance.
virtual const std::string getName() const
Gets the name of this prototype.
std::map< size_t, WColor > m_data
stores the vertex ids and colors
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
void setData(const std::map< size_t, WColor > &data)
Replace (copies) the internal data with the given one.
virtual const std::string getDescription() const
Gets the description for this prototype.
WColoredVertices()
Default constructor.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
Class building the interface for classes that might be transferred using WModuleConnector.
Definition: WTransferable.h:38