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