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-2017.
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 #ifndef OPENMS_KERNEL_FEATUREHANDLE_H
36 #define OPENMS_KERNEL_FEATUREHANDLE_H
37 
38 #include <OpenMS/CONCEPT/Types.h>
40 #include <OpenMS/KERNEL/Peak2D.h>
41 #include <OpenMS/OpenMSConfig.h>
42 
43 #include <iosfwd>
44 #include <vector>
45 
46 namespace OpenMS
47 {
48  class BaseFeature;
49 
58  class OPENMS_DLLAPI FeatureHandle :
59  public Peak2D,
60  public UniqueIdInterface
61  {
62 
63 public:
65 
67 
68  typedef Int ChargeType;
71  typedef float WidthType;
73 
75 
76  FeatureHandle();
78 
80  FeatureHandle(UInt64 map_index, const Peak2D& point, UInt64 element_index);
81 
83  FeatureHandle(UInt64 map_index, const BaseFeature& feature);
84 
86  FeatureHandle(const FeatureHandle& rhs);
87 
89  FeatureHandle& operator=(const FeatureHandle& rhs);
90 
92  virtual ~FeatureHandle();
93 
109  FeatureHandleMutable_& asMutable() const;
111 
113 
114  UInt64 getMapIndex() const;
116 
118  void setMapIndex(UInt64 i);
119 
121  void setCharge(ChargeType charge);
122 
124  ChargeType getCharge() const;
125 
127  void setWidth(WidthType width);
128 
130  WidthType getWidth() const;
131 
133 
135  bool operator==(const FeatureHandle& i) const;
136 
138  bool operator!=(const FeatureHandle& i) const;
139 
141  struct IndexLess :
142  std::binary_function<FeatureHandle, FeatureHandle, bool>
143  {
144  bool operator()(FeatureHandle const& left, FeatureHandle const& right) const;
145  };
146 
147 protected:
148 
154  float width_;
155  };
156 
164  class OPENMS_DLLAPI FeatureHandle::FeatureHandleMutable_ :
165  public FeatureHandle
166  {
167 private:
172  };
173 
175  {
176  // the const cast is to remove constness, but note that FeatureHandleMutable_ lacks some mutators
177  // TODO use const_cast
178  return static_cast<FeatureHandleMutable_&>(const_cast<FeatureHandle&>(*this));
179  }
180 
181  inline bool FeatureHandle::IndexLess::operator()(FeatureHandle const& left, FeatureHandle const& right) const
182  {
183  // if map indices are equal, use unique ids
184  if (left.map_index_ == right.map_index_)
185  {
186  return left.getUniqueId() < right.getUniqueId();
187  }
188  //else use map indices
189  return left.map_index_ < right.map_index_;
190  }
191 
193  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureHandle& cons);
194 } // namespace OpenMS
195 
196 #endif // OPENMS_KERNEL_FEATUREHANDLE_H
float width_
Width of the feature (FWHM)
Definition: FeatureHandle.h:154
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
bool operator()(FeatureHandle const &left, FeatureHandle const &right) const
Definition: FeatureHandle.h:181
void setMapIndex(UInt64 i)
Set the map index.
Size setUniqueId()
Assigns a new, valid unique id. Always returns 1.
Definition: UniqueIdInterface.h:151
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
Comparator by map and unique id.
Definition: FeatureHandle.h:141
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Int charge_
Charge of the feature.
Definition: FeatureHandle.h:152
A basic LC-MS feature.
Definition: BaseFeature.h:56
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Int ChargeType
Charge type.
Definition: FeatureHandle.h:69
FeatureHandleMutable_ & asMutable() const
Override (most of all) constness.
Definition: FeatureHandle.h:174
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:78
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:52
UInt64 map_index_
Index of the element&#39;s container.
Definition: FeatureHandle.h:150
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:58
float WidthType
Feature width type.
Definition: FeatureHandle.h:71
Helper class returned by FeatureHandle::asMutable(), which see.
Definition: FeatureHandle.h:164
UInt64 getUniqueId() const
Non-mutable access to unique id - returns the unique id.
Definition: UniqueIdInterface.h:110
int Int
Signed integer type.
Definition: Types.h:103

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:00 using doxygen 1.8.13