Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
FeatureHandle.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2013.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Erhan Kenar $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_KERNEL_FEATUREHANDLE_H
36 #define OPENMS_KERNEL_FEATUREHANDLE_H
37 
38 #include <iostream>
39 #include <vector>
40 
41 #include <OpenMS/KERNEL/Feature.h>
42 
43 namespace OpenMS
44 {
45  class ConsensusFeature;
54  class OPENMS_DLLAPI FeatureHandle :
55  public Peak2D,
56  public UniqueIdInterface
57  {
58 
59 public:
61 
63 
64  typedef Int ChargeType;
67  typedef Real WidthType;
69 
71 
72  FeatureHandle() :
74  Peak2D(),
76  map_index_(0),
77  charge_(0),
78  width_(0)
79  {}
80 
82  FeatureHandle(UInt64 map_index, const Peak2D & point, UInt64 element_index) :
83  Peak2D(point),
84  map_index_(map_index),
85  charge_(0),
86  width_(0)
87  {
88  setUniqueId(element_index);
89  }
90 
92  FeatureHandle(UInt64 map_index, const BaseFeature & feature) :
93  Peak2D(feature),
94  UniqueIdInterface(feature),
95  map_index_(map_index),
96  charge_(feature.getCharge()),
97  width_(feature.getWidth())
98  {}
99 
102  Peak2D(rhs),
103  UniqueIdInterface(rhs),
104  map_index_(rhs.map_index_),
105  charge_(rhs.charge_),
106  width_(rhs.width_)
107  {}
108 
111  {
112  Peak2D::operator=(rhs);
114  map_index_ = rhs.map_index_;
115  charge_ = rhs.charge_;
116  width_ = rhs.width_;
117 
118  return *this;
119  }
120 
122  virtual ~FeatureHandle()
123  {}
124 
140  FeatureHandleMutable_ & asMutable() const;
142 
144 
145  UInt64 getMapIndex() const
147  {
148  return map_index_;
149  }
150 
153  {
154  map_index_ = i;
155  }
156 
158  void setCharge(ChargeType charge)
159  {
160  charge_ = charge;
161  }
162 
165  {
166  return charge_;
167  }
168 
170  void setWidth(WidthType width)
171  {
172  width_ = width;
173  }
174 
177  {
178  return width_;
179  }
180 
182 
184  bool operator==(const FeatureHandle & i) const
185  {
186  return (Peak2D::operator==(i))
188  && (map_index_ == i.map_index_)
189  && (charge_ == i.charge_)
190  && (width_ == i.width_);
191  }
192 
194  bool operator!=(const FeatureHandle & i) const
195  {
196  return !(operator==(i));
197  }
198 
200  struct IndexLess :
201  std::binary_function<FeatureHandle, FeatureHandle, bool>
202  {
203  bool operator()(FeatureHandle const & left, FeatureHandle const & right) const
204  {
205  // if map indices are equal, use unique ids
206  if (left.map_index_ == right.map_index_)
207  {
208  return left.getUniqueId() < right.getUniqueId();
209  }
210  //else use map indices
211  return left.map_index_ < right.map_index_;
212  }
213 
214  };
215 
216 protected:
217 
224  };
225 
233  class OPENMS_DLLAPI FeatureHandle::FeatureHandleMutable_ :
234  public FeatureHandle
235  {
236 private:
241  };
242 
244  {
245  // the const cast is to remove constness, but note that FeatureHandleMutable_ lacks some mutators
246  return static_cast<FeatureHandleMutable_ &>(const_cast<FeatureHandle &>(*this));
247  }
248 
250  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const FeatureHandle & cons);
251 } // namespace OpenMS
252 
253 #endif // OPENMS_KERNEL_FEATUREHANDLE_H
FeatureHandle & operator=(const FeatureHandle &rhs)
Assignment operator.
Definition: FeatureHandle.h:110
float Real
Real type.
Definition: Types.h:109
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
FeatureHandle(UInt64 map_index, const BaseFeature &feature)
Constructor from map index and basic feature.
Definition: FeatureHandle.h:92
FeatureHandle(UInt64 map_index, const Peak2D &point, UInt64 element_index)
Constructor with map index, element index and position.
Definition: FeatureHandle.h:82
bool operator()(FeatureHandle const &left, FeatureHandle const &right) const
Definition: FeatureHandle.h:203
void setMapIndex(UInt64 i)
Set the map index.
Definition: FeatureHandle.h:152
void setCharge(ChargeType charge)
Sets the charge.
Definition: FeatureHandle.h:158
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
Size setUniqueId()
Assigns a new, valid unique id. Always returns 1.
Definition: UniqueIdInterface.h:150
Peak2D & operator=(const Peak2D &rhs)
Assignment operator.
Definition: Peak2D.h:217
Comparator by map and unique id.
Definition: FeatureHandle.h:200
void setWidth(WidthType width)
Sets the width (FWHM)
Definition: FeatureHandle.h:170
Int charge_
Charge of the feature.
Definition: FeatureHandle.h:221
bool operator!=(const FeatureHandle &i) const
Equality operator.
Definition: FeatureHandle.h:194
A basic LC-MS feature.
Definition: BaseFeature.h:55
ChargeType getCharge() const
Returns the charge.
Definition: FeatureHandle.h:164
Int ChargeType
Charge type.
Definition: FeatureHandle.h:65
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:75
FeatureHandle(const FeatureHandle &rhs)
Copy constructor.
Definition: FeatureHandle.h:101
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:51
UInt64 map_index_
Index of the element&#39;s container.
Definition: FeatureHandle.h:219
Real WidthType
Feature width type.
Definition: FeatureHandle.h:67
bool operator==(const FeatureHandle &i) const
Equality operator.
Definition: FeatureHandle.h:184
FeatureHandleMutable_ & asMutable() const
Override (most of all) constness.
Definition: FeatureHandle.h:243
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:54
UniqueIdInterface & operator=(UniqueIdInterface const &rhs)
Assignment operator - copies the unique id.
Definition: UniqueIdInterface.h:89
bool operator==(UniqueIdInterface const &rhs) const
Equality comparison operator - the unique ids must be equal (!)
Definition: UniqueIdInterface.h:102
Helper class returned by FeatureHandle::asMutable(), which see.
Definition: FeatureHandle.h:233
int Int
Signed integer type.
Definition: Types.h:100
WidthType getWidth() const
Returns the width (FWHM)
Definition: FeatureHandle.h:176
virtual ~FeatureHandle()
Destructor.
Definition: FeatureHandle.h:122
Real width_
Width of the feature (FWHM)
Definition: FeatureHandle.h:223
UInt64 getUniqueId() const
Non-mutable access to unique id - returns the unique id.
Definition: UniqueIdInterface.h:109

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:13 using doxygen 1.8.5