1 #pragma once 2 3 #include "data_types.hpp" 4 5 namespace phosphor 6 { 7 namespace dbus 8 { 9 namespace monitoring 10 { 11 12 /** @class Callback 13 * @brief Callback interface. 14 * 15 * Callbacks of any type can be run. 16 */ 17 class Callback 18 { 19 public: 20 Callback() = default; 21 Callback(const Callback&) = delete; 22 Callback(Callback&&) = default; 23 Callback& operator=(const Callback&) = delete; 24 Callback& operator=(Callback&&) = default; 25 virtual ~Callback() = default; 26 27 /** @brief Run the callback. */ 28 virtual void operator()() = 0; 29 }; 30 31 /** @class IndexedCallback 32 * @brief Callback with an index. 33 */ 34 class IndexedCallback : public Callback 35 { 36 public: 37 IndexedCallback() = delete; 38 IndexedCallback(const IndexedCallback&) = delete; 39 IndexedCallback(IndexedCallback&&) = default; 40 IndexedCallback& operator=(const IndexedCallback&) = delete; 41 IndexedCallback& operator=(IndexedCallback&&) = default; 42 virtual ~IndexedCallback() = default; 43 explicit IndexedCallback(const PropertyIndex& callbackIndex) 44 : Callback(), index(callbackIndex) {} 45 46 /** @brief Run the callback. */ 47 virtual void operator()() override = 0; 48 49 protected: 50 51 /** @brief Property names and their associated storage. */ 52 const PropertyIndex& index; 53 }; 54 55 } // namespace monitoring 56 } // namespace dbus 57 } // namespace phosphor 58