F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DelegateRawTime.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/DelegateRawTime.hpp
3 // \brief Define the Os::DelegateRawTime class
4 // ======================================================================
5 #ifndef OS_DELEGATERAWTIME_HPP_
6 #define OS_DELEGATERAWTIME_HPP_
7 
9 
10 namespace Os {
11 
12 class DelegateRawTime final : public RawTimeInterface {
13  public:
14  DelegateRawTime();
15 
18  explicit DelegateRawTime(RawTimeSource source);
19 
20  ~DelegateRawTime() final;
21 
23  DelegateRawTime(const DelegateRawTime& other);
24 
27 
30  RawTimeHandle* getHandle() override;
31 
32  // ------------------------------------------------------------
33  // Implementation-specific RawTime member functions
34  // ------------------------------------------------------------
35 
42  Status now() override;
43 
52  Status getTimeInterval(const Os::RawTime& other, Fw::TimeInterval& interval) const override;
53 
68  Fw::Endianness mode = Fw::Endianness::BIG) const override;
69 
84  Fw::Endianness mode = Fw::Endianness::BIG) override;
85 
98  Status getDiffUsec(const RawTime& other, U32& result) const override;
99 
100  // ------------------------------------------------------------
101  // Common functions built on top of OS-specific functions
102  // ------------------------------------------------------------
103 
105  bool operator==(const RawTime& other) const override;
106 
109  RawTimeSource getSource() const;
110 
111  private:
112  // This section is used to store the implementation-defined RawTime handle. To Os::RawTime and fprime, this type is
113  // opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store the handle in
114  // the byte-array here and set `m_handle_storage` to that address for storage.
115  //
116  alignas(FW_HANDLE_ALIGNMENT) RawTimeHandleStorage m_handle_storage;
117  RawTimeInterface& m_delegate;
118  RawTimeSource m_source = RAWTIME_DEFAULT;
119 };
120 } // namespace Os
121 
122 #endif // OS_DELEGATERAWTIME_HPP_
RawTimeSource
Timer source selection for RawTime.
Platform's default timer (maintains current behavior)
RawTimeHandle * getHandle() override
return the underlying RawTime handle (implementation specific)
RawTimeSource getSource() const
Get the timer source used by this RawTime instance.
U8 RawTimeHandleStorage[FW_RAW_TIME_HANDLE_MAX_SIZE]
Definition: Os.hpp:21
Status now() override
Get the current time.
SerializeStatus
forward declaration for string
Status getTimeInterval(const Os::RawTime &other, Fw::TimeInterval &interval) const override
Calculate the time interval between this and another raw time.
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
Deserialize the contents of the RawTimeInterface object from a buffer.
bool operator==(const RawTime &other) const override
Compare whether two RawTime objects are the same (i.e. refer to the same microsecond) ...
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
Serialize the contents of the RawTimeInterface object into a buffer.
Status getDiffUsec(const RawTime &other, U32 &result) const override
Calculate the difference in microseconds between two RawTime objects.
~DelegateRawTime() final
Destructor.
DelegateRawTime()
Default constructor.
Endianness
DelegateRawTime & operator=(const DelegateRawTime &other)
assignment operator that copies the internal representation
Big endian serialization.