Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Address.hxx
Go to the documentation of this file.
1
35#ifndef _DCC_ADDRESS_HXX_
36#define _DCC_ADDRESS_HXX_
37
38#include <stdint.h>
39
40#include "utils/macros.h"
41
42namespace dcc
43{
44
49{
51 static constexpr unsigned ADDRESS_MAX = 127;
53 uint8_t value;
55 explicit DccShortAddress(unsigned v)
56 : value(v)
57 {
59 }
60};
61
66{
68 static constexpr unsigned ADDRESS_MAX = 10239;
70 uint16_t value;
72 explicit DccLongAddress(unsigned v)
73 : value(v)
74 {
76 }
77};
78
82{
84 static constexpr unsigned ADDRESS_MAX = 80;
86 uint8_t value;
88 explicit MMAddress(unsigned v)
89 : value(v)
90 {
91 HASSERT(v <= ADDRESS_MAX);
92 }
93};
94
95} // namespace dcc
96
97#endif // _DCC_ADDRESS_HXX_
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
Definition macros.h:138
Strongly typed wrapper representing a long DCC address.
Definition Address.hxx:66
static constexpr unsigned ADDRESS_MAX
Largest valid address.
Definition Address.hxx:68
DccLongAddress(unsigned v)
Constructor.
Definition Address.hxx:72
uint16_t value
Address value.
Definition Address.hxx:70
Strongly typed wrapper representing a short DCC address.
Definition Address.hxx:49
DccShortAddress(unsigned v)
Constructor.
Definition Address.hxx:55
static constexpr unsigned ADDRESS_MAX
Largest valid address.
Definition Address.hxx:51
uint8_t value
Address value.
Definition Address.hxx:53
Strongly typed wrapper representing a marklin-motorola protocol address.
Definition Address.hxx:82
MMAddress(unsigned v)
Constructor.
Definition Address.hxx:88
uint8_t value
Address value.
Definition Address.hxx:86
static constexpr unsigned ADDRESS_MAX
Largest valid address.
Definition Address.hxx:84