Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CondFormats_RPCObjects_RPCDCCLink_icc
0002 #define CondFormats_RPCObjects_RPCDCCLink_icc
0003 
0004 #include "CondFormats/RPCObjects/interface/RPCDCCLink.h"
0005 
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 inline std::uint32_t RPCDCCLink::getId() const { return id_; }
0009 
0010 inline RPCDCCLink::operator std::uint32_t() const { return id_; }
0011 
0012 inline bool RPCDCCLink::matches(RPCDCCLink const& rhs) const {
0013   return ((id_ & rhs.getMask()) == (getMask() & rhs.id_));
0014 }
0015 
0016 inline void RPCDCCLink::setId(std::uint32_t const& id) { id_ = id; }
0017 
0018 inline void RPCDCCLink::reset() { id_ = 0x0; }
0019 
0020 // Field Getters
0021 inline int RPCDCCLink::getFED() const { return bf_get(min_fed_, mask_fed_, pos_fed_); }
0022 
0023 inline int RPCDCCLink::getDCCInput() const { return bf_get(min_dccinput_, mask_dccinput_, pos_dccinput_); }
0024 
0025 inline int RPCDCCLink::getTBInput() const { return bf_get(min_tbinput_, mask_tbinput_, pos_tbinput_); }
0026 
0027 // Field Setters
0028 inline RPCDCCLink& RPCDCCLink::setFED(int fed) { return bf_set(min_fed_, max_fed_, mask_fed_, pos_fed_, fed); }
0029 
0030 inline RPCDCCLink& RPCDCCLink::setDCCInput(int dccinput) {
0031   return bf_set(min_dccinput_, max_dccinput_, mask_dccinput_, pos_dccinput_, dccinput);
0032 }
0033 
0034 inline RPCDCCLink& RPCDCCLink::setTBInput(int tbinput) {
0035   return bf_set(min_tbinput_, max_tbinput_, mask_tbinput_, pos_tbinput_, tbinput);
0036 }
0037 
0038 inline bool RPCDCCLink::operator<(RPCDCCLink const& rhs) const { return (id_ < rhs.id_); }
0039 
0040 inline bool RPCDCCLink::operator==(RPCDCCLink const& rhs) const { return (id_ == rhs.id_); }
0041 
0042 inline bool RPCDCCLink::operator!=(RPCDCCLink const& rhs) const { return (id_ != rhs.id_); }
0043 
0044 inline bool RPCDCCLink::operator<(std::uint32_t const& rhs) const { return (id_ < rhs); }
0045 
0046 inline bool RPCDCCLink::operator==(std::uint32_t const& rhs) const { return (id_ == rhs); }
0047 
0048 inline bool RPCDCCLink::operator!=(std::uint32_t const& rhs) const { return (id_ != rhs); }
0049 
0050 inline RPCDCCLink& RPCDCCLink::operator++() {
0051   int value(0);
0052   if ((value = getTBInput()) != wildcard_) {
0053     if (value < max_tbinput_)
0054       return setTBInput(value + 1);
0055     setTBInput(min_tbinput_);
0056   }
0057   if ((value = getDCCInput()) != wildcard_) {
0058     if (value < max_dccinput_)
0059       return setDCCInput(value + 1);
0060     setDCCInput(min_dccinput_);
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 RPCDCCLink RPCDCCLink::operator++(int) {
0071   RPCDCCLink _value(*this);
0072   ++(*this);
0073   return _value;
0074 }
0075 
0076 inline RPCDCCLink& RPCDCCLink::operator--() {
0077   int value(0);
0078   if ((value = getTBInput()) != wildcard_) {
0079     if (value > min_tbinput_)
0080       return setTBInput(value - 1);
0081     setTBInput(max_tbinput_);
0082   }
0083   if ((value = getDCCInput()) != wildcard_) {
0084     if (value > min_dccinput_)
0085       return setDCCInput(value - 1);
0086     setDCCInput(max_dccinput_);
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 RPCDCCLink RPCDCCLink::operator--(int) {
0097   RPCDCCLink _value(*this);
0098   --(*this);
0099   return _value;
0100 }
0101 
0102 inline int RPCDCCLink::bf_get(int const min, std::uint32_t const mask, int const pos) const {
0103   std::uint32_t value(id_ & mask);
0104   if (value == 0)
0105     return wildcard_;
0106   return min + (int)(value >> pos) - 1;
0107 }
0108 
0109 inline RPCDCCLink& RPCDCCLink::bf_set(
0110     int const min, int const max, std::uint32_t const mask, int const pos, int const value) {
0111   if (value >= min && value <= max) {
0112     id_ &= ~mask;
0113     id_ |= (((std::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 RPCDCCLink::bf_set, position " << pos << ": "
0118                                        << value;
0119   return *this;
0120 }
0121 
0122 inline std::ostream& RPCDCCLink::bf_stream(std::ostream& ostream,
0123                                            int const min,
0124                                            std::uint32_t const mask,
0125                                            int const pos) const {
0126   std::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_RPCDCCLink_icc