LCOV - code coverage report
Current view: top level - source - FlushAndDataSynchronizer.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-02-11 10:03:53 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  * Copyright (C) 2026 Sky UK
       3              :  *
       4              :  * This library is free software; you can redistribute it and/or
       5              :  * modify it under the terms of the GNU Lesser General Public
       6              :  * License as published by the Free Software Foundation;
       7              :  * version 2.1 of the License.
       8              :  *
       9              :  * This library is distributed in the hope that it will be useful,
      10              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12              :  * Lesser General Public License for more details.
      13              :  *
      14              :  * You should have received a copy of the GNU Lesser General Public
      15              :  * License along with this library; if not, write to the Free Software
      16              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      17              :  */
      18              : 
      19              : #ifndef FLUSH_AND_DATA_SYNCHRONIZER_H_
      20              : #define FLUSH_AND_DATA_SYNCHRONIZER_H_
      21              : 
      22              : #include "IFlushAndDataSynchronizer.h"
      23              : #include <condition_variable>
      24              : #include <map>
      25              : #include <mutex>
      26              : #include <vector>
      27              : 
      28              : class FlushAndDataSynchronizer : public IFlushAndDataSynchronizer
      29              : {
      30              :     enum class FlushState
      31              :     {
      32              :         IDLE,
      33              :         FLUSHING,
      34              :         FLUSHED
      35              :     };
      36              : 
      37              :     enum class DataState
      38              :     {
      39              :         NO_DATA,
      40              :         DATA_RECEIVED,
      41              :         DATA_PUSHED
      42              :     };
      43              : 
      44              :     struct SourceState
      45              :     {
      46              :         FlushState flushState;
      47              :         DataState dataState;
      48              :     };
      49              : 
      50              :     struct FlushData
      51              :     {
      52              :         int32_t sourceId;
      53              :         bool resetTime;
      54              :     };
      55              : 
      56              : public:
      57          279 :     FlushAndDataSynchronizer() = default;
      58          279 :     ~FlushAndDataSynchronizer() override = default;
      59              : 
      60              :     void addSource(int32_t sourceId) override;
      61              :     void removeSource(int32_t sourceId) override;
      62              :     void notifyFlushStarted(int32_t sourceId) override;
      63              :     void notifyFlushCompleted(int32_t sourceId) override;
      64              :     void notifyDataReceived(int32_t sourceId) override;
      65              :     void notifyDataPushed(int32_t sourceId) override;
      66              :     void waitIfRequired(int32_t sourceId) override;
      67              :     bool isAnySourceFlushing() const override;
      68              : 
      69              : private:
      70              :     mutable std::mutex m_mutex;
      71              :     std::condition_variable m_cv;
      72              :     std::map<int32_t, SourceState> m_sourceStates;
      73              : };
      74              : 
      75              : #endif // FLUSH_AND_DATA_SYNCHRONIZER_H_
        

Generated by: LCOV version 2.0-1