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