Libsockcanpp
A complete C++ wrapper around socketcan.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes
sockcanpp::CanId Struct Reference

Represents a CAN ID in a simple and easy-to-use manner. More...

#include <CanId.hpp>

Public Member Functions

constexpr CanId ()=default
 
constexpr CanId (const canid_t id)
 
constexpr CanId (const int32_t id)
 
 CanId (const char *id)
 
constexpr canid_t operator* () const
 Returns the raw CAN ID value.
 
constexpr operator int16_t () const
 
constexpr operator uint16_t () const
 
constexpr operator int32_t () const
 
constexpr operator canid_t () const
 
template<typename T >
constexpr CanId operator& (const T x) const
 Performs a bitwise AND operation on this ID and another.
 
constexpr CanId operator& (const CanId &x) const
 Performs a bitwise AND operation on this ID and another.
 
template<typename T >
constexpr CanId operator| (const T x) const
 Performs a bitwise OR operation on this ID and a 16-bit integer.
 
constexpr CanId operator| (const CanId &x) const
 Performs a bitwise OR operation on this ID and another.
 
template<typename T >
constexpr CanId operator^ (const T x) const
 Performs a bitwise XOR operation on this ID and a 16-bit integer.
 
constexpr CanId operator^ (const CanId &x) const
 Performs a bitwise XOR operation on this ID and another.
 
constexpr CanId operator~ () const
 Performs a bitwise NOT operation on this ID.
 
template<typename T >
constexpr CanId operator<< (const T x) const
 Shifts this ID to the left by a 16-bit integer.
 
constexpr CanId operator<< (const CanId &x) const
 Shifts this ID to the left by another.
 
template<typename T >
constexpr CanId operator>> (const T x) const
 Shifts this ID to the right by a 16-bit integer.
 
constexpr CanId operator>> (const CanId &x) const
 Shifts this ID to the right by another.
 
template<typename T >
CanId operator<<= (const T x)
 Shifts this ID to the left by a 16-bit integer.
 
CanId operator<<= (const CanId &x)
 Shifts this ID to the left by another.
 
template<typename T >
CanId operator>>= (const T x)
 Shifts this ID to the right by a 16-bit integer.
 
CanId operator>>= (const CanId &x)
 Shifts this ID to the right by another.
 
constexpr bool operator== (const CanId &x) const
 Compares this ID to another.
 
template<typename T >
constexpr bool operator== (const T x) const
 Compares this ID to another.
 
constexpr bool operator!= (const CanId &x) const
 Compares this ID to another.
 
template<typename T >
constexpr bool operator!= (const T x) const
 Compares this ID to another.
 
template<typename T >
constexpr bool operator< (T x) const
 Compares this ID to another.
 
template<typename T >
constexpr bool operator> (T x) const
 Compares this ID to a 32-bit integer.
 
template<typename T >
constexpr bool operator<= (const T x) const
 Compares this ID to another.
 
template<typename T >
constexpr bool operator>= (const T x) const
 Compares this ID to another.
 
template<typename T >
constexpr CanId operator= (const T val)
 Assigns a new integer to this CanID.
 
constexpr CanId operator= (const int64_t val)
 Assigns a 64-bit integer to this ID.
 
template<typename T >
constexpr CanId operator|= (const T x)
 Performs a bitwise OR operation on this ID and another.
 
template<typename T >
constexpr CanId operator&= (const T x)
 Performs a bitwise AND operation on this ID and another.
 
template<typename T >
constexpr CanId operator^= (const T x)
 Performs a bitwise XOR operation on this ID and another.
 
template<typename T >
constexpr CanId operator+ (const T x) const
 
template<typename T >
constexpr CanId operator+= (const T x)
 
template<typename T >
constexpr CanId operator-= (const T x)
 
template<typename T >
constexpr CanId operator- (const T x) const
 
template<typename T >
constexpr CanId operator* (const T x) const
 
template<typename T >
constexpr CanId operator*= (const T x)
 
