blob: 28e7c76765957d60e89356bf3d21da56ac4338d5 [file] [log] [blame]
Ben Tynerb481d902020-03-05 10:24:23 -06001#pragma once
2
3#include <libpdbg.h>
4
5namespace attn
6{
7
8/** @brief attention handler configuration flags */
9inline constexpr uint32_t enableBreakpoints = 1;
10
11/**
12 * @brief These objects contain information about an active attention.
13 *
14 * An Attention object is created for each active attention. These objects
15 * carry with them various configuration and status information as well
16 * the attention handler function to call for handling the attention. Each
17 * Attention object also carries a priority value. This priority is used
18 * to determine which attention event(s) to handle when there are more than
19 * one active event.
20 */
21class Attention
22{
23 public:
24 /** @brief types of attentions to be handled (by priority low to high) */
25 enum AttentionType
26 {
27 Special = 0,
28 Checkstop = 1,
29 Vital = 2
30 };
31
32 /** @brief Default constructor. */
33 Attention() = delete;
34
35 /** @brief Main constructors */
36 Attention(AttentionType i_type, int (*i_handler)(Attention*),
37 pdbg_target* i_target, bool i_breakpoints);
38
39 /** @brief Destructor */
40 ~Attention() = default;
41
42 /** @brief Get attention priority */
43 int getPriority() const;
44
45 /** @brief Get configuration flags */
46 uint32_t getFlags() const;
47
48 /** @brief Set configuration flags */
49 void setFlags(uint32_t i_flags);
50
51 /* @brief Call attention handler function */
52 int handle();
53
54 /** @brief Copy constructor. */
55 Attention(const Attention&) = default;
56
57 /** @brief Assignment operator. */
58 Attention& operator=(const Attention&) = default;
59
60 /** @brief less than operator */
61 bool operator<(const Attention& right) const;
62
63 private:
64 AttentionType iv_type; // attention type
65 int (*iv_handler)(Attention*); // handler function
66 pdbg_target* iv_target; // handler function target
67 uint32_t iv_flags = 0; // configuration flags
68};
69
70} // namespace attn