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 | { |
| 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 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 | |
| 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 Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 68 | Config* iv_config; // configuration flags |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } // namespace attn |