Rivet  3.1.2
SingleValueProjection.hh
1 // -*- C++ -*-
2 #ifndef RIVET_SINGLEVALUEPROJECTION_HH
3 #define RIVET_SINGLEVALUEPROJECTION_HH
4 
5 #include "Rivet/Projection.hh"
6 
7 namespace Rivet {
8 
9 
18  public:
19 
21  SingleValueProjection() : _value(-1.0), _isSet(false) {
22  setName("SingleValueProjection");
23  }
24 
26  bool isValueSet() const {
27  return _isSet;
28  }
30  bool isSet() const { return isValueSet(); }
31 
33  double value() const {
34  return _value;
35  }
36 
38  double operator()() const {
39  return value();
40  }
41 
42 
43  protected:
44 
46  void setValue(double v) {
47  _value = v;
48  _isSet = true;
49  }
51  void set(double v) { setValue(v); }
52 
54  void clear() {
55  _value = -1.0;
56  _isSet = false;
57  }
58 
59 
60  private:
61 
62  double _value;
63 
65  bool _isSet;
66 
67  };
68 
69 
70 }
71 
72 #endif
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:142
Definition: MC_Cent_pPb.hh:10
void setValue(double v)
Set the value.
Definition: SingleValueProjection.hh:46
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
bool isSet() const
Definition: SingleValueProjection.hh:30
double value() const
Return the single value.
Definition: SingleValueProjection.hh:33
bool isValueSet() const
Returns true if the value has been set.
Definition: SingleValueProjection.hh:26
SingleValueProjection()
The default constructor.
Definition: SingleValueProjection.hh:21
double operator()() const
Return the single value.
Definition: SingleValueProjection.hh:38
Base class for all Rivet projections.
Definition: Projection.hh:29
void clear()
Unset the value.
Definition: SingleValueProjection.hh:54