blob: a44480c119d80f046701fd4b6879a11dfcfc7a66 [file] [log] [blame]
Brad Bishop4b916f12017-05-23 18:06:38 -04001#pragma once
2
Ratan Guptaa45e0862018-02-21 19:03:13 +05303#include "data_types.hpp"
4
Brad Bishop4b916f12017-05-23 18:06:38 -04005namespace phosphor
6{
7namespace dbus
8{
9namespace 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 Bishopce4fbe12017-06-06 23:58:09 -040020 * 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 Bishop4b916f12017-05-23 18:06:38 -040024 */
25class Watch
26{
Brad Bishopd1eac882018-03-29 10:34:05 -040027 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 Bishop4b916f12017-05-23 18:06:38 -040034
Brad Bishopd1eac882018-03-29 10:34:05 -040035 /** @brief Start the watch. */
36 virtual void start() = 0;
Brad Bishopce4fbe12017-06-06 23:58:09 -040037
Brad Bishopd1eac882018-03-29 10:34:05 -040038 /** @brief Invoke the callback associated with the watch. */
39 virtual void callback(Context ctx) = 0;
Marri Devender Rao0dabe592018-04-12 09:18:43 -050040
41 /** @brief Invoke the callback associated with the watch. */
42 virtual void callback(Context ctx, sdbusplus::message::message& msg){};
Brad Bishop4b916f12017-05-23 18:06:38 -040043};
44
45} // namespace monitoring
46} // namespace dbus
47} // namespace phosphor