F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Os::RawTimeCommon< T > Class Template Reference

Os::RawTime wrapper around the implementation T selected at compile time. More...

#include <Os/RawTime.hpp>

Inheritance diagram for Os::RawTimeCommon< T >:
Os::RawTimeUserInterface Fw::Serializable

Public Member Functions

 RawTimeCommon ()=default
 Default constructor. More...
 
 RawTimeCommon (RawTimeSource source)
 Constructor with timer source selection. More...
 
 ~RawTimeCommon ()=default
 Destructor. More...
 
 RawTimeCommon (const RawTimeCommon &other)=default
 copy constructor that copies the internal representation More...
 
RawTimeCommon & operator= (const RawTimeCommon &other)=default
 assignment operator that copies the internal representation More...
 
RawTimeHandle * getHandle ()
 return the underlying RawTime handle (implementation specific) More...
 
Status now ()
 Get the current time. More...
 
Status getTimeInterval (const RawTimeCommon &other, Fw::TimeInterval &interval) const
 Calculate the time interval between this and another raw time. More...
 
Fw::SerializeStatus serializeTo (Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
 Serialize the contents of the RawTime object into a buffer. More...
 
Fw::SerializeStatus deserializeFrom (Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
 Deserialize the contents of the RawTime object from a buffer. More...
 
Status getDiffUsec (const RawTimeCommon &other, U32 &result) const
 Calculate the difference in microseconds between two RawTime objects. More...
 
bool operator== (const RawTimeCommon &other) const
 Compare whether two RawTime objects are the same (i.e. refer to the same microsecond) More...
 
RawTimeSource getSource () const
 Get the timer source used by this RawTime instance. More...
 
- Public Member Functions inherited from Fw::Serializable
 DEPRECATED (SerializeStatus serialize(SerialBufferBase &buffer) const, "Use serializeTo(SerialBufferBase& buffer) instead")
 
 DEPRECATED (SerializeStatus deserialize(SerialBufferBase &buffer), "Use deserializeFrom(SerialBufferBase& buffer) instead")
 

Static Public Attributes

static const FwSizeType SERIALIZED_SIZE
 
- Static Public Attributes inherited from Os::RawTimeUserInterface
static const FwSizeType SERIALIZED_SIZE = FW_RAW_TIME_SERIALIZATION_MAX_SIZE
 

Additional Inherited Members

- Public Types inherited from Os::RawTimeUserInterface
enum  Status {
  OP_OK, OP_OVERFLOW, INVALID_PARAMS, NOT_SUPPORTED,
  OTHER_ERROR
}
 
- Public Types inherited from Fw::Serializable
using SizeType = FwSizeType
 
- Protected Member Functions inherited from Fw::Serializable
 Serializable ()
 Default constructor. More...
 
virtual ~Serializable ()
 Virtual destructor. More...
 

Detailed Description

template<typename T>
class Os::RawTimeCommon< T >

Os::RawTime wrapper around the implementation T selected at compile time.

Holds the implementation by value and forwards every operation to it. Os::RawTime is this class instantiated on the implementation selected in config/RawTimeSelection.hpp. T must be copyable and constructible from a RawTimeSource.

Definition at line 23 of file RawTime.hpp.

Constructor & Destructor Documentation

◆ RawTimeCommon() [1/3]

template<typename T>
Os::RawTimeCommon< T >::RawTimeCommon ( )
default

Default constructor.

◆ RawTimeCommon() [2/3]

template<typename T >
Os::RawTimeCommon< T >::RawTimeCommon ( RawTimeSource  source)
explicit

Constructor with timer source selection.

Parameters
sourceTimer source to use

Definition at line 128 of file RawTime.hpp.

◆ ~RawTimeCommon()

template<typename T>
Os::RawTimeCommon< T >::~RawTimeCommon ( )
default

Destructor.

◆ RawTimeCommon() [3/3]

template<typename T>
Os::RawTimeCommon< T >::RawTimeCommon ( const RawTimeCommon< T > &  other)
default

copy constructor that copies the internal representation

Member Function Documentation

◆ deserializeFrom()

template<typename T >
Fw::SerializeStatus Os::RawTimeCommon< T >::deserializeFrom ( Fw::SerialBufferBase &  buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
)
overridevirtual

Deserialize the contents of the RawTime object from a buffer.

Parameters
bufferThe buffer to deserialize the contents from.
modeEndianness to use when deserializing from the buffer.
Returns
Fw::SerializeStatus indicating the result of the deserialization.

Implements Fw::Serializable.

Definition at line 152 of file RawTime.hpp.

◆ getDiffUsec()

template<typename T >
RawTimeCommon< T >::Status Os::RawTimeCommon< T >::getDiffUsec ( const RawTimeCommon< T > &  other,
U32 &  result 
) const

Calculate the difference in microseconds between two RawTime objects.

Warning
This function will return Status::OP_OVERFLOW if the time difference is too large to fit in a U32.
This means the largest time difference that can be measured is 2^32 microseconds (about 71 minutes).
Users should prefer getTimeInterval() for larger intervals.
Parameters
otherThe other RawTime object to compare against.
resultA reference to a U32 variable where the result will be stored.
Returns
Status indicating the result of the operation.

Definition at line 157 of file RawTime.hpp.

◆ getHandle()

template<typename T >
RawTimeHandle * Os::RawTimeCommon< T >::getHandle ( )

return the underlying RawTime handle (implementation specific)

Returns
internal RawTime handle representation

Definition at line 131 of file RawTime.hpp.

◆ getSource()

template<typename T >
RawTimeSource Os::RawTimeCommon< T >::getSource ( ) const

Get the timer source used by this RawTime instance.

Returns
The RawTimeSource value configured for this instance

Definition at line 169 of file RawTime.hpp.

◆ getTimeInterval()

template<typename T >
RawTimeCommon< T >::Status Os::RawTimeCommon< T >::getTimeInterval ( const RawTimeCommon< T > &  other,
Fw::TimeInterval &  interval 
) const

Calculate the time interval between this and another raw time.

This function calculates the time interval between the current raw time and another specified raw time. The result is stored in the provided (output) interval object.

Parameters
otherThe other RawTime to compare against.
intervalOutput parameter to store the calculated time interval.
Returns
Status indicating the result of the operation.

Definition at line 141 of file RawTime.hpp.

◆ now()

template<typename T >
RawTimeCommon< T >::Status Os::RawTimeCommon< T >::now ( )

Get the current time.

This function retrieves the current time and stores it in the RawTime object.

Returns
Status indicating the result of the operation.

Definition at line 136 of file RawTime.hpp.

◆ operator=()

template<typename T>
RawTimeCommon& Os::RawTimeCommon< T >::operator= ( const RawTimeCommon< T > &  other)
default

assignment operator that copies the internal representation

◆ operator==()

template<typename T >
bool Os::RawTimeCommon< T >::operator== ( const RawTimeCommon< T > &  other) const

Compare whether two RawTime objects are the same (i.e. refer to the same microsecond)

Definition at line 162 of file RawTime.hpp.

◆ serializeTo()

template<typename T >
Fw::SerializeStatus Os::RawTimeCommon< T >::serializeTo ( Fw::SerialBufferBase &  buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
) const
overridevirtual

Serialize the contents of the RawTime object into a buffer.

Note
The serialization must fit within FW_RAW_TIME_SERIALIZATION_MAX_SIZE bytes. This value is defined in FpConfig.h. For example, Posix systems use a pair of U32 (sec, nanosec) and can therefore serialize in 8 bytes. Should an OSAL implementation require more than this, the project must increase that value in its config/ folder.
Parameters
bufferThe buffer to serialize the contents into.
modeEndianness to use when serializing to buffer.
Returns
Fw::SerializeStatus indicating the result of the serialization.

Implements Fw::Serializable.

Definition at line 147 of file RawTime.hpp.

Member Data Documentation

◆ SERIALIZED_SIZE

template<typename T>
const FwSizeType Os::RawTimeUserInterface::SERIALIZED_SIZE
static

Definition at line 24 of file RawTimeUserInterface.hpp.


The documentation for this class was generated from the following file: