OpenWalnut
1.4.0
|
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 #include <map> 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( const ClusterMap &clustering ) 00038 { 00039 m_clusters = clustering; 00040 } 00041 00042 00043 WDataSetFiberClustering::~WDataSetFiberClustering() 00044 { 00045 // cleanup 00046 } 00047 00048 boost::shared_ptr< WPrototyped > WDataSetFiberClustering::getPrototype() 00049 { 00050 if( !m_prototype ) 00051 { 00052 m_prototype = boost::shared_ptr< WPrototyped >( new WDataSetFiberClustering() ); 00053 } 00054 return m_prototype; 00055 } 00056 00057 const std::string WDataSetFiberClustering::getName() const 00058 { 00059 return "DataSetFiberClustering"; 00060 } 00061 00062 const std::string WDataSetFiberClustering::getDescription() const 00063 { 00064 return "A collection of fiber clusters."; 00065 } 00066 00067 void WDataSetFiberClustering::setCluster( size_t id, WFiberCluster::SPtr cluster ) 00068 { 00069 m_clusters[ id ] = cluster; 00070 } 00071 00072 WFiberCluster::SPtr WDataSetFiberClustering::getCluster( size_t id ) 00073 { 00074 WFiberCluster::SPtr result = m_clusters[ id ]; 00075 if( !result ) 00076 { 00077 throw WInvalidID( "The cluster with the specified ID does not exist." ); 00078 } 00079 return result; 00080 } 00081 00082 WFiberCluster::ConstSPtr WDataSetFiberClustering::getCluster( size_t id ) const 00083 { 00084 ClusterMap::const_iterator it = m_clusters.find( id ); 00085 if( it == m_clusters.end() ) 00086 { 00087 throw WInvalidID( "The cluster with the specified ID does not exist." ); 00088 } 00089 return it->second; 00090 } 00091 00092 WFiberCluster::SPtr WDataSetFiberClustering::getOrCreateCluster( size_t id ) 00093 { 00094 WFiberCluster::SPtr result = m_clusters[ id ]; 00095 if( !result ) 00096 { 00097 // create an empty one 00098 WFiberCluster::SPtr newCluster( new WFiberCluster() ); 00099 m_clusters[ id ] = newCluster; 00100 return newCluster; 00101 } 00102 return result; 00103 } 00104 00105 void WDataSetFiberClustering::removeCluster( size_t id ) 00106 { 00107 if( !m_clusters.count( id ) ) 00108 { 00109 return; 00110 } 00111 m_clusters.erase( id ); 00112 } 00113 00114 WDataSetFiberClustering::ClusterMap::const_iterator WDataSetFiberClustering::begin() const 00115 { 00116 return m_clusters.begin(); 00117 } 00118 00119 WDataSetFiberClustering::ClusterMap::iterator WDataSetFiberClustering::begin() 00120 { 00121 return m_clusters.begin(); 00122 } 00123 00124 WDataSetFiberClustering::ClusterMap::const_iterator WDataSetFiberClustering::end() const 00125 { 00126 return m_clusters.end(); 00127 } 00128 00129 WDataSetFiberClustering::ClusterMap::iterator WDataSetFiberClustering::end() 00130 { 00131 return m_clusters.end(); 00132 } 00133 00134 size_t WDataSetFiberClustering::size() const 00135 { 00136 return m_clusters.size(); 00137 } 00138 00139