Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CondFormats_RPCObjects_RPCAMCLink_h
0002 #define CondFormats_RPCObjects_RPCAMCLink_h
0003 
0004 #include <cstdint>
0005 #include <string>
0006 #include <iosfwd>
0007 #include <climits>
0008 
0009 #include "CondFormats/Serialization/interface/Serializable.h"
0010 
0011 /** Identifier for RPC AMC-LB path */
0012 class RPCAMCLink {
0013 public:
0014   static int const wildcard_ = INT_MIN;
0015 
0016   /** @{ */
0017   /** field ranges */
0018   static int const min_fed_ = 0;
0019   static int const max_fed_ = 65534;
0020   static int const min_amcnumber_ = 0;
0021   static int const max_amcnumber_ = 12;
0022   static int const min_amcinput_ = 0;
0023   static int const max_amcinput_ = 80;
0024   /** @} */
0025 
0026 protected:
0027   /** @{ */
0028   /** field positions and masks */
0029   static int const pos_fed_ = 16;
0030   static std::uint32_t const mask_fed_ = 0xffff0000;
0031   static int const pos_amcnumber_ = 12;
0032   static std::uint32_t const mask_amcnumber_ = 0x0000f000;
0033   static int const pos_amcinput_ = 0;
0034   static std::uint32_t const mask_amcinput_ = 0x00000fff;
0035   /** @} */
0036 
0037 public:
0038   RPCAMCLink();
0039   RPCAMCLink(std::uint32_t const& id);
0040   RPCAMCLink(int fed, int amcnumber, int amcinput = wildcard_);
0041 
0042   std::uint32_t getId() const;
0043   operator std::uint32_t() const;
0044   std::uint32_t getMask() const;
0045 
0046   bool matches(RPCAMCLink const& rhs) const;
0047 
0048   void setId(std::uint32_t const& id);
0049   void reset();
0050 
0051   /** @{ */
0052   /** Field Getters */
0053   int getFED() const;
0054   int getAMCNumber() const;
0055   int getAMCInput() const;
0056   /** @} */
0057 
0058   /** @{ */
0059   /** Field Setters
0060      * A cms::Exception("OutOfRange") is thrown for out-of-range input values.
0061      **/
0062   RPCAMCLink& setFED(int fed = wildcard_);
0063   RPCAMCLink& setAMCNumber(int amcnumber = wildcard_);
0064   RPCAMCLink& setAMCInput(int amcinput = wildcard_);
0065   /** @} */
0066 
0067   std::string getName() const;
0068 
0069   bool operator<(RPCAMCLink const& rhs) const;
0070   bool operator==(RPCAMCLink const& rhs) const;
0071   bool operator!=(RPCAMCLink const& rhs) const;
0072   bool operator<(std::uint32_t const& rhs) const;
0073   bool operator==(std::uint32_t const& rhs) const;
0074   bool operator!=(std::uint32_t const& rhs) const;
0075 
0076   RPCAMCLink& operator++();
0077   RPCAMCLink operator++(int);
0078   RPCAMCLink& operator--();
0079   RPCAMCLink operator--(int);
0080 
0081 protected:
0082   int bf_get(int const min, std::uint32_t const mask, int const pos) const;
0083   RPCAMCLink& bf_set(int const min, int const max, std::uint32_t const mask, int const pos, int const value);
0084   std::ostream& bf_stream(std::ostream& ostream, int const min, std::uint32_t const mask, int const pos) const;
0085 
0086 protected:
0087   std::uint32_t id_;
0088 
0089   COND_SERIALIZABLE;
0090 };
0091 
0092 std::ostream& operator<<(std::ostream& ostream, RPCAMCLink const& link);
0093 
0094 #include "CondFormats/RPCObjects/interface/RPCAMCLink.icc"
0095 
0096 #endif  // CondFormats_RPCObjects_RPCAMCLink_h