File indexing completed on 2024-04-06 12:02:12
0001 #ifndef CondFormats_HcalObjects_AbsHcalFunctor_h
0002 #define CondFormats_HcalObjects_AbsHcalFunctor_h
0003
0004 #include <cfloat>
0005 #include <typeinfo>
0006
0007 #include "boost/serialization/access.hpp"
0008 #include "boost/serialization/base_object.hpp"
0009 #include "boost/serialization/export.hpp"
0010
0011
0012
0013 #if !defined(__GCCXML__)
0014 #include <cassert>
0015 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
0016 #include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
0017 #endif
0018
0019 class AbsHcalFunctor {
0020 public:
0021 inline virtual ~AbsHcalFunctor() {}
0022
0023
0024 virtual double operator()(double x) const = 0;
0025
0026
0027 inline virtual double xmin() const { return -DBL_MAX; }
0028 inline virtual double xmax() const { return DBL_MAX; }
0029
0030
0031
0032
0033 inline bool operator==(const AbsHcalFunctor& r) const { return (typeid(*this) == typeid(r)) && this->isEqual(r); }
0034 inline bool operator!=(const AbsHcalFunctor& r) const { return !(*this == r); }
0035
0036 protected:
0037
0038
0039 virtual bool isEqual(const AbsHcalFunctor&) const = 0;
0040
0041
0042 template <class Iter>
0043 static bool isStrictlyIncreasing(Iter begin, Iter const end) {
0044 if (begin == end)
0045 return false;
0046 Iter first(begin);
0047 bool status = ++begin != end;
0048 for (; begin != end && status; ++begin, ++first)
0049 if (!(*first < *begin))
0050 status = false;
0051 return status;
0052 }
0053
0054
0055 template <class Iter>
0056 static bool isStrictlyDecreasing(Iter begin, Iter const end) {
0057 if (begin == end)
0058 return false;
0059 Iter first(begin);
0060 bool status = ++begin != end;
0061 for (; begin != end && status; ++begin, ++first)
0062 if (!(*begin < *first))
0063 status = false;
0064 return status;
0065 }
0066
0067 private:
0068 friend class boost::serialization::access;
0069 template <typename Ar>
0070 inline void serialize(Ar& ar, unsigned ) {}
0071 };
0072
0073 BOOST_CLASS_EXPORT_KEY(AbsHcalFunctor)
0074
0075 #endif