F´ Flight Software - C/C++ Documentation  devel
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 = NATIVE_UINT_TYPE
 

Public Member Functions

 TimeInterval ()=default
 
 ~TimeInterval ()=default
 
 TimeInterval (const TimeInterval &other)
 
 TimeInterval (U32 seconds, U32 useconds)
 
void set (U32 seconds, U32 useconds)
 
U32 getSeconds () const
 
U32 getUSeconds () const
 
SerializeStatus serialize (SerializeBufferBase &buffer) const
 serialize contents More...
 
SerializeStatus deserialize (SerializeBufferBase &buffer)
 deserialize to contents 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)
 

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 ()
 destructor More...
 

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SERIALIZED_SIZE 

Definition at line 21 of file TimeInterval.hpp.

◆ Comparison

The type of a comparison result.

Enumerator
LT 
EQ 
GT 
INCOMPARABLE 

Definition at line 44 of file TimeInterval.hpp.

Constructor & Destructor Documentation

◆ TimeInterval() [1/3]

Fw::TimeInterval::TimeInterval ( )
default

◆ ~TimeInterval()

Fw::TimeInterval::~TimeInterval ( )
default

◆ TimeInterval() [2/3]

TimeInterval::TimeInterval ( const TimeInterval other)

Definition at line 5 of file TimeInterval.cpp.

◆ TimeInterval() [3/3]

TimeInterval::TimeInterval ( U32  seconds,
U32  useconds 
)

Definition at line 9 of file TimeInterval.cpp.

Member Function Documentation

◆ add() [1/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 104 of file TimeInterval.cpp.

◆ add() [2/2]

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

Definition at line 141 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 80 of file TimeInterval.cpp.

◆ deserialize()

SerializeStatus TimeInterval::deserialize ( SerializeBufferBase buffer)
virtual

deserialize to contents

Implements Fw::Serializable.

Definition at line 61 of file TimeInterval.cpp.

◆ getSeconds()

U32 TimeInterval::getSeconds ( ) const

Definition at line 72 of file TimeInterval.cpp.

◆ getUSeconds()

U32 TimeInterval::getUSeconds ( ) const

Definition at line 76 of file TimeInterval.cpp.

◆ operator!=()

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

Definition at line 29 of file TimeInterval.cpp.

◆ operator<()

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

Definition at line 37 of file TimeInterval.cpp.

◆ operator<=()

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

Definition at line 46 of file TimeInterval.cpp.

◆ operator=()

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

Definition at line 18 of file TimeInterval.cpp.

◆ operator==()

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

Definition at line 25 of file TimeInterval.cpp.

◆ operator>()

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

Definition at line 33 of file TimeInterval.cpp.

◆ operator>=()

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

Definition at line 41 of file TimeInterval.cpp.

◆ serialize()

SerializeStatus TimeInterval::serialize ( SerializeBufferBase buffer) const
virtual

serialize contents

Implements Fw::Serializable.

Definition at line 51 of file TimeInterval.cpp.

◆ set()

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

Definition at line 13 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 121 of file TimeInterval.cpp.


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