template<typename T >
constexpr CanId operator/ (const T x) const
 
template<typename T >
constexpr CanId operator/= (const T x)
 
template<typename T >
constexpr CanId operator% (const T x) const
 
template<typename T >
constexpr CanId operator%= (const T x)
 
constexpr bool hasErrorFrameFlag () const
 Indicates whether or not this ID is an error frame.
 
constexpr bool hasRtrFrameFlag () const
 Indicates whether or not this ID is a remote transmission request.
 
constexpr bool isStandardFrameId () const
 Indicates whether or not this ID is a standard frame ID.
 
constexpr bool isExtendedFrameId () const
 Indicates whether or not this ID is an extended frame ID.
 
constexpr bool equals (const CanId &otherId) const
 Compares this ID to another.
 

Static Public Member Functions

template<typename T >
static constexpr bool isValidIdentifier (T value)
 Indicates whether or not a given integer is a valid CAN identifier.
 
template<typename T >
static constexpr bool isErrorFrame (T value)
 Indicates whether or not a given integer contains the error frame flag or not.
 
template<typename T >
static constexpr bool isRemoteTransmissionRequest (T value)
 Indicates whether the received frame is a remote transmission request.
 
template<typename T >
static constexpr bool isExtendedFrame (T value)
 Indicates whether or not a given integer is an extended frame ID.
 

Private Attributes

uint32_t m_identifier = 0
 

Detailed Description

Represents a CAN ID in a simple and easy-to-use manner.

Definition at line 61 of file CanId.hpp.

Constructor & Destructor Documentation

◆ CanId() [1/4]

constexpr sockcanpp::CanId::CanId ( )
constexprdefault

◆ CanId() [2/4]

constexpr sockcanpp::CanId::CanId ( const canid_t  id)
inlineconstexpr

Definition at line 64 of file CanId.hpp.

64: m_identifier(id) { }
uint32_t m_identifier
Definition CanId.hpp:259

References m_identifier.

Referenced by sockcanpp::CanMessage::CanMessage().

◆ CanId() [3/4]

constexpr sockcanpp::CanId::CanId ( const int32_t  id)
inlineconstexpr

Definition at line 65 of file CanId.hpp.

65: m_identifier(id) { }

References m_identifier.

◆ CanId() [4/4]

sockcanpp::CanId::CanId ( const char *  id)
inline

Definition at line 72 of file CanId.hpp.

72{ m_identifier = std::stoul(id, nullptr, 16); }

References m_identifier.

Member Function Documentation

◆ equals()

constexpr bool sockcanpp::CanId::equals ( const CanId otherId) const
inlineconstexpr

Compares this ID to another.

Definition at line 256 of file CanId.hpp.

References m_identifier.

◆ hasErrorFrameFlag()

constexpr bool sockcanpp::CanId::hasErrorFrameFlag ( ) const
inlineconstexpr

Indicates whether or not this ID is an error frame.

Definition at line 250 of file CanId.hpp.

References isErrorFrame(), and m_identifier.

◆ hasRtrFrameFlag()

constexpr bool sockcanpp::CanId::hasRtrFrameFlag ( ) const
inlineconstexpr

Indicates whether or not this ID is a remote transmission request.

Definition at line 251 of file CanId.hpp.

References isRemoteTransmissionRequest(), and m_identifier.

◆ isErrorFrame()

template<typename T >
static constexpr bool sockcanpp::CanId::isErrorFrame ( value)
inlinestaticconstexpr

Indicates whether or not a given integer contains the error frame flag or not.

Parameters
valueThe integer to check.
Returns
true If value has the error frame flag (bit) set to 1.
false Otherwise.

Definition at line 219 of file CanId.hpp.

219 {
220 return static_cast<canid_t>(value) & CAN_ERR_FLAG;
221 }

Referenced by hasErrorFrameFlag().

◆ isExtendedFrame()

template<typename T >
static constexpr bool sockcanpp::CanId::isExtendedFrame ( value)
inlinestaticconstexpr

