Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 1 | #include <attn/attention.hpp> |
| 2 | #include <attn/attn_config.hpp> |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 3 | |
| 4 | namespace attn |
| 5 | { |
| 6 | |
| 7 | /** @brief Main constructor. */ |
| 8 | Attention::Attention(AttentionType i_type, int (*i_handler)(Attention*), |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 9 | pdbg_target* i_target, Config* i_config) : |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 10 | iv_type(i_type), |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 11 | iv_handler(i_handler), iv_target(i_target), iv_config(i_config) |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 12 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 13 | {} |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 14 | |
| 15 | /** @brief Get attention priority */ |
| 16 | int Attention::getPriority() const |
| 17 | { |
| 18 | return iv_type; |
| 19 | } |
| 20 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 21 | /* @brief Get config object */ |
| 22 | Config* Attention::getConfig() const |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 23 | { |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 24 | return iv_config; |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | /* @brief Call attention handler function */ |
| 28 | int Attention::handle() |
| 29 | { |
| 30 | return iv_handler(this); |
| 31 | } |
| 32 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 33 | /* @brief Get attention handler target */ |
| 34 | pdbg_target* Attention::getTarget() const |
| 35 | { |
| 36 | return iv_target; |
| 37 | } |
| 38 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 39 | /** @brief less than operator, for heap creation */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 40 | bool Attention::operator<(const Attention& right) const |
| 41 | { |
| 42 | return (getPriority() < right.getPriority()); |
| 43 | } |
| 44 | |
| 45 | } // namespace attn |