Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:28

0001 #ifndef CondFormats_RPCObjects_RPCLBLink_icc
0002 #define CondFormats_RPCObjects_RPCLBLink_icc
0003 
0004 #include "CondFormats/RPCObjects/interface/RPCLBLink.h"
0005 
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 inline std::uint32_t RPCLBLink::getId() const { return id_; }
0009 
0010 inline RPCLBLink::operator std::uint32_t() const { return id_; }
0011 
0012 inline bool RPCLBLink::matches(RPCLBLink const& rhs) const { return ((id_ & rhs.getMask()) == (getMask() & rhs.id_)); }
0013 
0014 inline void RPCLBLink::setId(std::uint32_t const& id) { id_ = id; }
0015 
0016 inline void RPCLBLink::reset() { id_ = 0x0; }
0017 
0018 // Field Getters
0019 inline int RPCLBLink::getRegion() const { return bf_get(min_region_, mask_region_, pos_region_); }
0020 
0021 inline int RPCLBLink::getYoke() const { return bf_get(min_yoke_, mask_yoke_, pos_yoke_); }
0022 
0023 inline int RPCLBLink::getSector() const { return bf_get(min_sector_, mask_sector_, pos_sector_); }
0024 
0025 inline int RPCLBLink::getSide() const { return bf_get(min_side_, mask_side_, pos_side_); }
0026 
0027 inline int RPCLBLink::getWheelOrDisk() const { return bf_get(min_wheelordisk_, mask_wheelordisk_, pos_wheelordisk_); }
0028 
0029 inline int RPCLBLink::getFibre() const { return bf_get(min_fibre_, mask_fibre_, pos_fibre_); }
0030 
0031 inline int RPCLBLink::getRadial() const { return bf_get(min_radial_, mask_radial_, pos_radial_); }
0032 
0033 inline int RPCLBLink::getLinkBoard() const { return bf_get(min_linkboard_, mask_linkboard_, pos_linkboard_); }
0034 
0035 inline int RPCLBLink::getConnector() const { return bf_get(min_connector_, mask_connector_, pos_connector_); }
0036 
0037 // Field Setters
0038 inline RPCLBLink& RPCLBLink::setRegion(int region) {
0039   return bf_set(min_region_, max_region_, mask_region_, pos_region_, region);
0040 }
0041 
0042 inline RPCLBLink& RPCLBLink::setYoke(int yoke) { return bf_set(min_yoke_, max_yoke_, mask_yoke_, pos_yoke_, yoke); }
0043 
0044 inline RPCLBLink& RPCLBLink::setSector(int sector) {
0045   return bf_set(min_sector_, max_sector_, mask_sector_, pos_sector_, sector);
0046 }
0047 
0048 inline RPCLBLink& RPCLBLink::setSide(int side) { return bf_set(min_side_, max_side_, mask_side_, pos_side_, side); }
0049 
0050 inline RPCLBLink& RPCLBLink::setWheelOrDisk(int wheelordisk) {
0051   return bf_set(min_wheelordisk_, max_wheelordisk_, mask_wheelordisk_, pos_wheelordisk_, wheelordisk);
0052 }
0053 
0054 inline RPCLBLink& RPCLBLink::setFibre(int fibre) {
0055   return bf_set(min_fibre_, max_fibre_, mask_fibre_, pos_fibre_, fibre);
0056 }
0057 
0058 inline RPCLBLink& RPCLBLink::setRadial(int radial) {
0059   return bf_set(min_radial_, max_radial_, mask_radial_, pos_radial_, radial);
0060 }
0061 
0062 inline RPCLBLink& RPCLBLink::setLinkBoard(int linkboard) {
0063   return bf_set(min_linkboard_, max_linkboard_, mask_linkboard_, pos_linkboard_, linkboard);
0064 }
0065 
0066 inline RPCLBLink& RPCLBLink::setConnector(int connector) {
0067   return bf_set(min_connector_, max_connector_, mask_connector_, pos_connector_, connector);
0068 }
0069 
0070 inline bool RPCLBLink::operator<(RPCLBLink const& rhs) const { return (id_ < rhs.id_); }
0071 
0072 inline bool RPCLBLink::operator==(RPCLBLink const& rhs) const { return (id_ == rhs.id_); }
0073 
0074 inline bool RPCLBLink::operator!=(RPCLBLink const& rhs) const { return (id_ != rhs.id_); }
0075 
0076 inline bool RPCLBLink::operator<(std::uint32_t const& rhs) const { return (id_ < rhs); }
0077 
0078 inline bool RPCLBLink::operator==(std::uint32_t const& rhs) const { return (id_ == rhs); }
0079 
0080 inline bool RPCLBLink::operator!=(std::uint32_t const& rhs) const { return (id_ != rhs); }
0081 
0082 inline RPCLBLink& RPCLBLink::operator++() {
0083   int value(0);
0084   if ((value = getConnector()) != wildcard_) {
0085     if (value < max_connector_)
0086       return setConnector(value + 1);
0087     setConnector(min_connector_);
0088   }
0089   if ((value = getLinkBoard()) != wildcard_) {
0090     if (value < max_linkboard_)
0091       return setLinkBoard(value + 1);
0092     setLinkBoard(min_linkboard_);
0093   }
0094   if ((value = getRadial()) != wildcard_) {
0095     if (value < max_radial_)
0096       return setRadial(value + 1);
0097     setRadial(min_radial_);
0098   }
0099   if ((value = getFibre()) != wildcard_) {
0100     if (value < max_fibre_)
0101       return setFibre(value + 1);
0102     setFibre(min_fibre_);
0103   }
0104   if ((value = getWheelOrDisk()) != wildcard_) {
0105     if (value < max_wheelordisk_)
0106       return setWheelOrDisk(value + 1);
0107     setWheelOrDisk(min_wheelordisk_);
0108   }
0109   if ((value = getSide()) != wildcard_) {
0110     if (value < max_side_)
0111       return setSide(value + 1);
0112     setSide(min_side_);
0113   }
0114   if ((value = getSector()) != wildcard_) {
0115     if (value < max_sector_)
0116       return setSector(value + 1);
0117     setSector(min_sector_);
0118   }
0119   if ((value = getYoke()) != wildcard_) {
0120     if (value < max_yoke_)
0121       return setYoke(value + 1);
0122     setYoke(min_yoke_);
0123   }
0124   if ((value = getRegion()) != wildcard_) {
0125     if (value < max_region_)
0126       return setRegion(value + 1);
0127     setRegion(min_region_);
0128   }
0129   return *this;
0130 }
0131 
0132 inline RPCLBLink RPCLBLink::operator++(int) {
0133   RPCLBLink _value(*this);
0134   ++(*this);
0135   return _value;
0136 }
0137 
0138 inline RPCLBLink& RPCLBLink::operator--() {
0139   int value(0);
0140   if ((value = getConnector()) != wildcard_) {
0141     if (value > min_connector_)
0142       return setConnector(value - 1);
0143     setConnector(max_connector_);
0144   }
0145   if ((value = getLinkBoard()) != wildcard_) {
0146     if (value > min_linkboard_)
0147       return setLinkBoard(value - 1);
0148     setLinkBoard(max_linkboard_);
0149   }
0150   if ((value = getRadial()) != wildcard_) {
0151     if (value > min_radial_)
0152       return setRadial(value - 1);
0153     setRadial(max_radial_);
0154   }
0155   if ((value = getFibre()) != wildcard_) {
0156     if (value > min_fibre_)
0157       return setFibre(value - 1);
0158     setFibre(max_fibre_);
0159   }
0160   if ((value = getWheelOrDisk()) != wildcard_) {
0161     if (value > min_wheelordisk_)
0162       return setWheelOrDisk(value - 1);
0163     setWheelOrDisk(max_wheelordisk_);
0164   }
0165   if ((value = getSide()) != wildcard_) {
0166     if (value > min_side_)
0167       return setSide(value - 1);
0168     setSide(max_side_);
0169   }
0170   if ((value = getSector()) != wildcard_) {
0171     if (value > min_sector_)
0172       return setSector(value - 1);
0173     setSector(max_sector_);
0174   }
0175   if ((value = getYoke()) != wildcard_) {
0176     if (value > min_yoke_)
0177       return setYoke(value - 1);
0178     setYoke(max_yoke_);
0179   }
0180   if ((value = getRegion()) != wildcard_) {
0181     if (value > min_region_)
0182       return setRegion(value - 1);
0183     setRegion(max_region_);
0184   }
0185   return *this;
0186 }
0187 
0188 inline RPCLBLink RPCLBLink::operator--(int) {
0189   RPCLBLink _value(*this);
0190   --(*this);
0191   return _value;
0192 }
0193 
0194 inline int RPCLBLink::bf_get(int const min, std::uint32_t const mask, int const pos) const {
0195   std::uint32_t value(id_ & mask);
0196   if (value == 0)
0197     return wildcard_;
0198   return min + (int)(value >> pos) - 1;
0199 }
0200 
0201 inline RPCLBLink& RPCLBLink::bf_set(
0202     int const min, int const max, std::uint32_t const mask, int const pos, int const value) {
0203   if (value >= min && value <= max) {
0204     id_ &= ~mask;
0205     id_ |= (((std::uint32_t)(value - min + 1) << pos) & mask);
0206   } else if (value == wildcard_)
0207     id_ &= ~mask;
0208   else
0209     throw cms::Exception("OutOfRange") << "Out-of-range input for RPCLBLink::bf_set, position " << pos << ": " << value;
0210   return *this;
0211 }
0212 
0213 inline std::ostream& RPCLBLink::bf_stream(std::ostream& ostream,
0214                                           int const min,
0215                                           std::uint32_t const mask,
0216                                           int const pos) const {
0217   std::uint32_t value(id_ & mask);
0218   if (value == 0)
0219     return (ostream << '*');
0220   return (ostream << (min + (int)(value >> pos) - 1));
0221 }
0222 
0223 #endif  // CondFormats_RPCObjects_RPCLBLink_icc