Indicates whether or not a given integer is an extended frame ID.

Parameters
valueThe integer to check.
Returns
true If the frame is in the extended format.
false Otherwise.

Definition at line 245 of file CanId.hpp.

245 {
246 return static_cast<canid_t>(value) & CAN_EFF_FLAG;
247 }

Referenced by isExtendedFrameId(), and isStandardFrameId().

◆ isExtendedFrameId()

constexpr bool sockcanpp::CanId::isExtendedFrameId ( ) const
inlineconstexpr

Indicates whether or not this ID is an extended frame ID.

Definition at line 253 of file CanId.hpp.

References isExtendedFrame(), and m_identifier.

◆ isRemoteTransmissionRequest()

template<typename T >
static constexpr bool sockcanpp::CanId::isRemoteTransmissionRequest ( value)
inlinestaticconstexpr

Indicates whether the received frame is a remote transmission request.

Parameters
valueThe integer to check.
Returns
true If the frame is a remote transmission request.
false Otherwise.

Definition at line 232 of file CanId.hpp.

232 {
233 return static_cast<canid_t>(value) & CAN_RTR_FLAG;
234 }

Referenced by hasRtrFrameFlag().

◆ isStandardFrameId()

constexpr bool sockcanpp::CanId::isStandardFrameId ( ) const
inlineconstexpr

Indicates whether or not this ID is a standard frame ID.

Definition at line 252 of file CanId.hpp.

References isExtendedFrame(), and m_identifier.

◆ isValidIdentifier()

template<typename T >
static constexpr bool sockcanpp::CanId::isValidIdentifier ( value)
inlinestaticconstexpr

Indicates whether or not a given integer is a valid CAN identifier.

Parameters
valueThe integer to check.
Returns
true If value is a valid CAN identifier.
false Otherwise.

Definition at line 206 of file CanId.hpp.

206 {
207 return static_cast<canid_t>(value) <= CAN_EFF_MASK;
208 }

◆ operator canid_t()

constexpr sockcanpp::CanId::operator canid_t ( ) const
inlineconstexpr

Definition at line 81 of file CanId.hpp.

81{ return m_identifier & CAN_ERR_MASK; }

References m_identifier.

◆ operator int16_t()

constexpr sockcanpp::CanId::operator int16_t ( ) const
inlineconstexpr

Definition at line 78 of file CanId.hpp.

78{ return static_cast<int16_t>(m_identifier) & CAN_ERR_MASK; }

References m_identifier.

◆ operator int32_t()

constexpr sockcanpp::CanId::operator int32_t ( ) const
inlineconstexpr

Definition at line 80 of file CanId.hpp.

80{ return m_identifier & CAN_ERR_MASK; }

References m_identifier.

◆ operator uint16_t()

constexpr sockcanpp::CanId::operator uint16_t ( ) const
inlineconstexpr

Definition at line 79 of file CanId.hpp.

79{ return static_cast<uint16_t>(m_identifier) & CAN_ERR_MASK; }

References m_identifier.

◆ operator!=() [1/2]

constexpr bool sockcanpp::CanId::operator!= ( const CanId x) const
inlineconstexpr

Compares this ID to another.

Definition at line 123 of file CanId.hpp.

References m_identifier.

◆ operator!=() [2/2]

template<typename T >
constexpr bool sockcanpp::CanId::operator!= ( const T  x) const
inlineconstexpr

Compares this ID to another.

Definition at line 126 of file CanId.hpp.

References m_identifier.

◆ operator%()

template<typename T >
constexpr CanId sockcanpp::CanId::operator% ( const T  x) const
inlineconstexpr

Definition at line 190 of file CanId.hpp.

190{ return m_identifier % x; }

References m_identifier.

◆ operator%=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator%= ( const T  x)
inlineconstexpr

Definition at line 193 of file CanId.hpp.

193{ return m_identifier %= x; }

References m_identifier.

◆ operator&() [1/2]

constexpr CanId sockcanpp::CanId::operator& ( const CanId x) const
inlineconstexpr

