mavtables  0.2.1
MAVLink router and firewall.
MAVAddress.hpp
Go to the documentation of this file.
1 // MAVLink router and firewall.
2 // Copyright (C) 2017-2018 Michael R. Shannon <mrshannon.aerospace@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #ifndef MAVADDRESS_HPP_
19 #define MAVADDRESS_HPP_
20 
21 
22 #include <ostream>
23 #include <string>
24 
25 
26 /** A MAVLink address.
27  *
28  * MAVLink addresses consist of a system and component and can be represented
29  * as two ocetets in the form:
30  * ```
31  * system.component
32  * ```
33  * Therefore, a system ID of 16 and a component ID of 8 can be represented as
34  * `16.8`.
35  *
36  * `0.0` is reserved as the broadcast address.
37  */
39 {
40  public:
41  /** Copy constructor.
42  *
43  * \param other MAVLink address to copy from.
44  */
45  MAVAddress(const MAVAddress &other) = default;
46  /** Move constructor.
47  *
48  * \param other MAVLink address to move from.
49  */
50  MAVAddress(MAVAddress &&other) = default;
51  MAVAddress(unsigned int address);
52  MAVAddress(unsigned int system, unsigned int component);
53  MAVAddress(std::string address);
54  unsigned int address() const;
55  unsigned int system() const;
56  unsigned int component() const;
57  /** Assignment operator.
58  *
59  * \param other MAVLink address to copy from.
60  */
61  MAVAddress &operator=(const MAVAddress &other) = default;
62  /** Assignment operator (by move semantics).
63  *
64  * \param other MAVLink address to move from.
65  */
66  MAVAddress &operator=(MAVAddress &&other) = default;
67 
68  private:
69  unsigned int address_;
70  void construct_(unsigned int system, unsigned int component);
71 };
72 
73 
74 bool operator==(const MAVAddress &lhs, const MAVAddress &rhs);
75 bool operator!=(const MAVAddress &lhs, const MAVAddress &rhs);
76 bool operator<(const MAVAddress &lhs, const MAVAddress &rhs);
77 bool operator>(const MAVAddress &lhs, const MAVAddress &rhs);
78 bool operator<=(const MAVAddress &lhs, const MAVAddress &rhs);
79 bool operator>=(const MAVAddress &lhs, const MAVAddress &rhs);
80 std::ostream &operator<<(std::ostream &os, const MAVAddress &mavaddress);
81 
82 
83 #endif // MAVADDRESS_HPP_
unsigned int component() const
Definition: MAVAddress.cpp:171
unsigned int system() const
Definition: MAVAddress.cpp:161
std::ostream & operator<<(std::ostream &os, const Action &action)
Definition: Action.cpp:188
unsigned int address() const
Definition: MAVAddress.cpp:151
MAVAddress(const MAVAddress &other)=default
bool operator==(const Action &lhs, const Action &rhs)
Definition: Action.cpp:154
bool operator<=(const IPAddress &lhs, const IPAddress &rhs)
Definition: IPAddress.cpp:297
bool operator!=(const Action &lhs, const Action &rhs)
Definition: Action.cpp:168
MAVAddress & operator=(const MAVAddress &other)=default
bool operator>=(const IPAddress &lhs, const IPAddress &rhs)
Definition: IPAddress.cpp:313
bool operator>(const IPAddress &lhs, const IPAddress &rhs)
Definition: IPAddress.cpp:280
bool operator<(const IPAddress &lhs, const IPAddress &rhs)
Definition: IPAddress.cpp:263