OpenMS  3.0.0
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-2022.
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: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
39 #include <OpenMS/KERNEL/Peak2D.h>
40 #include <OpenMS/OpenMSConfig.h>
41 
42 #include <iosfwd>
43 #include <vector>
44 
45 namespace OpenMS
46 {
47  class BaseFeature;
48 
57  class OPENMS_DLLAPI FeatureHandle :
58  public Peak2D,
59  public UniqueIdInterface
60  {
61 
62 public:
64 
66 
67  typedef Int ChargeType;
70  typedef float WidthType;
72 
74 
75  FeatureHandle();
77 
79  FeatureHandle(UInt64 map_index, const Peak2D& point, UInt64 element_index);
80 
82  FeatureHandle(UInt64 map_index, const BaseFeature& feature);
83 
85  FeatureHandle(const FeatureHandle& rhs);
86 
88  FeatureHandle& operator=(const FeatureHandle& rhs);
89 
91  ~FeatureHandle() override;
92 
108  FeatureHandleMutable_& asMutable() const;
110 
112 
113  UInt64 getMapIndex() const;
115 
117  void setMapIndex(UInt64 i);
118 
120  void setCharge(ChargeType charge);
121 
123  ChargeType getCharge() const;
124 
126  void setWidth(WidthType width);
127 
129  WidthType getWidth() const;
130 
132 
134  bool operator==(const FeatureHandle& i) const;
135 
137  bool operator!=(const FeatureHandle& i) const;
138 
140  struct IndexLess
141  {
142  bool operator()(FeatureHandle const& left, FeatureHandle const& right) const;
143  };
144 
145 protected:
146 
152  float width_;
153  };
154 
162  class OPENMS_DLLAPI FeatureHandle::FeatureHandleMutable_ :
163  public FeatureHandle
164  {
165 private:
170  };
171 
173  {
174  // the const cast is to remove constness, but note that FeatureHandleMutable_ lacks some mutators
175  // TODO use const_cast
176  return static_cast<FeatureHandleMutable_&>(const_cast<FeatureHandle&>(*this));
177  }
178 
179  inline bool FeatureHandle::IndexLess::operator()(FeatureHandle const& left, FeatureHandle const& right) const
180  {
181  // if map indices are equal, use unique ids
182  if (left.map_index_ == right.map_index_)
183  {
184  return left.getUniqueId() < right.getUniqueId();
185  }
186  //else use map indices
187  return left.map_index_ < right.map_index_;
188  }
189 
191  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureHandle& cons);
192 } // namespace OpenMS
193 
UniqueIdInterface.h
OpenMS::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Types.h
OpenMS::Peak2D
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:58
KDTree::operator!=
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
OpenMS::FeatureHandle::width_
float width_
Width of the feature (FWHM)
Definition: FeatureHandle.h:152
OpenMS::UniqueIdInterface
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:50
OpenMS::FeatureHandle::FeatureHandleMutable_
Helper class returned by FeatureHandle::asMutable(), which see.
Definition: FeatureHandle.h:162
OpenMS::FeatureHandle::IndexLess
Comparator by map and unique id.
Definition: FeatureHandle.h:140
OpenMS::FeatureHandle::setMapIndex
void setMapIndex(UInt64 i)
Set the map index.
OpenMS::FeatureHandle::ChargeType
Int ChargeType
Charge type.
Definition: FeatureHandle.h:68
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Peak2D.h
OpenMS::Peak2D::operator<<
friend std::ostream & operator<<(std::ostream &os, const Peak2D &point)
Print the contents to a stream.
OpenMS::FeatureHandle::charge_
Int charge_
Charge of the feature.
Definition: FeatureHandle.h:150
OpenMS::UniqueIdInterface::setUniqueId
Size setUniqueId()
Assigns a new, valid unique id. Always returns 1.
OpenMS::FeatureHandle::map_index_
UInt64 map_index_
Index of the element's container.
Definition: FeatureHandle.h:148
OpenMS::FeatureHandle::IndexLess::operator()
bool operator()(FeatureHandle const &left, FeatureHandle const &right) const
Definition: FeatureHandle.h:179
OpenMS::FeatureHandle::WidthType
float WidthType
Feature width type.
Definition: FeatureHandle.h:70
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::FeatureHandle
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
float
OpenMS::FeatureHandle::asMutable
FeatureHandleMutable_ & asMutable() const
Override (most of all) constness.
Definition: FeatureHandle.h:172
OpenMS::UniqueIdInterface::getUniqueId
UInt64 getUniqueId() const
Non-mutable access to unique id - returns the unique id.
Definition: UniqueIdInterface.h:104