Performs a bitwise AND operation on this ID and another.

Definition at line 87 of file CanId.hpp.

References m_identifier.

◆ operator&() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator& ( const T  x) const
inlineconstexpr

Performs a bitwise AND operation on this ID and another.

Definition at line 86 of file CanId.hpp.

References m_identifier.

◆ operator&=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator&= ( const T  x)
inlineconstexpr

Performs a bitwise AND operation on this ID and another.

Definition at line 158 of file CanId.hpp.

References m_identifier.

◆ operator*() [1/2]

constexpr canid_t sockcanpp::CanId::operator* ( ) const
inlineconstexpr

Returns the raw CAN ID value.

Definition at line 75 of file CanId.hpp.

References m_identifier.

Referenced by sockcanpp::CanIdHasher::operator()(), and sockcanpp::CanDriver::setCanFilters().

◆ operator*() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator* ( const T  x) const
inlineconstexpr

Definition at line 178 of file CanId.hpp.

178{ return m_identifier * x; }

References m_identifier.

◆ operator*=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator*= ( const T  x)
inlineconstexpr

Definition at line 181 of file CanId.hpp.

181{ return m_identifier *= x; }

References m_identifier.

◆ operator+()

template<typename T >
constexpr CanId sockcanpp::CanId::operator+ ( const T  x) const
inlineconstexpr

Definition at line 166 of file CanId.hpp.

166{ return m_identifier + x; }

References m_identifier.

◆ operator+=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator+= ( const T  x)
inlineconstexpr

Definition at line 169 of file CanId.hpp.

169{ return m_identifier += x; }

References m_identifier.

◆ operator-()

template<typename T >
constexpr CanId sockcanpp::CanId::operator- ( const T  x) const
inlineconstexpr

Definition at line 175 of file CanId.hpp.

175{ return m_identifier - x; }

References m_identifier.

◆ operator-=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator-= ( const T  x)
inlineconstexpr

Definition at line 172 of file CanId.hpp.

172{ return m_identifier -= x; }

References m_identifier.

◆ operator/()

template<typename T >
constexpr CanId sockcanpp::CanId::operator/ ( const T  x) const
inlineconstexpr

Definition at line 184 of file CanId.hpp.

184{ return m_identifier / x; }

References m_identifier.

◆ operator/=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator/= ( const T  x)
inlineconstexpr

Definition at line 187 of file CanId.hpp.

187{ return m_identifier /= x; }

References m_identifier.

◆ operator<()

template<typename T >
constexpr bool sockcanpp::CanId::operator< ( x) const
inlineconstexpr

Compares this ID to another.

Definition at line 129 of file CanId.hpp.

References m_identifier.

◆ operator<<() [1/2]

constexpr CanId sockcanpp::CanId::operator<< ( const CanId x) const
inlineconstexpr

Shifts this ID to the left by another.

Definition at line 101 of file CanId.hpp.

References m_identifier.

◆ operator<<() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator<< ( const T  x) const
inlineconstexpr

Shifts this ID to the left by a 16-bit integer.

Definition at line 100 of file CanId.hpp.

References m_identifier.

◆ operator<<=() [1/2]

CanId sockcanpp::CanId::operator<<= ( const CanId x)
inline

Shifts this ID to the left by another.

Definition at line 109 of file CanId.hpp.

References m_identifier.

◆ operator<<=() [2/2]

template<typename T >
CanId sockcanpp::CanId::operator<<= ( const T  x)
inline

Shifts this ID to the left by a 16-bit integer.

Definition at line 108 of file CanId.hpp.

References m_identifier.

◆ operator<=()

template<typename T >
constexpr bool sockcanpp::CanId::operator<= ( const T  x) const
inlineconstexpr

Compares this ID to another.

Definition at line 135 of file CanId.hpp.

References m_identifier.

◆ operator=() [1/2]

constexpr CanId sockcanpp::CanId::operator= ( const int64_t  val)
inlineconstexpr

