Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:30

0001 #ifndef CondFormats_RPCObjects_RPCAMCLink_icc
0002 #define CondFormats_RPCObjects_RPCAMCLink_icc
0003 
0004 #include "CondFormats/RPCObjects/interface/RPCAMCLink.h"
0005 
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 inline ::uint32_t RPCAMCLink::getId() const { return id_; }
0009 
0010 inline RPCAMCLink::operator ::uint32_t() const { return id_; }
0011 
0012 inline bool RPCAMCLink::matches(RPCAMCLink const& rhs) const {
0013   return ((id_ & rhs.getMask()) == (getMask() & rhs.id_));
0014 }
0015 
0016 inline void RPCAMCLink::setId(::uint32_t const& id) { id_ = id; }
0017 
0018 inline void RPCAMCLink::reset() { id_ = 0x0; }
0019 
0020 // Field Getters
0021 inline int RPCAMCLink::getFED() const { return bf_get(min_fed_, mask_fed_, pos_fed_); }
0022 
0023 inline int RPCAMCLink::getAMCNumber() const { return bf_get(min_amcnumber_, mask_amcnumber_, pos_amcnumber_); }
0024 
0025 inline int RPCAMCLink::getAMCInput() const { return bf_get(min_amcinput_, mask_amcinput_, pos_amcinput_); }
0026 
0027 // Field Setters
0028 inline RPCAMCLink& RPCAMCLink::setFED(int fed) { return bf_set(min_fed_, max_fed_, mask_fed_, pos_fed_, fed); }
0029 
0030 inline RPCAMCLink& RPCAMCLink::setAMCNumber(int amcnumber) {
0031   return bf_set(min_amcnumber_, max_amcnumber_, mask_amcnumber_, pos_amcnumber_, amcnumber);
0032 }
0033 
0034 inline RPCAMCLink& RPCAMCLink::setAMCInput(int amcinput) {
0035   return bf_set(min_amcinput_, max_amcinput_, mask_amcinput_, pos_amcinput_, amcinput);
0036 }
0037 
0038 inline bool RPCAMCLink::operator<(RPCAMCLink const& rhs) const { return (id_ < rhs.id_); }
0039 
0040 inline bool RPCAMCLink::operator==(RPCAMCLink const& rhs) const { return (id_ == rhs.id_); }
0041 
0042 inline bool RPCAMCLink::operator!=(RPCAMCLink const& rhs) const { return (id_ != rhs.id_); }
0043 
0044 inline bool RPCAMCLink::operator<(::uint32_t const& rhs) const { return (id_ < rhs); }
0045 
0046 inline bool RPCAMCLink::operator==(::uint32_t const& rhs) const { return (id_ == rhs); }
0047 
0048 inline bool RPCAMCLink::operator!=(::uint32_t const& rhs) const { return (id_ != rhs); }
0049 
0050 inline RPCAMCLink& RPCAMCLink::operator++() {
0051   int value(0);
0052   if ((value = getAMCInput()) != wildcard_) {
0053     if (value < max_amcinput_)
0054       return setAMCInput(value + 1);
0055     setAMCInput(min_amcinput_);
0056   }
0057   if ((value = getAMCNumber()) != wildcard_) {
0058     if (value < max_amcnumber_)
0059       return setAMCNumber(value + 1);
0060     setAMCNumber(min_amcnumber_);
0061   }
0062   if ((value = getFED()) != wildcard_) {
0063     if (value < max_fed_)
0064       return setFED(value + 1);
0065     setFED(min_fed_);
0066   }
0067   return *this;
0068 }
0069 
0070 inline RPCAMCLink RPCAMCLink::operator++(int) {
0071   RPCAMCLink _value(*this);
0072   ++(*this);
0073   return _value;
0074 }
0075 
0076 inline RPCAMCLink& RPCAMCLink::operator--() {
0077   int value(0);
0078   if ((value = getAMCInput()) != wildcard_) {
0079     if (value > min_amcinput_)
0080       return setAMCInput(value - 1);
0081     setAMCInput(max_amcinput_);
0082   }
0083   if ((value = getAMCNumber()) != wildcard_) {
0084     if (value > min_amcnumber_)
0085       return setAMCNumber(value - 1);
0086     setAMCNumber(max_amcnumber_);
0087   }
0088   if ((value = getFED()) != wildcard_) {
0089     if (value > min_fed_)
0090       return setFED(value - 1);
0091     setFED(max_fed_);
0092   }
0093   return *this;
0094 }
0095 
0096 inline RPCAMCLink RPCAMCLink::operator--(int) {
0097   RPCAMCLink _value(*this);
0098   --(*this);
0099   return _value;
0100 }
0101 
0102 inline int RPCAMCLink::bf_get(int const min, ::uint32_t const mask, int const pos) const {
0103   ::uint32_t value(id_ & mask);
0104   if (value == 0)
0105     return wildcard_;
0106   return min + (int)(value >> pos) - 1;
0107 }
0108 
0109 inline RPCAMCLink& RPCAMCLink::bf_set(
0110     int const min, int const max, ::uint32_t const mask, int const pos, int const value) {
0111   if (value >= min && value <= max) {
0112     id_ &= ~mask;
0113     id_ |= (((::uint32_t)(value - min + 1) << pos) & mask);
0114   } else if (value == wildcard_)
0115     id_ &= ~mask;
0116   else
0117     throw cms::Exception("OutOfRange") << "Out-of-range input for RPCAMCLink::bf_set, position " << pos << ": "
0118                                        << value;
0119   return *this;
0120 }
0121 
0122 inline std::ostream& RPCAMCLink::bf_stream(std::ostream& ostream,
0123                                            int const min,
0124                                            ::uint32_t const mask,
0125                                            int const pos) const {
0126   ::uint32_t value(id_ & mask);
0127   if (value == 0)
0128     return (ostream << '*');
0129   return (ostream << (min + (int)(value >> pos) - 1));
0130 }
0131 
0132 #endif  // CondFormats_RPCObjects_RPCAMCLink_icc