Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_KERNEL_FEATUREHANDLE_H
00036 #define OPENMS_KERNEL_FEATUREHANDLE_H
00037
00038 #include <iostream>
00039 #include <vector>
00040
00041 #include <OpenMS/KERNEL/Feature.h>
00042
00043 namespace OpenMS
00044 {
00045 class ConsensusFeature;
00054 class OPENMS_DLLAPI FeatureHandle :
00055 public Peak2D,
00056 public UniqueIdInterface
00057 {
00058
00059 public:
00060 class FeatureHandleMutable_;
00061
00063
00064
00065 typedef Int ChargeType;
00067 typedef Real WidthType;
00069
00071
00072
00073 FeatureHandle() :
00074 Peak2D(),
00075 UniqueIdInterface(),
00076 map_index_(0),
00077 charge_(0),
00078 width_(0)
00079 {}
00080
00082 FeatureHandle(UInt64 map_index, const Peak2D & point, UInt64 element_index) :
00083 Peak2D(point),
00084 map_index_(map_index),
00085 charge_(0),
00086 width_(0)
00087 {
00088 setUniqueId(element_index);
00089 }
00090
00092 FeatureHandle(UInt64 map_index, const BaseFeature & feature) :
00093 Peak2D(feature),
00094 UniqueIdInterface(feature),
00095 map_index_(map_index),
00096 charge_(feature.getCharge()),
00097 width_(feature.getWidth())
00098 {}
00099
00101 FeatureHandle(const FeatureHandle & rhs) :
00102 Peak2D(rhs),
00103 UniqueIdInterface(rhs),
00104 map_index_(rhs.map_index_),
00105 charge_(rhs.charge_),
00106 width_(rhs.width_)
00107 {}
00108
00110 FeatureHandle & operator=(const FeatureHandle & rhs)
00111 {
00112 Peak2D::operator=(rhs);
00113 UniqueIdInterface::operator=(rhs);
00114 map_index_ = rhs.map_index_;
00115 charge_ = rhs.charge_;
00116 width_ = rhs.width_;
00117
00118 return *this;
00119 }
00120
00122 virtual ~FeatureHandle()
00123 {}
00124
00140 FeatureHandleMutable_ & asMutable() const;
00142
00144
00145
00146 UInt64 getMapIndex() const
00147 {
00148 return map_index_;
00149 }
00150
00152 void setMapIndex(UInt64 i)
00153 {
00154 map_index_ = i;
00155 }
00156
00158 void setCharge(ChargeType charge)
00159 {
00160 charge_ = charge;
00161 }
00162
00164 ChargeType getCharge() const
00165 {
00166 return charge_;
00167 }
00168
00170 void setWidth(WidthType width)
00171 {
00172 width_ = width;
00173 }
00174
00176 WidthType getWidth() const
00177 {
00178 return width_;
00179 }
00180
00182
00184 bool operator==(const FeatureHandle & i) const
00185 {
00186 return (Peak2D::operator==(i))
00187 && (UniqueIdInterface::operator==(i))
00188 && (map_index_ == i.map_index_)
00189 && (charge_ == i.charge_)
00190 && (width_ == i.width_);
00191 }
00192
00194 bool operator!=(const FeatureHandle & i) const
00195 {
00196 return !(operator==(i));
00197 }
00198
00200 struct IndexLess :
00201 std::binary_function<FeatureHandle, FeatureHandle, bool>
00202 {
00203 bool operator()(FeatureHandle const & left, FeatureHandle const & right) const
00204 {
00205
00206 if (left.map_index_ == right.map_index_)
00207 {
00208 return left.getUniqueId() < right.getUniqueId();
00209 }
00210
00211 return left.map_index_ < right.map_index_;
00212 }
00213
00214 };
00215
00216 protected:
00217
00219 UInt64 map_index_;
00221 Int charge_;
00223 Real width_;
00224 };
00225
00233 class OPENMS_DLLAPI FeatureHandle::FeatureHandleMutable_ :
00234 public FeatureHandle
00235 {
00236 private:
00237 using FeatureHandle::setUniqueId;
00238 using FeatureHandle::setMapIndex;
00239 FeatureHandleMutable_();
00240 FeatureHandleMutable_(const FeatureHandleMutable_ &);
00241 };
00242
00243 inline FeatureHandle::FeatureHandleMutable_ & FeatureHandle::asMutable() const
00244 {
00245
00246 return static_cast<FeatureHandleMutable_ &>(const_cast<FeatureHandle &>(*this));
00247 }
00248
00250 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const FeatureHandle & cons);
00251 }
00252
00253 #endif // OPENMS_KERNEL_FEATUREHANDLE_H