Assigns a 64-bit integer to this ID.

Definition at line 152 of file CanId.hpp.

References operator=().

◆ operator=() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator= ( const T  val)
inlineconstexpr

Assigns a new integer to this CanID.

Definition at line 143 of file CanId.hpp.

Referenced by operator=().

◆ operator==() [1/2]

constexpr bool sockcanpp::CanId::operator== ( const CanId x) const
inlineconstexpr

Compares this ID to another.

Definition at line 118 of file CanId.hpp.

References m_identifier.

◆ operator==() [2/2]

template<typename T >
constexpr bool sockcanpp::CanId::operator== ( const T  x) const
inlineconstexpr

Compares this ID to another.

Definition at line 121 of file CanId.hpp.

References m_identifier.

◆ operator>()

template<typename T >
constexpr bool sockcanpp::CanId::operator> ( x) const
inlineconstexpr

Compares this ID to a 32-bit integer.

Definition at line 132 of file CanId.hpp.

References m_identifier.

◆ operator>=()

template<typename T >
constexpr bool sockcanpp::CanId::operator>= ( const T  x) const
inlineconstexpr

Compares this ID to another.

Definition at line 138 of file CanId.hpp.

References m_identifier.

◆ operator>>() [1/2]

constexpr CanId sockcanpp::CanId::operator>> ( const CanId x) const
inlineconstexpr

Shifts this ID to the right by another.

Definition at line 105 of file CanId.hpp.

References m_identifier.

◆ operator>>() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator>> ( const T  x) const
inlineconstexpr

Shifts this ID to the right by a 16-bit integer.

Definition at line 104 of file CanId.hpp.

References m_identifier.

◆ operator>>=() [1/2]

CanId sockcanpp::CanId::operator>>= ( const CanId x)
inline

Shifts this ID to the right by another.

Definition at line 113 of file CanId.hpp.

References m_identifier.

◆ operator>>=() [2/2]

template<typename T >
CanId sockcanpp::CanId::operator>>= ( const T  x)
inline

Shifts this ID to the right by a 16-bit integer.

Definition at line 112 of file CanId.hpp.

References m_identifier.

◆ operator^() [1/2]

constexpr CanId sockcanpp::CanId::operator^ ( const CanId x) const
inlineconstexpr

Performs a bitwise XOR operation on this ID and another.

Definition at line 95 of file CanId.hpp.

References m_identifier.

◆ operator^() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator^ ( const T  x) const
inlineconstexpr

Performs a bitwise XOR operation on this ID and a 16-bit integer.

Definition at line 94 of file CanId.hpp.

References m_identifier.

◆ operator^=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator^= ( const T  x)
inlineconstexpr

Performs a bitwise XOR operation on this ID and another.

Definition at line 161 of file CanId.hpp.

References m_identifier.

◆ operator|() [1/2]

constexpr CanId sockcanpp::CanId::operator| ( const CanId x) const
inlineconstexpr

Performs a bitwise OR operation on this ID and another.

Definition at line 91 of file CanId.hpp.

References m_identifier.

◆ operator|() [2/2]

template<typename T >
constexpr CanId sockcanpp::CanId::operator| ( const T  x) const
inlineconstexpr

Performs a bitwise OR operation on this ID and a 16-bit integer.

Definition at line 90 of file CanId.hpp.

References m_identifier.

◆ operator|=()

template<typename T >
constexpr CanId sockcanpp::CanId::operator|= ( const T  x)
inlineconstexpr

Performs a bitwise OR operation on this ID and another.

Definition at line 155 of file CanId.hpp.

References m_identifier.

◆ operator~()

constexpr CanId sockcanpp::CanId::operator~ ( ) const
inlineconstexpr

Performs a bitwise NOT operation on this ID.

Definition at line 97 of file CanId.hpp.

References m_identifier.

Field Documentation

◆ m_identifier

uint32_t sockcanpp::CanId::m_identifier = 0
private

The documentation for this struct was generated from the following file: