F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Fw::TimeInterval Class Reference

#include <Fw/Time/TimeInterval.hpp>

Inheritance diagram for Fw::TimeInterval:
Fw::Serializable

Public Types

enum  { SERIALIZED_SIZE = sizeof(U32) * 2 }
 
enum  Comparison { LT = -1, EQ = 0, GT = 1, INCOMPARABLE = 2 }
 The type of a comparison result. More...
 
- Public Types inherited from Fw::Serializable
using SizeType = FwSizeType
 

Public Member Functions

 TimeInterval ()=default
 
 ~TimeInterval ()=default
 
 TimeInterval (const TimeInterval &other)
 
 TimeInterval (U32 seconds, U32 useconds)
 
 TimeInterval (const Time &start, const Time &end)
 
void set (U32 seconds, U32 useconds)
 
U32 getSeconds () const
 
U32 getUSeconds () const
 
SerializeStatus serializeTo (SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
 Serialize the contents of this object to a buffer. More...
 
SerializeStatus deserializeFrom (SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
 Deserialize the contents of this object from a buffer. More...
 
void add (U32 seconds, U32 mseconds)
 
bool operator== (const TimeInterval &other) const
 
bool operator!= (const TimeInterval &other) const
 
bool operator> (const TimeInterval &other) const
 
bool operator< (const TimeInterval &other) const
 
bool operator>= (const TimeInterval &other) const
 
bool operator<= (const TimeInterval &other) const
 
TimeIntervaloperator= (const TimeInterval &other)
 
- Public Member Functions inherited from Fw::Serializable
Serializableoperator= (const Serializable &src)=default
 TODO: this operator should be deleted, this must be done after RawTime is modified though. More...
 
 DEPRECATED (SerializeStatus serialize(SerialBufferBase &buffer) const, "Use serializeTo(SerialBufferBase& buffer) instead")
 
 DEPRECATED (SerializeStatus deserialize(SerialBufferBase &buffer), "Use deserializeFrom(SerialBufferBase& buffer) instead")
 

Static Public Member Functions

static Comparison compare (const TimeInterval &time1, const TimeInterval &time2)
 
static TimeInterval add (const TimeInterval &a, const TimeInterval &b)
 
static TimeInterval sub (const TimeInterval &t1, const TimeInterval &t2)
 

Additional Inherited Members

- Protected Member Functions inherited from Fw::Serializable
 Serializable ()
 Default constructor. More...
 
virtual ~Serializable ()
 Virtual destructor. More...
 

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SERIALIZED_SIZE 

Definition at line 22 of file TimeInterval.hpp.

◆ Comparison

The type of a comparison result.

Enumerator
LT 
EQ 
GT 
INCOMPARABLE 

Definition at line 47 of file TimeInterval.hpp.

Constructor & Destructor Documentation

◆ TimeInterval() [1/4]

Fw::TimeInterval::TimeInterval ( )
default

◆ ~TimeInterval()

Fw::TimeInterval::~TimeInterval ( )
default

◆ TimeInterval() [2/4]

TimeInterval::TimeInterval ( const TimeInterval other)

Definition at line 5 of file TimeInterval.cpp.

◆ TimeInterval() [3/4]

TimeInterval::TimeInterval ( U32  seconds,
U32  useconds 
)

Definition at line 9 of file TimeInterval.cpp.

◆ TimeInterval() [4/4]

TimeInterval::TimeInterval ( const Time start,
const Time end 
)

Definition at line 13 of file TimeInterval.cpp.

Member Function Documentation

◆ add() [1/2]

void TimeInterval::add ( U32  seconds,
U32  mseconds 
)

Definition at line 122 of file TimeInterval.cpp.

◆ add() [2/2]

TimeInterval TimeInterval::add ( const TimeInterval a,
const TimeInterval b 
)
static

Add two time intervals Adds the seconds and microseconds fields of two time intervals together

Returns
TimeInterval result
Parameters
aTimeInterval a
bTimeInterval b

Definition at line 93 of file TimeInterval.cpp.

◆ compare()

TimeInterval::Comparison TimeInterval::compare ( const TimeInterval time1,
const TimeInterval time2 
)
static

Compare two time intervals A time interval is considered greater than another if it spans a longer duration The comparison is done on the seconds first, then the microseconds if the seconds are equal

Returns
TimeInterval result
Parameters
time1TimeInterval 1
time2TimeInterval 2

Definition at line 74 of file TimeInterval.cpp.

◆ deserializeFrom()

SerializeStatus TimeInterval::deserializeFrom ( SerialBufferBase buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
)
overridevirtual

Deserialize the contents of this object from a buffer.

This method reads serialized data from the provided buffer and reconstructs the object's data from it. The buffer should contain data in the format produced by serializeTo().

Parameters
bufferReference to the SerialBufferBase from which data will be deserialized
modeEndianness mode for deserialization (default is Endianness::BIG)
Returns
SerializeStatus indicating the result of the operation

Implements Fw::Serializable.

Definition at line 61 of file TimeInterval.cpp.

◆ getSeconds()

U32 TimeInterval::getSeconds ( ) const

Definition at line 66 of file TimeInterval.cpp.

◆ getUSeconds()

U32 TimeInterval::getUSeconds ( ) const

Definition at line 70 of file TimeInterval.cpp.

◆ operator!=()

bool TimeInterval::operator!= ( const TimeInterval other) const

Definition at line 34 of file TimeInterval.cpp.

◆ operator<()

bool TimeInterval::operator< ( const TimeInterval other) const

Definition at line 42 of file TimeInterval.cpp.

◆ operator<=()

bool TimeInterval::operator<= ( const TimeInterval other) const

Definition at line 51 of file TimeInterval.cpp.

◆ operator=()

TimeInterval & TimeInterval::operator= ( const TimeInterval other)

Definition at line 23 of file TimeInterval.cpp.

◆ operator==()

bool TimeInterval::operator== ( const TimeInterval other) const

Definition at line 30 of file TimeInterval.cpp.

◆ operator>()

bool TimeInterval::operator> ( const TimeInterval other) const

Definition at line 38 of file TimeInterval.cpp.

◆ operator>=()

bool TimeInterval::operator>= ( const TimeInterval other) const

Definition at line 46 of file TimeInterval.cpp.

◆ serializeTo()

SerializeStatus TimeInterval::serializeTo ( SerialBufferBase buffer,
Fw::Endianness  mode = Fw::Endianness::BIG 
) const
overridevirtual

Serialize the contents of this object to a buffer.

This method serializes the object's data into the provided buffer. The serialization process converts the object's data into a format that can be stored or transmitted, and then writes it to the buffer.

Parameters
bufferReference to the SerialBufferBase where data will be serialized
modeEndianness mode for serialization (default is Endianness::BIG)
Returns
SerializeStatus indicating the result of the operation

Implements Fw::Serializable.

Definition at line 56 of file TimeInterval.cpp.

◆ set()

void TimeInterval::set ( U32  seconds,
U32  useconds 
)

Definition at line 17 of file TimeInterval.cpp.

◆ sub()

TimeInterval TimeInterval::sub ( const TimeInterval t1,
const TimeInterval t2 
)
static

Subtract two time intervals This computes the absolute value of the difference between two time intervals For example if t1=(0s, 5us) and t2=(0s, 3us), the result is (0s, 2us). This operation is commutative, i.e. the result is the same regardless of the order of the arguments.

Returns
TimeInterval result
Parameters
t1TimeInterval 1
t2TimeInterval 2

Definition at line 105 of file TimeInterval.cpp.


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