OpenWalnut 1.3.1
WDataSetFiberClustering.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WDATASETFIBERCLUSTERING_H
00026 #define WDATASETFIBERCLUSTERING_H
00027 
00028 #include <map>
00029 #include <string>
00030 
00031 #include <boost/shared_ptr.hpp>
00032 
00033 #include "datastructures/WFiberCluster.h"
00034 
00035 #include "../common/exceptions/WInvalidID.h"
00036 #include "../common/WTransferable.h"
00037 
00038 /**
00039  * 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
00040  * fibers belonging to the clusters.
00041  *
00042  * Each cluster has its own ID. A mapping between names and IDs is possible.
00043  */
00044 class WDataSetFiberClustering: public WTransferable
00045 {
00046 public:
00047     /**
00048      * Convenience typedef for a boost::shared_ptr< WDataSetFiberClustering >.
00049      */
00050     typedef boost::shared_ptr< WDataSetFiberClustering > SPtr;
00051 
00052     /**
00053      * Convenience typedef for a boost::shared_ptr< const WDataSetFiberClustering >.
00054      */
00055     typedef boost::shared_ptr< const WDataSetFiberClustering > ConstSPtr;
00056 
00057     /**
00058      * The type of the cluster map
00059      */
00060     typedef std::map< size_t, WFiberCluster::SPtr > ClusterMap;
00061 
00062     /**
00063      * Default constructor.
00064      */
00065     WDataSetFiberClustering();
00066 
00067     /**
00068      * Destructor.
00069      */
00070     virtual ~WDataSetFiberClustering();
00071 
00072     /**
00073      * The name of this transferable. This is useful information for the users.
00074      *
00075      * \return the name.
00076      */
00077     virtual const std::string getName() const;
00078 
00079     /**
00080      *
00081      * The description of this transferable. This is useful information for the users.
00082      *
00083      * \return A description
00084      */
00085     virtual const std::string getDescription() const;
00086 
00087     /**
00088      * Returns a prototype instantiated with the true type of the deriving class.
00089      *
00090      * \return the prototype.
00091      */
00092     static boost::shared_ptr< WPrototyped > getPrototype();
00093 
00094     /**
00095      * Sets the cluster at the given ID. If there is a cluster at this ID, it is replaced.
00096      *
00097      * \param id the ID of the cluster
00098      * \param cluster the cluster
00099      */
00100     virtual void setCluster( size_t id, WFiberCluster::SPtr cluster );
00101 
00102     /**
00103      * Returns the cluster with the given ID.
00104      *
00105      * \throw WInvalidID if the ID is not known.
00106      *
00107      * \param id the ID of the cluster to get
00108      *
00109      * \return the cluster
00110      */
00111     virtual WFiberCluster::SPtr getCluster( size_t id );
00112 
00113     /**
00114      * Returns the cluster with the given ID. If there is no cluster with this ID, an empty one is returned.
00115      *
00116      * \param id the ID of the cluster to get
00117      *
00118      * \return the cluster
00119      */
00120     virtual WFiberCluster::SPtr getOrCreateCluster( size_t id );
00121 
00122     /**
00123      * Removes the cluster with the specified ID. If it does not exist, nothing happens.
00124      *
00125      * \param id the id of the cluster
00126      */
00127     virtual void removeCluster( size_t id );
00128 
00129     /**
00130      * The begin iterator of the clustering for const iteration.
00131      *
00132      * \return the begin iterator
00133      */
00134     ClusterMap::const_iterator begin() const;
00135 
00136     /**
00137      * The begin iterator of the clustering for non-const iteration.
00138      *
00139      * \return the begin iterator
00140      */
00141     ClusterMap::iterator begin();
00142 
00143     /**
00144      * The end iterator of the clustering for const iteration.
00145      *
00146      * \return the begin iterator
00147      */
00148     ClusterMap::const_iterator end() const;
00149 
00150     /**
00151      * The end iterator of the clustering for non-const iteration.
00152      *
00153      * \return the end iterator
00154      */
00155     ClusterMap::iterator end();
00156 
00157 protected:
00158     /**
00159      * Prototype for this dataset
00160      */
00161     static boost::shared_ptr< WPrototyped > m_prototype;
00162 private:
00163     /**
00164      * The map between ID and cluster.
00165      */
00166     std::map< size_t, WFiberCluster::SPtr > m_clusters;
00167 };
00168 
00169 #endif  // WDATASETFIBERCLUSTERING_H
00170