LCOV - code coverage report
Current view: top level - core/utility - Observable.hpp (source / functions) Coverage Total Hit
Test: coverage-src.info Lines: 100.0 % 7 7
Test Date: 2025-05-27 23:26:07 Functions: 13.0 % 23 3

            Line data    Source code
       1              : #ifndef __OBSERVABLE_HPP__
       2              : #define __OBSERVABLE_HPP__
       3              : 
       4              : #include <list>
       5              : #include <memory>
       6              : #include <functional>
       7              : 
       8              : namespace Soldank
       9              : {
      10              : template<typename... OnNotifyArgs>
      11              : class Observable
      12              : {
      13              : public:
      14            1 :     void AddObserver(const std::function<void(OnNotifyArgs...)>& observer_callback)
      15              :     {
      16            1 :         observers_.push_back(std::move(observer_callback));
      17            1 :     }
      18              : 
      19            2 :     void Notify(OnNotifyArgs... on_notify_args) const
      20              :     {
      21            3 :         for (const auto& observer_callback : observers_) {
      22            1 :             observer_callback(on_notify_args...);
      23              :         }
      24            2 :     }
      25              : 
      26              : private:
      27              :     std::list<std::function<void(OnNotifyArgs...)>> observers_;
      28              : };
      29              : 
      30              : } // namespace Soldank
      31              : 
      32              : #endif
        

Generated by: LCOV version 2.0-1