GCC Code Coverage Report


Directory: ./
File: Svc/FrameAccumulator/FrameDetector.hpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ======================================================================
2 // \title FrameDetector.hpp
3 // \author mstarch
4 // \brief hpp interface specification for FrameDetector
5 // ======================================================================
6 #ifndef SVC_FPRIME_FRAME_DETECTOR_HPP
7 #define SVC_FPRIME_FRAME_DETECTOR_HPP
8 #include <Fw/FPrimeBasicTypes.hpp>
9 #include <Utils/Types/CircularBuffer.hpp>
10
11 namespace Svc {
12
13 //! \brief interface class used to codify what must be supported to allow frame detection
14 class FrameDetector {
15 public:
16 //! \brief status returned from the detection step
17 enum Status {
18 FRAME_DETECTED, //!< Frame detected. Extract frame and return with new data.
19 NO_FRAME_DETECTED, //!< No frame detected. Discard data and return with new data.
20 MORE_DATA_NEEDED //!< More data is needed to detect a frame. Keep current data and return with more.
21 };
22
23 //! \brief virtual destructor
24 2 virtual ~FrameDetector() = default;
25
26 //! \brief detect if a frame is available within the circular buffer
27 //!
28 //! Function implemented by sub classes used to determine if a frame is available at the current position of the
29 //! circular buffer. Implementors should detect if a frame is available, set size_out, and return a status while
30 //! following these expectations:
31 //!
32 //! 1. FRAME_DETECTED status implies a frame is available at the current offset of the circular buffer.
33 //! size_out must be set to the size of the frame from that location.
34 //!
35 //! 2. NO_FRAME_DETECTED status implies no frame is possible at the current offset of the circular buffer.
36 //! e.g. no start word is found at the current offset. size_out is ignored.
37 //!
38 //! 3. MORE_DATA_NEEDED status implies that a frame might be possible but more data is needed before a
39 //! determination is possible. size_out must be set to the total amount of data needed.
40 //!
41 //! For example, if a frame start word is 4 bytes, and 3 bytes are available in the circular buffer then the
42 //! return status would be NO_FRAME_DETECTED and size_out must be set to 4 to ensure that at least the start
43 //! word is available.
44 //!
45 //! \param data: circular buffer with read-only access
46 //! \param size_out: set as output to caller indicating size when appropriate
47 //! \return status of the detection to be paired with size_out
48 virtual Status detect(const Types::CircularBuffer& data, FwSizeType& size_out) const = 0;
49 };
50
51 } // namespace Svc
52
53 #endif // SVC_FPRIME_FRAME_DETECTOR_HPP
54