-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecklist_base.h
127 lines (108 loc) · 3.45 KB
/
checklist_base.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
#include <string>
#include <functional>
#include <cmath>
#include <vector>
namespace mavsdk {
/**
* @brief Base class for every checklist.
*/
class ChecklistBase {
public:
/**
* @brief Default Constructor.
*/
ChecklistBase() = default;
/**
* @brief Default Destructor.
*/
virtual ~ChecklistBase() = default;
/**
* @brief Type representing a checklist item.
*/
struct ChecklistItem {
uint16_t index{uint16_t(NAN)};
std::string name{};
std::string description{};
};
/**
* @brief Equal operator to compare two `ChecklistBase::ChecklistItem` objects.
*
* @return `true` if items are equal.
*/
friend bool
operator==(const ChecklistBase::ChecklistItem& lhs, const ChecklistBase::ChecklistItem& rhs);
/**
* @brief Stream operator to print information about a `ChecklistBase::ChecklistItem`.
*
* @return A reference to the stream.
*/
friend std::ostream&
operator<<(std::ostream& str, ChecklistBase::ChecklistItem const& checklist_item);
/**
* @brief Checklist
*/
struct Checklist {
std::vector<ChecklistItem> items{}; /**< @brief The checklist items */
};
/**
* @brief Equal operator to compare two `ChecklistBase::Checklist` objects.
*
* @return `true` if items are equal.
*/
friend bool
operator==(const ChecklistBase::Checklist& lhs, const ChecklistBase::Checklist& rhs);
/**
* @brief Stream operator to print information about a `ChecklistBase::Checklist`.
*
* @return A reference to the stream.
*/
friend std::ostream&
operator<<(std::ostream& str, ChecklistBase::Checklist const& list);
/**
* @brief Possible ACKs returned for action requests.
*/
enum class Ack { Accepted, Error, NoSpace, InvalidSequence, Cancelled, Unknown };
/**
* @brief Stream operator to print information about a `ChecklistBase::Ack`.
*
* @return A reference to the stream.
*/
friend std::ostream& operator<<(std::ostream& str, ChecklistBase::Ack const& ack);
/**
* @brief Possible results returned for action requests.
*/
enum class Result {
Unknown, /**< @brief Unknown result. */
Success, /**< @brief Request succeeded. */
ConnectionError, /**< @brief Connection error. */
ProtocolError, /**< @brief Protocol error. */
Busy, /**< @brief Vehicle is busy. */
Timeout, /**< @brief Request timed out. */
InvalidArgument, /**< @brief Invalid argument. */
TransferCancelled, /**< @brief Checklist transfer has been cancelled. */
};
/**
* @brief Stream operator to print information about a `ChecklistBase::Result`.
*
* @return A reference to the stream.
*/
friend std::ostream& operator<<(std::ostream& str, ChecklistBase::Result const& result);
/**
* @brief Callback type for asynchronous Checklist ACK calls.
*/
using ResultAckCallback = std::function<void(Result, Ack)>;
/**
* @brief Callback type for download_checklist_async.
*/
using DownloadChecklistCallback = std::function<void(Result, Checklist)>;
/**
* @brief Copy constructor (object is not copyable).
*/
ChecklistBase(const ChecklistBase&) = delete;
/**
* @brief Assign operator (object is not copyable).
*/
const ChecklistBase& operator=(const ChecklistBase&) = delete;
};
} // namespace mavsdk