OpenWalnut  1.5.0dev
WDataSetFiberClustering.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 WDATASETFIBERCLUSTERING_H
26 #define WDATASETFIBERCLUSTERING_H
27 
28 #include <map>
29 #include <memory>
30 #include <string>
31 
32 
33 #include "../common/WTransferable.h"
34 #include "../common/exceptions/WInvalidID.h"
35 #include "datastructures/WFiberCluster.h"
36 
37 /**
38  * This is a dataset which represent a clustering of fibers. It does not itself contain the fiber-data. This dataset only contains the indices of
39  * fibers belonging to the clusters.
40  *
41  * Each cluster has its own ID. A mapping between names and IDs is possible.
42  */
44 {
45 public:
46  /**
47  * Convenience typedef for a std::shared_ptr< WDataSetFiberClustering >.
48  */
49  typedef std::shared_ptr< WDataSetFiberClustering > SPtr;
50 
51  /**
52  * Convenience typedef for a std::shared_ptr< const WDataSetFiberClustering >.
53  */
54  typedef std::shared_ptr< const WDataSetFiberClustering > ConstSPtr;
55 
56  /**
57  * The type of the cluster map
58  */
59  typedef std::map< size_t, WFiberCluster::SPtr > ClusterMap;
60 
61  /**
62  * Default constructor.
63  */
65 
66  /**
67  * constructor with cluster list.
68  *
69  * \param clustering the cluster map defining the clustering
70  */
71  explicit WDataSetFiberClustering( const ClusterMap &clustering );
72 
73  /**
74  * Destructor.
75  */
76  virtual ~WDataSetFiberClustering();
77 
78  /**
79  * The name of this transferable. This is useful information for the users.
80  *
81  * \return the name.
82  */
83  virtual const std::string getName() const;
84 
85  /**
86  *
87  * The description of this transferable. This is useful information for the users.
88  *
89  * \return A description
90  */
91  virtual const std::string getDescription() const;
92 
93  /**
94  * Returns a prototype instantiated with the true type of the deriving class.
95  *
96  * \return the prototype.
97  */
98  static std::shared_ptr< WPrototyped > getPrototype();
99 
100  /**
101  * Sets the cluster at the given ID. If there is a cluster at this ID, it is replaced.
102  *
103  * \param id the ID of the cluster
104  * \param cluster the cluster
105  */
106  virtual void setCluster( size_t id, WFiberCluster::SPtr cluster );
107 
108  /**
109  * Returns the cluster with the given ID.
110  *
111  * \throw WInvalidID if the ID is not known.
112  *
113  * \param id the ID of the cluster to get
114  *
115  * \return the cluster
116  */
117  virtual WFiberCluster::SPtr getCluster( size_t id );
118 
119  /**
120  * Returns the cluster with the given ID.
121  *
122  * \throw WInvalidID if the ID is not known.
123  *
124  * \param id the ID of the cluster to get
125  *
126  * \return the cluster
127  */
128  virtual WFiberCluster::ConstSPtr getCluster( size_t id ) const;
129 
130  /**
131  * Returns the cluster with the given ID. If there is no cluster with this ID, an empty one is returned.
132  *
133  * \param id the ID of the cluster to get
134  *
135  * \return the cluster
136  */
137  virtual WFiberCluster::SPtr getOrCreateCluster( size_t id );
138 
139  /**
140  * Removes the cluster with the specified ID. If it does not exist, nothing happens.
141  *
142  * \param id the id of the cluster
143  */
144  virtual void removeCluster( size_t id );
145 
146  /**
147  * The begin iterator of the clustering for const iteration.
148  *
149  * \return the begin iterator
150  */
151  ClusterMap::const_iterator begin() const;
152 
153  /**
154  * The begin iterator of the clustering for non-const iteration.
155  *
156  * \return the begin iterator
157  */
158  ClusterMap::iterator begin();
159 
160  /**
161  * The end iterator of the clustering for const iteration.
162  *
163  * \return the begin iterator
164  */
165  ClusterMap::const_iterator end() const;
166 
167  /**
168  * The end iterator of the clustering for non-const iteration.
169  *
170  * \return the end iterator
171  */
172  ClusterMap::iterator end();
173 
174  /**
175  * Returns the amount of clusters in the clustering
176  *
177  * \return the amount of clusters in the clustering
178  */
179  size_t size() const;
180 
181 protected:
182  /**
183  * Prototype for this dataset
184  */
185  static std::shared_ptr< WPrototyped > m_prototype;
186 private:
187  /**
188  * The map between ID and cluster.
189  */
190  std::map< size_t, WFiberCluster::SPtr > m_clusters;
191 };
192 
193 #endif // WDATASETFIBERCLUSTERING_H
This is a dataset which represent a clustering of fibers.
virtual WFiberCluster::SPtr getOrCreateCluster(size_t id)
Returns the cluster with the given ID.
static std::shared_ptr< WPrototyped > m_prototype
Prototype for this dataset.
WDataSetFiberClustering()
Default constructor.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
virtual ~WDataSetFiberClustering()
Destructor.
ClusterMap::const_iterator begin() const
The begin iterator of the clustering for const iteration.
size_t size() const
Returns the amount of clusters in the clustering.
std::shared_ptr< WDataSetFiberClustering > SPtr
Convenience typedef for a std::shared_ptr< WDataSetFiberClustering >.
virtual const std::string getName() const
The name of this transferable.
ClusterMap::const_iterator end() const
The end iterator of the clustering for const iteration.
virtual const std::string getDescription() const
The description of this transferable.
virtual void setCluster(size_t id, WFiberCluster::SPtr cluster)
Sets the cluster at the given ID.
std::map< size_t, WFiberCluster::SPtr > m_clusters
The map between ID and cluster.
std::shared_ptr< const WDataSetFiberClustering > ConstSPtr
Convenience typedef for a std::shared_ptr< const WDataSetFiberClustering >.
std::map< size_t, WFiberCluster::SPtr > ClusterMap
The type of the cluster map.
virtual WFiberCluster::SPtr getCluster(size_t id)
Returns the cluster with the given ID.
virtual void removeCluster(size_t id)
Removes the cluster with the specified ID.
std::shared_ptr< WFiberCluster > SPtr
Shared pointer abbreviation.
Definition: WFiberCluster.h:51
std::shared_ptr< const WFiberCluster > ConstSPtr
Const shared pointer abbreviation.
Definition: WFiberCluster.h:56
Class building the interface for classes that might be transferred using WModuleConnector.
Definition: WTransferable.h:38