com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv > Class Template Reference

A helper class to handle bounded integer values, with an optional domain for tagging domain-specific types. More...

`#include <bounded_integer.h>`

Collaboration diagram for com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >:

## Public Member Functions

| BoundedInteger ()
| Constructs an invalid instance.
| BoundedInteger (int value)
| Constructs an instance from a raw value.
| BoundedInteger (const BoundedInteger< Tag, min, max, inv > &rhs)
| Copy c'tor.
BoundedInteger< Tag, min, max, inv > & | operator= (const BoundedInteger< Tag, min, max, inv > &rhs)
| Assignment operator.
bool | operator== (const BoundedInteger< Tag, min, max, inv > &rhs) const
| Equality comparison operator.
| operator int () const
| Implicit casting operator to a raw integer value.
bool | is_valid () const
| is_valid checks whether the contained value is in [min, max].
int | get () const
| Returns the raw integer value contained in this instance.
void | set (int new_value)
| Assigns a new raw integer value.
void | reset ()
| Resets the instance to an invalid value.

## Static Public Member Functions

static int | invalid ()
| Returns the invalid value for the specified range.
static int | minimum ()
| Access the minimum value of the integer.
static int | maximum ()
| Access the maximum value of the integer.
static int | range ()
| Returns max - min.
static BoundedInteger< Tag, min, max, inv > | from_percent (float percent)
| from_percent creates a new instance, mapping to the defined range of valid values.

## Detailed Description

template<typename Tag, int min, int max, int inv = min-1>
class com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >

A helper class to handle bounded integer values, with an optional domain for tagging domain-specific types.

Definition at line 37 of file bounded_integer.h.

## Constructor & Destructor Documentation

## BoundedInteger() [1/3]

template<typename Tag, int min, int max, int inv = min-1>

com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::BoundedInteger | ( |  | ) |

inline

Constructs an invalid instance.

Definition at line 91 of file bounded_integer.h.

## BoundedInteger() [2/3]

template<typename Tag, int min, int max, int inv = min-1>

com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::BoundedInteger | ( | int | value | ) |

inline explicit

Constructs an instance from a raw value.

Parameters

  value | The raw value.

Exceptions

  std::runtime_error | if value is not in [min, max].

Definition at line 100 of file bounded_integer.h.

## BoundedInteger() [3/3]

template<typename Tag, int min, int max, int inv = min-1>

com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::BoundedInteger | ( | const BoundedInteger< Tag, min, max, inv > & | rhs | ) |

inline

Copy c'tor.

Parameters

  rhs | The instance to copy from.

Definition at line 112 of file bounded_integer.h.

## Member Function Documentation

## from_percent()

template<typename Tag, int min, int max, int inv = min-1>

BoundedInteger< Tag, min, max, inv > com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::from_percent | ( | float | percent | ) |

inline static

from_percent creates a new instance, mapping to the defined range of valid values.

Definition at line 77 of file bounded_integer.h.

## get()

template<typename Tag, int min, int max, int inv = min-1>

int com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::get | ( |  | ) | const

inline

Returns the raw integer value contained in this instance.

Exceptions

  std::runtime_error | if is_valid() returns false.

Definition at line 159 of file bounded_integer.h.

Referenced by com::lomiri::location::connectivity::BoundedInteger< Tag::Frequency, 2412, 5825 >::operator int().

## invalid()

template<typename Tag, int min, int max, int inv = min-1>

int com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::invalid | ( |  | ) |

inline static

Returns the invalid value for the specified range.

Definition at line 45 of file bounded_integer.h.

Referenced by com::lomiri::location::connectivity::BoundedInteger< Tag::Frequency, 2412, 5825 >::reset().

## is_valid()

template<typename Tag, int min, int max, int inv = min-1>

bool com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::is_valid | ( |  | ) | const

inline

is_valid checks whether the contained value is in [min, max].

Returns
  true iff the contained integer value is in [min, max].

Definition at line 150 of file bounded_integer.h.

Referenced by com::lomiri::location::connectivity::BoundedInteger< Tag::Frequency, 2412, 5825 >::operator<<.

## maximum()

template<typename Tag, int min, int max, int inv = min-1>

int com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::maximum | ( |  | ) |

inline static

Access the maximum value of the integer.

Definition at line 61 of file bounded_integer.h.

## minimum()

template<typename Tag, int min, int max, int inv = min-1>

int com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::minimum | ( |  | ) |

inline static

Access the minimum value of the integer.

Definition at line 53 of file bounded_integer.h.

Referenced by com::lomiri::location::connectivity::BoundedInteger< Tag::Frequency, 2412, 5825 >::from_percent().

## operator int()

template<typename Tag, int min, int max, int inv = min-1>

com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::operator int | ( |  | ) | const

inline

Implicit casting operator to a raw integer value.

Returns
  The raw integer value.

Definition at line 141 of file bounded_integer.h.

## operator=()

template<typename Tag, int min, int max, int inv = min-1>

BoundedInteger< Tag, min, max, inv > & com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::operator= | ( | const BoundedInteger< Tag, min, max, inv > & | rhs | ) |

inline

Assignment operator.

Parameters

  rhs | The instance to assign from.

Returns
  A mutable reference to this instance.

Definition at line 121 of file bounded_integer.h.

## operator==()

template<typename Tag, int min, int max, int inv = min-1>

bool com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::operator== | ( | const BoundedInteger< Tag, min, max, inv > & | rhs | ) | const

inline

Equality comparison operator.

Parameters

  rhs | The instance to compare to.

Returns
  true iff both instances' value are equal.

Definition at line 132 of file bounded_integer.h.

## range()

template<typename Tag, int min, int max, int inv = min-1>

int com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::range | ( |  | ) |

inline static

Returns max - min.

Definition at line 69 of file bounded_integer.h.

Referenced by com::lomiri::location::connectivity::BoundedInteger< Tag::Frequency, 2412, 5825 >::from_percent().

## reset()

template<typename Tag, int min, int max, int inv = min-1>

void com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::reset | ( |  | ) |

inline

Resets the instance to an invalid value.

Definition at line 180 of file bounded_integer.h.

## set()

template<typename Tag, int min, int max, int inv = min-1>

void com::lomiri::location::connectivity::BoundedInteger< Tag, min, max, inv >::set | ( | int | new_value | ) |

inline

Assigns a new raw integer value.

Parameters

  new_value | The new value.

Exceptions

  std::runtime_error | if new_value is not in [min, max].

Definition at line 169 of file bounded_integer.h.

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

- bounded_integer.h