AERA
Static Public Member Functions | Static Public Attributes | List of all members
r_code::Utils Class Reference

Static Public Member Functions

static Timestamp GetTimeReference ()
 
static std::chrono::microseconds GetBasePeriod ()
 
static uint32 GetFloatTolerance ()
 
static std::chrono::microseconds GetTimeTolerance ()
 
static void SetReferenceValues (std::chrono::microseconds base_period, float32 float_tolerance, std::chrono::microseconds time_tolerance)
 
static void SetTimeReference (Timestamp time_reference)
 
static bool Equal (float32 l, float32 r)
 
static bool Synchronous (Timestamp l, Timestamp r)
 
static int64 GetInt64 (const Atom *code, size_t index)
 
static void SetInt64 (Atom *code, size_t index, int64 value)
 
static Timestamp GetTimestamp (const Atom *iptr)
 
static std::chrono::microseconds GetMicrosecondsSinceEpoch (const Atom *iptr)
 
static void SetTimestamp (Atom *iptr, Timestamp timestamp)
 
static void SetTimestampStruct (Code *object, uint16 index, Timestamp timestamp)
 
template<class O >
static bool HasTimestamp (const O *object, uint16 index)
 
template<class O >
static Timestamp GetTimestamp (const O *object, uint16 index)
 
template<class O >
static void SetTimestamp (O *object, uint16 index, Timestamp timestamp)
 
static std::string ToString_s_ms_us (Timestamp timestamp, Timestamp time_reference)
 
static std::chrono::microseconds GetDuration (const Atom *iptr)
 
static void SetDuration (Atom *iptr, std::chrono::microseconds duration)
 
static void SetDurationStruct (Code *object, uint16 index, std::chrono::microseconds duration)
 
template<class O >
static std::chrono::microseconds GetDuration (const O *object, uint16 index)
 
template<class O >
static void SetDuration (O *object, uint16 index, std::chrono::microseconds duration)
 
static std::string ToString_us (std::chrono::microseconds duration)
 
static std::string GetString (const Atom *iptr)
 
static void SetString (Atom *iptr, const std::string &s)
 
template<class O >
static std::string GetString (const O *object, uint16 index)
 
template<class O >
static void SetString (O *object, uint16 index, const std::string &s)
 
static int32 GetResilience (Timestamp now, std::chrono::microseconds time_to_live, uint64 upr)
 
static int32 GetResilience (float32 resilience, float32 origin_upr, float32 destination_upr)
 
static std::string RelativeTime (Timestamp t)
 
static bool has_reference (const Atom *code, uint16 index)
 

Static Public Attributes

static const uint64 MaxTHZ = 0xFFFFFFFF
 

Detailed Description

Definition at line 115 of file r_code/utils.h.

Member Function Documentation

◆ GetDuration() [1/2]

static std::chrono::microseconds r_code::Utils::GetDuration ( const Atom iptr)
inlinestatic

Interpret iptr[1] and iptr[2] as an signed 64-bit integer and return it as a duration. This assumes that the caller has already checked iptr[0] == Atom::DURATION, if needed.

Parameters
iptrA pointer into the Atom array.
Returns
The duration.

Definition at line 242 of file r_code/utils.h.

◆ GetDuration() [2/2]

template<class O >
static std::chrono::microseconds r_code::Utils::GetDuration ( const O *  object,
uint16  index 
)
inlinestatic

Get the duration pointed to by the I_PTR at index. This assumes that the caller has already checked that the code pointed to is Atom::DURATION, if needed.

Parameters
objectThe object with the Code array.
indexThe index in the Code array of the I_PTR to the duration structure (like SetDuration<Code>() but not the index of the duration structure itself as in SetDurationStruct()).
Returns
The duration.

Definition at line 274 of file r_code/utils.h.

◆ GetInt64()

static int64 r_code::Utils::GetInt64 ( const Atom code,
size_t  index 
)
inlinestatic

Get the signed 64-bit integer at code[index] and code[index + 1].

Parameters
codeThe Atom array.
indexThe index in code of the first uint32 value.
Returns
The signed 64-bit integer.

Definition at line 138 of file r_code/utils.h.

◆ GetTimestamp() [1/2]

Timestamp r_code::Utils::GetTimestamp ( const Atom iptr)
static

Interpret iptr[1] and iptr[2] as an signed 64-bit integer and return it as time stamp. This assumes that the caller has already checked iptr[0] == Atom::TIMESTAMP, if needed.

Parameters
iptrA pointer into the Atom array.
Returns
The time stamp.

Definition at line 129 of file code_utils.cpp.

◆ GetTimestamp() [2/2]

template<class O >
static Timestamp r_code::Utils::GetTimestamp ( const O *  object,
uint16  index 
)
inlinestatic

Get the time stamp pointed to by the I_PTR at index.

