00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // -------------------------------------------------------------------------- 00005 // OpenMS Mass Spectrometry Framework 00006 // -------------------------------------------------------------------------- 00007 // Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // -------------------------------------------------------------------------- 00024 // $Maintainer: Eva Lange $ 00025 // -------------------------------------------------------------------------- 00026 00027 #ifndef OPENMS_ANALYSIS_MAPMATCHING_INDEXTUPLE_H 00028 #define OPENMS_ANALYSIS_MAPMATCHING_INDEXTUPLE_H 00029 00030 #include <iostream> 00031 #include <vector> 00032 00033 #include<OpenMS/KERNEL/FeatureMap.h> 00034 00035 00036 namespace OpenMS 00037 { 00047 template < typename ContainerType = FeatureMap< Feature > > 00048 class IndexTuple 00049 { 00050 public: 00051 typedef typename ContainerType::value_type ElementType; 00052 typedef DPosition<2> PositionType; 00053 00055 IndexTuple() 00056 : map_index_(0), 00057 element_index_(0), 00058 element_pointer_(0) 00059 {} 00060 00062 inline IndexTuple(UInt map_index, UInt element_index, const ElementType& element) 00063 { 00064 map_index_ = map_index; 00065 element_index_ = element_index; 00066 element_pointer_ = const_cast<ElementType*>(&element); 00067 transformed_position_ = element_pointer_->getPosition(); 00068 } 00069 00071 inline IndexTuple(const IndexTuple& source) 00072 { 00073 map_index_ = source.map_index_; 00074 element_index_ = source.element_index_; 00075 element_pointer_ = source.element_pointer_; 00076 transformed_position_ = source.transformed_position_; 00077 } 00078 00080 IndexTuple& operator = (const IndexTuple& source) 00081 { 00082 if (&source == this) 00083 return *this; 00084 00085 map_index_ = source.map_index_; 00086 element_index_ = source.element_index_; 00087 element_pointer_ = source.element_pointer_; 00088 transformed_position_ = source.transformed_position_; 00089 return *this; 00090 } 00091 00093 virtual ~IndexTuple() 00094 {} 00095 00097 inline UInt getMapIndex() const 00098 { 00099 return map_index_; 00100 } 00101 00103 inline void setMapIndex(UInt c) 00104 { 00105 map_index_ = c; 00106 } 00107 00109 inline UInt getElementIndex() const 00110 { 00111 return element_index_; 00112 } 00113 00115 inline void setElementIndex(UInt e) 00116 { 00117 element_index_= e; 00118 } 00119 00121 inline const ElementType& getElement() const 00122 { 00123 return *element_pointer_; 00124 } 00125 00127 inline void setElement(const ElementType& e) 00128 { 00129 element_pointer_ = &e; 00130 } 00131 00133 inline const PositionType& getTransformedPosition() const 00134 { 00135 return transformed_position_; 00136 } 00137 00139 inline void setTransformedPosition(const PositionType& p) 00140 { 00141 transformed_position_ = p; 00142 } 00143 00145 virtual bool operator == (const IndexTuple& i) const 00146 { 00147 return ((map_index_ == i.map_index_) && (element_index_ == i.element_index_) && (element_pointer_ == i.element_pointer_)); 00148 } 00149 00151 virtual bool operator != (const IndexTuple& i) const 00152 { 00153 return !((map_index_ == i.map_index_) && (element_index_ == i.element_index_) && (element_pointer_ == i.element_pointer_)); 00154 } 00155 00157 struct IndexLess 00158 : std::binary_function < IndexTuple, IndexTuple, bool > 00159 { 00160 inline bool operator () ( IndexTuple const & left, IndexTuple const & right ) const 00161 { 00162 return ( left.map_index_ < right.map_index_ ); 00163 } 00164 }; 00165 00166 protected: 00168 PositionType transformed_position_; 00170 UInt map_index_; 00172 UInt element_index_; 00174 const ElementType* element_pointer_; 00175 }; 00176 00178 template < typename ContainerT > 00179 std::ostream& operator << (std::ostream& os, const IndexTuple<ContainerT>& cons) 00180 { 00181 os << "---------- IndexTuple -----------------\n" 00182 << "Transformed Position: " << cons.getTransformedPosition() << '\n' 00183 << "Original Position: " << cons.getElement() << '\n' 00184 << "Element Index: " << cons.getElementIndex() << '\n' 00185 << "Map Index: " << cons.getMapIndex() << std::endl; 00186 return os; 00187 } 00188 } // namespace OpenMS 00189 00190 #endif // OPENMS_ANALYSIS_MAPMAPPING_INDEXTUPLE_H
Generated Tue Apr 1 15:36:35 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |