xref: /openbmc/phosphor-dbus-monitor/src/watch.hpp (revision eab4f8c0a047e1aaedf74d6144d83132d1b003de)
14b916f13SBrad Bishop #pragma once
24b916f13SBrad Bishop 
3a45e086dSRatan Gupta #include "data_types.hpp"
4a45e086dSRatan Gupta 
54b916f13SBrad Bishop namespace phosphor
64b916f13SBrad Bishop {
74b916f13SBrad Bishop namespace dbus
84b916f13SBrad Bishop {
94b916f13SBrad Bishop namespace monitoring
104b916f13SBrad Bishop {
114b916f13SBrad Bishop 
124b916f13SBrad Bishop /** @class Watch
134b916f13SBrad Bishop  *  @brief Watch interface.
144b916f13SBrad Bishop  *
154b916f13SBrad Bishop  *  The start method is invoked by main() on all watches of any type
164b916f13SBrad Bishop  *  at application startup, to allow watches to perform custom setup
174b916f13SBrad Bishop  *  or initialization.  Typical implementations might register dbus
184b916f13SBrad Bishop  *  callbacks or perform queries.
194b916f13SBrad Bishop  *
20ce4fbe11SBrad Bishop  *  The callback method is invoked by main() on all watches of any
21ce4fbe11SBrad Bishop  *  type at application startup, after all watches have performed
22ce4fbe11SBrad Bishop  *  their setup.  Typical implementations will forward the call
23ce4fbe11SBrad Bishop  *  to their associated callback.
244b916f13SBrad Bishop  */
254b916f13SBrad Bishop class Watch
264b916f13SBrad Bishop {
274b916f13SBrad Bishop   public:
284b916f13SBrad Bishop     Watch() = default;
294b916f13SBrad Bishop     Watch(const Watch&) = default;
304b916f13SBrad Bishop     Watch(Watch&&) = default;
314b916f13SBrad Bishop     Watch& operator=(const Watch&) = default;
324b916f13SBrad Bishop     Watch& operator=(Watch&&) = default;
334b916f13SBrad Bishop     virtual ~Watch() = default;
344b916f13SBrad Bishop 
354b916f13SBrad Bishop     /** @brief Start the watch. */
364b916f13SBrad Bishop     virtual void start() = 0;
37ce4fbe11SBrad Bishop 
38ce4fbe11SBrad Bishop     /** @brief Invoke the callback associated with the watch. */
39a45e086dSRatan Gupta     virtual void callback(Context ctx) = 0;
400dabe592SMarri Devender Rao 
410dabe592SMarri Devender Rao     /** @brief Invoke the callback associated with the watch. */
callback(Context,sdbusplus::message_t &)42*eab4f8c0SPatrick Williams     virtual void callback(Context /* ctx */, sdbusplus::message_t& /* msg */) {
43*eab4f8c0SPatrick Williams     };
444b916f13SBrad Bishop };
454b916f13SBrad Bishop 
464b916f13SBrad Bishop } // namespace monitoring
474b916f13SBrad Bishop } // namespace dbus
484b916f13SBrad Bishop } // namespace phosphor
49