source: trunk/yat/utility/DataWeight.h @ 1887

Last change on this file since 1887 was 1887, checked in by Peter, 15 years ago

closes #512. added relates tag in namespace utility.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1#ifndef _theplu_yat_utility_data_weight_
2#define _theplu_yat_utility_data_weight_
3
4// $Id: DataWeight.h 1887 2009-03-31 17:38:16Z peter $
5
6/*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26namespace theplu {
27namespace yat {
28namespace utility {
29
30  /**
31     \brief Holds a pair of data and associated weight
32
33     The class has comparison operators (declared outside class) that
34     are designed to ignore the weights, and behaves like the
35     corresponding double operator behaves for data().
36
37     \since New in yat 0.5
38  */
39  class DataWeight
40  {
41  public:
42    /**
43       \brief Default constructor
44
45       \param data data value to hold
46       \param weight weight value to hold
47     */
48    explicit DataWeight(double data=0.0, double weight=1.0);
49
50    /**
51       \return reference to data
52     */
53    double& data(void);
54
55    /**
56       \return const reference to data
57     */
58    const double& data(void) const;
59
60    /**
61       \return reference to weight
62     */
63    double& weight(void);
64
65    /**
66       \return const reference to weight
67     */
68    const double& weight(void) const;
69  private:
70    double data_;
71    double weight_;
72    // using compiler generated copy
73    // DataWeight(const DataWeight&)
74    // DataWeight& operator=(const DataWeight&);
75  };
76
77  /**
78     \brief equality operator
79
80     \return true if lhs.data() == rhs.data()
81
82     \relates DataWeight
83   */
84  bool operator==(const DataWeight& lhs, const DataWeight& rhs);
85
86  /**
87     \brief inequality operator
88
89     \return true if lhs.data() != rhs.data()
90
91     \relates DataWeight
92   */
93  bool operator!=(const DataWeight&, const DataWeight&);
94
95  /**
96     \brief comparison operator
97
98     \return true if lhs data is less than rhs data
99
100     \relates DataWeight
101   */
102  bool operator<(const DataWeight&, const DataWeight&);
103
104  /**
105     \brief comparison operator
106
107     \return true if lhs data is greater than rhs data
108
109     \relates DataWeight
110   */
111  bool operator>(const DataWeight&, const DataWeight&);
112
113  /**
114     \brief comparison operator
115
116     \return true if lhs.data() <= rhs.data()
117
118     \relates DataWeight
119   */
120  bool operator<=(const DataWeight&, const DataWeight&);
121
122  /**
123     \brief comparison operator
124
125     \return true if lhs.data() >= rhs.data()
126
127     \relates DataWeight
128   */
129  bool operator>=(const DataWeight&, const DataWeight&);
130
131
132}}} // of namespace utility, yat, and theplu
133
134#endif
Note: See TracBrowser for help on using the repository browser.