Parameters
objectThe object with the Code array.
indexThe index in the Code array of the I_PTR to the time stamp structure (like SetTimestamp<Code>() but not the index of the time stamp structure itself as in SetTimestampStruct()).
Returns
The time stamp.

Definition at line 204 of file r_code/utils.h.

◆ has_reference()

bool r_code::Utils::has_reference ( const Atom code,
uint16  index 
)
static

Check the code at index has a reference, also following I_PTR and recursing into sets.

Parameters
codeThe code to check.
indexstart checking at code[index].
Returns
True if the element has a reference.

Definition at line 254 of file code_utils.cpp.

◆ SetDuration() [1/2]

static void r_code::Utils::SetDuration ( Atom iptr,
std::chrono::microseconds  duration 
)
inlinestatic

Set iptr[0] to Atom::Duration() and set iptr[1] and iptr[2] to the signed 64-bit value of the duration.

Parameters
iptrA pointer into the Atom array.
durationThe duration.

Definition at line 251 of file r_code/utils.h.

◆ SetDuration() [2/2]

template<class O >
static void r_code::Utils::SetDuration ( O *  object,
uint16  index,
std::chrono::microseconds  duration 
)
inlinestatic

Set the Code array values at index with the structure for the duration.

Parameters
objectThe object with the Code array.
indexThe index in the Code array of the I_PTR to the duration structure (like GetDuration() but not the index of the time stamp structure itself as in SetDurationStruct()).
durationThe duration to put in the structure at the index.

Definition at line 287 of file r_code/utils.h.

◆ SetDurationStruct()

void r_code::Utils::SetDurationStruct ( Code object,
uint16  index,
std::chrono::microseconds  duration 
)
static

Set the Code array values at index with the structure for the duration.

Parameters
objectThe object with the Code array. This expands object->code to allocate atoms.
indexThe index in the Code array to place the duration structure (not the index of the I_PTR to the structure as in SetDuration<Code>() or GetDuration()).
durationThe duration to put in the structure at the index.

Definition at line 168 of file code_utils.cpp.

◆ SetInt64()

static void r_code::Utils::SetInt64 ( Atom code,
size_t  index,
int64  value 
)
inlinestatic

Set the uint32 values at code[index] and code[index + 1] to the big-endian of value.

Parameters
codeThe Atom array. You must make sure the array has room up to code[index + 1].
indexThe index in code for the first uint32 value.
valueThe signed 64-bit integer to set.

Definition at line 149 of file r_code/utils.h.

◆ SetTimestamp() [1/2]

void r_code::Utils::SetTimestamp ( Atom iptr,
Timestamp  timestamp 
)
static

Set iptr[0] to Atom::Timestamp() and set iptr[1] and iptr[2] to the signed 64-bit value of the time stamp.

Parameters
iptrA pointer into the Atom array.
timestampThe time stamp.

Definition at line 134 of file code_utils.cpp.

◆ SetTimestamp() [2/2]

template<class O >
static void r_code::Utils::SetTimestamp ( O *  object,
uint16  index,
Timestamp  timestamp 
)
inlinestatic

Set the Code array values at index with the structure for the timestamp.

Parameters
objectThe object with the Code array.
indexThe index in the Code array of the I_PTR to the time stamp structure (like GetTimestamp() but not the index of the time stamp structure itself as in SetTimestampStruct()).
timestampThe time stamp to put in the structure at the index.

Definition at line 217 of file r_code/utils.h.

◆ SetTimestampStruct()

void r_code::Utils::SetTimestampStruct ( Code object,
uint16  index,
Timestamp  timestamp 
)
static

Set the Code array values at index with the structure for the timestamp.

Parameters
objectThe object with the Code array.
indexThe index in the Code array to place the time stamp structure (not the index of the I_PTR to the structure as in SetTimestamp<Code>() or GetTimestamp()).
timestampThe time stamp to put in the structure at the index.

Definition at line 140 of file code_utils.cpp.

◆ ToString_s_ms_us()

string r_code::Utils::ToString_s_ms_us ( Timestamp  timestamp,
Timestamp  time_reference 
)
static

Make a string from (timestamp - time_reference) in the form XXXs:YYYms:ZZZus, with a minus sign if it is negative.

Parameters
timestampThe time stamp.
time_referenceThe reference time to subtract from timestamp, usually the session start time. We do this because timestamp is seconds since 01/01/1970, so the seconds would be very large.
Returns
The formatted time string.

Definition at line 148 of file code_utils.cpp.

◆ ToString_us()

string r_code::Utils::ToString_us ( std::chrono::microseconds  duration)
static

Make a string from duration in the form XXXus, with a minus sign if it is negative. However if the microseconds portion is zero, then use YYYms. Or if the microseconds and milliseconds portions are zero, then use ZZZs. (This is the complement to how the compiler parses durations.)

Parameters
durationThe duration.
Returns
The formatted time string.

Definition at line 174 of file code_utils.cpp.


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