OpenWalnut 1.3.1
WDataSetFiberClustering.cpp
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 #include <string>
00026 
00027 #include "WDataSetFiberClustering.h"
00028 
00029 // The prototype as singleton. Created during first getPrototype() call
00030 boost::shared_ptr< WPrototyped > WDataSetFiberClustering::m_prototype = boost::shared_ptr< WPrototyped >();
00031 
00032 WDataSetFiberClustering::WDataSetFiberClustering()
00033 {
00034     // initialize members
00035 }
00036 
00037 WDataSetFiberClustering::~WDataSetFiberClustering()
00038 {
00039     // cleanup
00040 }
00041 
00042 boost::shared_ptr< WPrototyped > WDataSetFiberClustering::getPrototype()
00043 {
00044     if( !m_prototype )
00045     {
00046         m_prototype = boost::shared_ptr< WPrototyped >( new WDataSetFiberClustering() );
00047     }
00048     return m_prototype;
00049 }
00050 
00051 const std::string WDataSetFiberClustering::getName() const
00052 {
00053     return "DataSetFiberClustering";
00054 }
00055 
00056 const std::string WDataSetFiberClustering::getDescription() const
00057 {
00058     return "A collection of fiber clusters.";
00059 }
00060 
00061 void WDataSetFiberClustering::setCluster( size_t id, WFiberCluster::SPtr cluster )
00062 {
00063     m_clusters[ id ] = cluster;
00064 }
00065 
00066 WFiberCluster::SPtr WDataSetFiberClustering::getCluster( size_t id )
00067 {
00068     WFiberCluster::SPtr result = m_clusters[ id ];
00069     if( !result )
00070     {
00071         throw WInvalidID( "The cluster with the specified ID does not exist." );
00072     }
00073     return result;
00074 }
00075 
00076 WFiberCluster::SPtr WDataSetFiberClustering::getOrCreateCluster( size_t id )
00077 {
00078     WFiberCluster::SPtr result = m_clusters[ id ];
00079     if( !result )
00080     {
00081         // create an empty one
00082         WFiberCluster::SPtr newCluster( new WFiberCluster() );
00083         m_clusters[ id ] = newCluster;
00084         return newCluster;
00085     }
00086     return result;
00087 }
00088 
00089 void WDataSetFiberClustering::removeCluster( size_t id )
00090 {
00091     if( !m_clusters.count( id ) )
00092     {
00093         return;
00094     }
00095     m_clusters.erase( id );
00096 }
00097 
00098 WDataSetFiberClustering::ClusterMap::const_iterator WDataSetFiberClustering::begin() const
00099 {
00100     return m_clusters.begin();
00101 }
00102 
00103 WDataSetFiberClustering::ClusterMap::iterator WDataSetFiberClustering::begin()
00104 {
00105     return m_clusters.begin();
00106 }
00107 
00108 WDataSetFiberClustering::ClusterMap::const_iterator WDataSetFiberClustering::end() const
00109 {
00110     return m_clusters.end();
00111 }
00112 
00113 WDataSetFiberClustering::ClusterMap::iterator WDataSetFiberClustering::end()
00114 {
00115     return m_clusters.end();
00116 }
00117