RPCAMCLink

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
#ifndef CondFormats_RPCObjects_RPCAMCLink_h
#define CondFormats_RPCObjects_RPCAMCLink_h

#include <cstdint>
#include <string>
#include <iosfwd>
#include <climits>

#include "CondFormats/Serialization/interface/Serializable.h"

/** Identifier for RPC AMC-LB path */
class RPCAMCLink {
public:
  static int const wildcard_ = INT_MIN;

  /** @{ */
  /** field ranges */
  static int const min_fed_ = 0;
  static int const max_fed_ = 65534;
  static int const min_amcnumber_ = 0;
  static int const max_amcnumber_ = 12;
  static int const min_amcinput_ = 0;
  static int const max_amcinput_ = 80;
  /** @} */

protected:
  /** @{ */
  /** field positions and masks */
  static int const pos_fed_ = 16;
  static std::uint32_t const mask_fed_ = 0xffff0000;
  static int const pos_amcnumber_ = 12;
  static std::uint32_t const mask_amcnumber_ = 0x0000f000;
  static int const pos_amcinput_ = 0;
  static std::uint32_t const mask_amcinput_ = 0x00000fff;
  /** @} */

public:
  RPCAMCLink();
  RPCAMCLink(std::uint32_t const& id);
  RPCAMCLink(int fed, int amcnumber, int amcinput = wildcard_);

  std::uint32_t getId() const;
  operator std::uint32_t() const;
  std::uint32_t getMask() const;

  bool matches(RPCAMCLink const& rhs) const;

  void setId(std::uint32_t const& id);
  void reset();

  /** @{ */
  /** Field Getters */
  int getFED() const;
  int getAMCNumber() const;
  int getAMCInput() const;
  /** @} */

  /** @{ */
  /** Field Setters
     * A cms::Exception("OutOfRange") is thrown for out-of-range input values.
     **/
  RPCAMCLink& setFED(int fed = wildcard_);
  RPCAMCLink& setAMCNumber(int amcnumber = wildcard_);
  RPCAMCLink& setAMCInput(int amcinput = wildcard_);
  /** @} */

  std::string getName() const;

  bool operator<(RPCAMCLink const& rhs) const;
  bool operator==(RPCAMCLink const& rhs) const;
  bool operator!=(RPCAMCLink const& rhs) const;
  bool operator<(std::uint32_t const& rhs) const;
  bool operator==(std::uint32_t const& rhs) const;
  bool operator!=(std::uint32_t const& rhs) const;

  RPCAMCLink& operator++();
  RPCAMCLink operator++(int);
  RPCAMCLink& operator--();
  RPCAMCLink operator--(int);

protected:
  int bf_get(int const min, std::uint32_t const mask, int const pos) const;
  RPCAMCLink& bf_set(int const min, int const max, std::uint32_t const mask, int const pos, int const value);
  std::ostream& bf_stream(std::ostream& ostream, int const min, std::uint32_t const mask, int const pos) const;

protected:
  std::uint32_t id_;

  COND_SERIALIZABLE;
};

std::ostream& operator<<(std::ostream& ostream, RPCAMCLink const& link);

#include "CondFormats/RPCObjects/interface/RPCAMCLink.icc"

#endif  // CondFormats_RPCObjects_RPCAMCLink_h