CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbsHcalFunctor.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_AbsHcalFunctor_h
2 #define CondFormats_HcalObjects_AbsHcalFunctor_h
3 
4 #include <cfloat>
5 #include <typeinfo>
6 
7 #include "boost/serialization/access.hpp"
8 #include "boost/serialization/base_object.hpp"
9 #include "boost/serialization/export.hpp"
10 
11 // Archive headers are needed here for the serialization registration to work.
12 // <cassert> is needed for the archive headers to work.
13 #if !defined(__GCCXML__)
14 #include <cassert>
15 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
16 #include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
17 #endif /* #if !defined(__GCCXML__) */
18 
20 public:
21  inline virtual ~AbsHcalFunctor() {}
22 
23  // Method to override by concrete storable functor classes
24  virtual double operator()(double x) const = 0;
25 
26  // Functor domain. Should be overriden by derived classes if needed.
27  inline virtual double xmin() const { return -DBL_MAX; }
28  inline virtual double xmax() const { return DBL_MAX; }
29 
30  // Comparison operators. Note that they are not virtual and should
31  // not be overriden by derived classes. These operators are very
32  // useful for I/O testing.
33  inline bool operator==(const AbsHcalFunctor& r) const { return (typeid(*this) == typeid(r)) && this->isEqual(r); }
34  inline bool operator!=(const AbsHcalFunctor& r) const { return !(*this == r); }
35 
36 protected:
37  // Method needed to compare objects for equality.
38  // Must be implemented by derived classes.
39  virtual bool isEqual(const AbsHcalFunctor&) const = 0;
40 
41  // Check if the sequence of values is strictly increasing
42  template <class Iter>
43  static bool isStrictlyIncreasing(Iter begin, Iter const end) {
44  if (begin == end)
45  return false;
46  Iter first(begin);
47  bool status = ++begin != end;
48  for (; begin != end && status; ++begin, ++first)
49  if (!(*first < *begin))
50  status = false;
51  return status;
52  }
53 
54  // Check if the sequence of values is strictly decreasing
55  template <class Iter>
56  static bool isStrictlyDecreasing(Iter begin, Iter const end) {
57  if (begin == end)
58  return false;
59  Iter first(begin);
60  bool status = ++begin != end;
61  for (; begin != end && status; ++begin, ++first)
62  if (!(*begin < *first))
63  status = false;
64  return status;
65  }
66 
67 private:
69  template <typename Ar>
70  inline void serialize(Ar& ar, unsigned /* version */) {}
71 };
72 
73 BOOST_CLASS_EXPORT_KEY(AbsHcalFunctor)
74 
75 #endif // CondFormats_HcalObjects_AbsHcalFunctor_h
virtual bool isEqual(const AbsHcalFunctor &) const =0
list status
Definition: mps_update.py:107
static bool isStrictlyIncreasing(Iter begin, Iter const end)
virtual ~AbsHcalFunctor()
virtual double xmax() const
bool operator!=(const AbsHcalFunctor &r) const
static bool isStrictlyDecreasing(Iter begin, Iter const end)
friend class boost::serialization::access
void serialize(Ar &ar, unsigned)
virtual double operator()(double x) const =0
virtual double xmin() const
bool operator==(const AbsHcalFunctor &r) const
string end
Definition: dataset.py:937