GCC Code Coverage Report


Directory: Os/Posix/
File: RawTime.hpp
Date: 2026-09-03 21:16:08
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Posix/RawTime.hpp
3 // \brief Posix definitions for Os::RawTime
4 // ======================================================================
5 #ifndef OS_POSIX_RAWTIME_HPP
6 #define OS_POSIX_RAWTIME_HPP
7
8 #include <Os/RawTime.hpp>
9 #include <ctime>
10
11 namespace Os {
12 namespace Posix {
13 namespace RawTime {
14
15 struct PosixRawTimeHandle : public RawTimeHandle {
16 timespec m_timespec = {0, 0};
17 };
18
19 //! \brief Posix implementation of Os::RawTime
20 //!
21 //! Posix implementation of `RawTimeInterface` for use as a delegate class handling error-only file operations.
22 //!
23 class PosixRawTime : public RawTimeInterface {
24 public:
25 //! \brief constructor
26 2181 PosixRawTime() = default;
27
28 //! \brief destructor
29 4362 ~PosixRawTime() override = default;
30
31 //! \brief return the underlying RawTime handle (implementation specific)
32 //! \return internal RawTime handle representation
33 RawTimeHandle* getHandle() override;
34
35 // ------------------------------------------------------------
36 // Implementation-specific RawTime overrides
37 // ------------------------------------------------------------
38 //! \brief Get the current time.
39 //!
40 //! This function retrieves the current time and stores it in the RawTime object.
41 //! Each implementation should define its RawTimeHandle type for storing the time.
42 //!
43 //! \return Status indicating the result of the operation.
44 Status now() override;
45
46 //! \brief Calculate the time interval between this and another raw time.
47 //!
48 //! This function calculates the time interval between the current raw time and another
49 //! specified raw time. The result is stored in the provided (output) interval object.
50 //!
51 //! \param other The other RawTimeHandle to compare against.
52 //! \param interval Output parameter to store the calculated time interval.
53 //! \return Status indicating the result of the operation.
54 Status getTimeInterval(const Os::RawTime& other, Fw::TimeInterval& interval) const override;
55
56 //! \brief Serialize the contents of the RawTimeInterface object into a buffer.
57 //!
58 //! This function serializes the contents of the RawTimeInterface object into the provided
59 //! buffer.
60 //!
61 //! \note The serialization must fit within `FW_RAW_TIME_SERIALIZATION_MAX_SIZE` bytes. This value is
62 //! defined in FpConfig.h. For example, Posix systems use a pair of U32 (sec, nanosec) and can therefore
63 //! serialize in 8 bytes. Should an OSAL implementation require more than this, the project must increase
64 //! that value in its config/ folder.
65 //!
66 //! \param buffer The buffer to serialize the contents into.
67 //! \param mode Endianness to use when serializing to buffer.
68 //! \return Fw::SerializeStatus indicating the result of the serialization.
69 Fw::SerializeStatus serializeTo(Fw::SerialBufferBase& buffer,
70 Fw::Endianness mode = Fw::Endianness::BIG) const override;
71
72 //! \brief Deserialize the contents of the RawTimeInterface object from a buffer.
73 //!
74 //! This function deserializes the contents of the RawTimeInterface object from the provided
75 //! buffer.
76 //!
77 //! \note The serialization must fit within `FW_RAW_TIME_SERIALIZATION_MAX_SIZE` bytes. This value is
78 //! defined in FpConfig.h. For example, Posix systems use a pair of U32 (sec, nanosec) and can therefore
79 //! serialize in 8 bytes. Should an OSAL implementation require more than this, the project must increase
80 //! that value in its config/ folder.
81 //!
82 //! \param buffer The buffer to deserialize the contents from.
83 //! \param mode Endianness to use when deserializing from the buffer.
84 //! \return Fw::SerializeStatus indicating the result of the deserialization.
85 Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase& buffer,
86 Fw::Endianness mode = Fw::Endianness::BIG) override;
87
88 private:
89 //! Handle for PosixRawTime
90 PosixRawTimeHandle m_handle;
91 };
92
93 } // namespace RawTime
94 } // namespace Posix
95 } // namespace Os
96 #endif // OS_POSIX_RAWTIME_HPP
97