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