Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ratan Gupta | a45e086 | 2018-02-21 19:03:13 +0530 | [diff] [blame] | 3 | #include "data_types.hpp" |
| 4 | |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 5 | namespace phosphor |
| 6 | { |
| 7 | namespace dbus |
| 8 | { |
| 9 | namespace monitoring |
| 10 | { |
| 11 | |
| 12 | /** @class Watch |
| 13 | * @brief Watch interface. |
| 14 | * |
| 15 | * The start method is invoked by main() on all watches of any type |
| 16 | * at application startup, to allow watches to perform custom setup |
| 17 | * or initialization. Typical implementations might register dbus |
| 18 | * callbacks or perform queries. |
| 19 | * |
Brad Bishop | ce4fbe1 | 2017-06-06 23:58:09 -0400 | [diff] [blame] | 20 | * The callback method is invoked by main() on all watches of any |
| 21 | * type at application startup, after all watches have performed |
| 22 | * their setup. Typical implementations will forward the call |
| 23 | * to their associated callback. |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 24 | */ |
| 25 | class Watch |
| 26 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 27 | public: |
| 28 | Watch() = default; |
| 29 | Watch(const Watch&) = default; |
| 30 | Watch(Watch&&) = default; |
| 31 | Watch& operator=(const Watch&) = default; |
| 32 | Watch& operator=(Watch&&) = default; |
| 33 | virtual ~Watch() = default; |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 34 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 35 | /** @brief Start the watch. */ |
| 36 | virtual void start() = 0; |
Brad Bishop | ce4fbe1 | 2017-06-06 23:58:09 -0400 | [diff] [blame] | 37 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 38 | /** @brief Invoke the callback associated with the watch. */ |
| 39 | virtual void callback(Context ctx) = 0; |
Marri Devender Rao | 0dabe59 | 2018-04-12 09:18:43 -0500 | [diff] [blame] | 40 | |
| 41 | /** @brief Invoke the callback associated with the watch. */ |
| 42 | virtual void callback(Context ctx, sdbusplus::message::message& msg){}; |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // namespace monitoring |
| 46 | } // namespace dbus |
| 47 | } // namespace phosphor |