ubuntu-location-service: com::ubuntu::location::connectivity::BoundedInteger< Tag, min, max, inv > Class Template Reference

ubuntu-location-service .. An aggregating location service providing positioning and geocoding capabilities to applications.

Public Member Functions | Static Public Member Functions | List of all members
com::ubuntu::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::ubuntu::location::connectivity::BoundedInteger< Tag, min, max, inv >:

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

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

## Detailed Description

### template<typename Tag, int min, int max, int inv = min-1>
class com::ubuntu::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::ubuntu::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::ubuntu::location::connectivity::BoundedInteger< Tag, min, max, inv >::BoundedInteger | ( | int | value | ) |
| inlineexplicit

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::ubuntu::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>

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

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::ubuntu::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.

## ◆ invalid()

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

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

Returns the invalid value for the specified range.

Definition at line 45 of file bounded_integer.h.

## ◆ is_valid()

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

bool com::ubuntu::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.

## ◆ maximum()

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

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

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>

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

Access the minimum value of the integer.

Definition at line 53 of file bounded_integer.h.

## ◆ operator int()

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

com::ubuntu::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::ubuntu::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::ubuntu::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>

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

Returns max - min.

Definition at line 69 of file bounded_integer.h.

## ◆ reset()

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

void com::ubuntu::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::ubuntu::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:

- /build/location-service-git/src/location-service/include/location_service/com/ubuntu/location/connectivity/bounded_integer.h