0.01.00
ot::Mac::ChannelMask Class Reference

This class defines a channel mask. More...

#include <src/core/mac/channel_mask.hpp>

Public Types

enum  {
  kChannelIteratorFirst = 0xff,
  kInfoStringSize = 45
}
 
typedef String< kInfoStringSizeInfoString
 This type defines the fixed-length String object returned from ToString().
 

Public Member Functions

 ChannelMask (void)
 This constructor initializes a ChannelMask instance.
 
 ChannelMask (uint32_t aMask)
 This constructor initializes a ChannelMask instance with a given mask. More...
 
void Clear (void)
 This method clears the channel mask.
 
uint32_t GetMask (void) const
 This method gets the channel mask (as a uint32_t bit-vector mask with bit 0 (lsb) -> channel 0, and so on). More...
 
void SetMask (uint32_t aMask)
 This method sets the channel mask. More...
 
bool IsEmpty (void) const
 This method indicates if the mask is empty. More...
 
bool IsSingleChannel (void) const
 This method indicates if the mask contains only a single channel. More...
 
bool ContainsChannel (uint8_t aChannel) const
 This method indicates if the mask contains a given channel. More...
 
void AddChannel (uint8_t aChannel)
 This method adds a channel to the channel mask. More...
 
void RemoveChannel (uint8_t aChannel)
 This method removes a channel from the channel mask. More...
 
void Intersect (const ChannelMask &aOtherMask)
 This method updates the channel mask by intersecting it with another mask. More...
 
uint8_t GetNumberOfChannels (void) const
 This method returns the number of channels in the mask. More...
 
otError GetNextChannel (uint8_t &aChannel) const
 This method gets the next channel in the channel mask. More...
 
bool operator== (const ChannelMask &aAnother) const
 This method overloads == operator to indicate whether two masks are equal. More...
 
bool operator!= (const ChannelMask &aAnother) const
 This method overloads != operator to indicate whether two masks are different. More...
 
InfoString ToString (void) const
 This method converts the channel mask into a human-readable string. More...
 

Detailed Description

This class defines a channel mask.

It is a wrapper class around a uint32_t bit vector representing a set of channels.

Member Enumeration Documentation

§ anonymous enum

anonymous enum
Enumerator
kChannelIteratorFirst 

Value to pass in GetNextChannel() to get the first channel in the mask.

kInfoStringSize 

Recommended buffer size to use with ToString().

Constructor & Destructor Documentation

§ ChannelMask()

ot::Mac::ChannelMask::ChannelMask ( uint32_t  aMask)
inline

This constructor initializes a ChannelMask instance with a given mask.

Parameters
[in]aMaskA channel mask (as a uint32_t bit-vector mask with bit 0 (lsb) -> channel 0, and so on).

Member Function Documentation

§ AddChannel()

void ot::Mac::ChannelMask::AddChannel ( uint8_t  aChannel)
inline

This method adds a channel to the channel mask.

Parameters
[in]aChannelA channel

§ ContainsChannel()

bool ot::Mac::ChannelMask::ContainsChannel ( uint8_t  aChannel) const
inline

This method indicates if the mask contains a given channel.

Parameters
[in]aChannelA channel.
Returns
TRUE if the channel aChannel is included in the mask, FALSE otherwise.

§ GetMask()

uint32_t ot::Mac::ChannelMask::GetMask ( void  ) const
inline

This method gets the channel mask (as a uint32_t bit-vector mask with bit 0 (lsb) -> channel 0, and so on).

Returns
The channel mask.

§ GetNextChannel()

otError ot::Mac::ChannelMask::GetNextChannel ( uint8_t &  aChannel) const

This method gets the next channel in the channel mask.

This method can be used to iterate over all channels in the channel mask. To get the first channel (channel with lowest number) in the mask the aChannel should be set to kChannelIteratorFirst.

Parameters
[in,out]aChannelA reference to a uint8_t. On entry it should contain the previous channel or kChannelIteratorFirst. On exit it contains the next channel.
Return values
OT_ERROR_NONEGot the next channel, aChannel updated successfully.
OT_ERROR_NOT_FOUNDNo next channel in the channel mask (note: aChannel may be changed).

§ GetNumberOfChannels()

uint8_t ot::Mac::ChannelMask::GetNumberOfChannels ( void  ) const

This method returns the number of channels in the mask.

Returns
Number of channels in the mask.

§ Intersect()

void ot::Mac::ChannelMask::Intersect ( const ChannelMask aOtherMask)
inline

This method updates the channel mask by intersecting it with another mask.

Parameters
[in]aOtherMaskAnother channel mask.

§ IsEmpty()

bool ot::Mac::ChannelMask::IsEmpty ( void  ) const
inline

This method indicates if the mask is empty.

Returns
TRUE if the mask is empty, FALSE otherwise.

§ IsSingleChannel()

bool ot::Mac::ChannelMask::IsSingleChannel ( void  ) const
inline

This method indicates if the mask contains only a single channel.

Returns
TRUE if channel mask contains a single channel, FALSE otherwise

§ operator!=()

bool ot::Mac::ChannelMask::operator!= ( const ChannelMask aAnother) const
inline

This method overloads != operator to indicate whether two masks are different.

Parameters
[in]aAnotherA reference to another mask to compare with the current one.
Returns
TRUE if the two masks are different, FALSE otherwise.

§ operator==()

bool ot::Mac::ChannelMask::operator== ( const ChannelMask aAnother) const
inline

This method overloads == operator to indicate whether two masks are equal.

Parameters
[in]aAnotherA reference to another mask to compare with the current one.
Returns
TRUE if the two masks are equal, FALSE otherwise.

§ RemoveChannel()

void ot::Mac::ChannelMask::RemoveChannel ( uint8_t  aChannel)
inline

This method removes a channel from the channel mask.

Parameters
[in]aChannelA channel

§ SetMask()

void ot::Mac::ChannelMask::SetMask ( uint32_t  aMask)
inline

This method sets the channel mask.

Parameters
[in]aMaskA channel mask (as a uint32_t bit-vector mask with bit 0 (lsb) -> channel 0, and so on).

§ ToString()

ChannelMask::InfoString ot::Mac::ChannelMask::ToString ( void  ) const

This method converts the channel mask into a human-readable string.

Examples of possible output:

  • empty mask -> "{ }"
  • all channels -> "{ 11-26 }"
  • single channel -> "{ 20 }"
  • multiple ranges -> "{ 11, 14-17, 20-22, 24, 25 }"
  • no range -> "{ 14, 21, 26 }"
Returns
An InfoString object representing the channel mask.

The documentation for this class was generated from the following files: