Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <libpdbg.h> |
| 4 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 5 | #include <attn/attn_config.hpp> |
| 6 | |
| 7 | #include <bitset> |
| 8 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 9 | namespace attn |
| 10 | { |
| 11 | |
| 12 | /** @brief attention handler configuration flags */ |
| 13 | inline 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 | */ |
| 25 | class Attention |
| 26 | { |
| 27 | public: |
| 28 | /** @brief types of attentions to be handled (by priority low to high) */ |
| 29 | enum AttentionType |
| 30 | { |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame] | 31 | Special = 0, |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 32 | Checkstop = 1, |
Patrick Williams | 27dd636 | 2023-05-10 07:51:20 -0500 | [diff] [blame] | 33 | Vital = 2 |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | /** @brief Default constructor. */ |
| 37 | Attention() = delete; |
| 38 | |
| 39 | /** @brief Main constructors */ |
| 40 | Attention(AttentionType i_type, int (*i_handler)(Attention*), |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 41 | pdbg_target* i_target, Config* i_config); |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 42 | |
| 43 | /** @brief Destructor */ |
| 44 | ~Attention() = default; |
| 45 | |
| 46 | /** @brief Get attention priority */ |
| 47 | int getPriority() const; |
| 48 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 49 | /* @brief Get config object */ |
| 50 | Config* getConfig() const; |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 51 | |
| 52 | /* @brief Call attention handler function */ |
| 53 | int handle(); |
| 54 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 55 | /* @brief Get attention handler target */ |
| 56 | pdbg_target* getTarget() const; |
| 57 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 58 | /** @brief Copy constructor. */ |
| 59 | Attention(const Attention&) = default; |
| 60 | |
| 61 | /** @brief Assignment operator. */ |
| 62 | Attention& operator=(const Attention&) = default; |
| 63 | |
| 64 | /** @brief less than operator */ |
| 65 | bool operator<(const Attention& right) const; |
| 66 | |
| 67 | private: |
| 68 | AttentionType iv_type; // attention type |
| 69 | int (*iv_handler)(Attention*); // handler function |
| 70 | pdbg_target* iv_target; // handler function target |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 71 | Config* iv_config; // configuration flags |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace attn |