![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Wrapper to manage and convert time as timespce. More...
#include <Time.h>

Public Member Functions | |
| Time (const struct timespec &t) | |
| Default, copy constructors and default destructor. | |
| Time (int64 sec=0, int64 nsec=0) | |
| ~Time () | |
| int64 | sec () const |
| Get time seconds. | |
| int64 | nsec () const |
| Get time nanoseconds. | |
| void | setTime (const struct timespec &t) |
| Function to set the time in the time object. | |
| void | setTime (uint32 sec, uint32 nsec) |
| Function to set the time in the time object. | |
| void | stepTime (uint64 nsec) |
| Function to step time forward by a set amount of nanoseconds. | |
| const timespec & | asTimespec () const |
| Functions to return various time formats. | |
| floating_point | asFloatingPoint () const |
| unsigned long long | asMilliseconds () const |
| int16 | fromStr (const char *str) override |
| int16 | str (char *output, size_t size) const override |
| Output time as string. | |
| floating_point | asFrequency () |
| Function to convert time to frequency in Hz. | |
| int16 | fromFrequency (uint16 rate_hz) |
| Function to set a time object from a frequency, in Hz. | |
| void | fromFloatingPoint (floating_point val) |
| Function to set a time object from floating point. | |
| int16 | add (const Time &a, Time &res) const |
| Set the time object from a string. | |
| int16 | subtract (const Time &b, Time &res) const |
| Function to subtract a - b = res. | |
| int16 | multiply (unsigned int m, Time &res) const |
| Function to multiply time by int. | |
| int16 | divide (unsigned int d, Time &res) const |
| Function to divide time by int. | |
| bool | operator>= (const Time &B) const |
| Overloaded operator to compare two time objects. | |
| bool | operator<= (const Time &B) const |
| Overloaded operator to compare two time objects. | |
| bool | operator> (const Time &B) const |
| Overloaded operator to compare two time objects. | |
| bool | operator< (const Time &B) const |
| Overloaded operator to compare two time objects. | |
| bool | operator== (const Time &B) const |
| Overloaded operator to compare two time objects. | |
| Public Member Functions inherited from clockwerk::GraphTreeObject | |
| GraphTreeObject (const char *gt_nme="", GraphTreeObject **storage_array=nullptr, uint32 storage_size=0) | |
| Name-based constructor for GraphTreeObject which will have no children by default. | |
| virtual | ~GraphTreeObject () |
| Destructor. | |
| GraphTreeObject * | parent () |
| Functions to get object's parent/children. | |
| GraphTreeObject ** | children () |
| GraphTreeObject * | childAtIndex (uint8 i) const |
| int16 | parent (GraphTreeObject *new_parent) |
| Function to assign the node's parent via pointer. | |
| int16 | parent (GraphTreeObject &new_parent) |
| Function to assign the node's parent via reference. | |
| uint8 | nChildren () const |
| Getters for number of children and descendants. | |
| uint16 | nDescendants () const |
| uint8 | capacity () const |
| const char * | name () const |
| Getter and setter for object name. | |
| int16 | name (const char *new_name) |
| uint8 | rank () |
| Getter for the object rank. | |
| int8 | type () |
| Function to indicate type – -1 by default unless implemented downstream. | |
| bool | loggable () |
| Getter for object logability flag – note no setter because should only be set by this or a derived class in its definition. | |
| GraphTreeObject * | getRootDataPointer () |
| Get the pointer to the highest object in the graph tree. | |
Protected Attributes | |
| struct timespec | _tspec |
| Protected Attributes inherited from clockwerk::GraphTreeObject | |
| GraphTreeObject * | _parent = nullptr |
| GraphTreeObject ** | _children_ptr = nullptr |
| uint32 | _max_num_children = 0 |
| uint16 | _num_descendants = 0 |
| char | _name [MAXIMUM_NAME_CHARS] = "" |
| String name for object. | |
| uint8 | _num_children = 0 |
| Number of direct children of the tree (not including the tree itself). | |
| uint8 | _rank = 0 |
| int8 | _graph_tree_type = BASE_GRAPH_TREE |
| Variable to store graph tree object type. | |
| bool | _loggable = false |
| Variable to indicate whether the selected object is loggable. Set to false by default. | |
| uint32 | _index = 0 |
| Index pointing to the next write location for the graph tree children. | |
Additional Inherited Members | |
| Protected Member Functions inherited from clockwerk::GraphTreeObject | |
| int16 | _setStorage (GraphTreeObject **storage_array, uint8 storage_size) |
| Getter for object's string address. | |
| void | _recalculateDescendants () |
| Function to recursively re-calculate the number of descendants of a given node on the tree. | |
| void | _recalculateRank () |
| Function to recursively re-calculate the rank of a given node on the tree. | |
| int16 | _addChild (GraphTreeObject *child) |
| Function to decompose a string into a series of substrings via indexing. | |
| int16 | _removeChild (GraphTreeObject *child) |
| Function to remove a child from the graph node's children. | |
Wrapper to manage and convert time as timespce.
The time class is a simple wrapper class designed to make working with time simple. It wraps around a struct timespec as its core, and contains functions to perform time math and conversions into various formats.
|
inline |
Default, copy constructors and default destructor.
|
inline |
|
inline |
Set the time object from a string.
| val | String in standard seconds.decimal format |
Function to add two times together a + b
| a | Time to add |
| res | Result of the addition operation |
|
inline |
| floating_point clockwerk::Time::asFrequency | ( | ) |
Function to convert time to frequency in Hz.
|
inline |
|
inline |
Functions to return various time formats.
| int16 clockwerk::Time::divide | ( | unsigned int | d, |
| Time & | res ) const |
Function to divide time by int.
| d | Amount to divide by |
| res | Result of the division operation |
| void clockwerk::Time::fromFloatingPoint | ( | floating_point | val | ) |
Function to set a time object from floating point.
| val | The floating point value to set time from |
| int16 clockwerk::Time::fromFrequency | ( | uint16 | rate_hz | ) |
Function to set a time object from a frequency, in Hz.
| rate_hz | The rate to be converted to time |
|
overridevirtual |
Reimplemented from clockwerk::GraphTreeObject.
| int16 clockwerk::Time::multiply | ( | unsigned int | m, |
| Time & | res ) const |
Function to multiply time by int.
| m | Amount to multiply by |
| res | Result of the multiplication operation |
|
inline |
Get time nanoseconds.
| bool clockwerk::Time::operator< | ( | const Time & | B | ) | const |
Overloaded operator to compare two time objects.
| B | Time value to compare against |
| bool clockwerk::Time::operator<= | ( | const Time & | B | ) | const |
Overloaded operator to compare two time objects.
| B | Time value to compare against |
| bool clockwerk::Time::operator== | ( | const Time & | B | ) | const |
Overloaded operator to compare two time objects.
| B | Time value to compare against |
| bool clockwerk::Time::operator> | ( | const Time & | B | ) | const |
Overloaded operator to compare two time objects.
| B | Time value to compare against |
| bool clockwerk::Time::operator>= | ( | const Time & | B | ) | const |
Overloaded operator to compare two time objects.
| B | Time value to compare against |
|
inline |
Get time seconds.
|
inline |
Function to set the time in the time object.
| t | Timespec to set the time to11 |
|
inline |
| void clockwerk::Time::stepTime | ( | uint64 | nsec | ) |
Function to step time forward by a set amount of nanoseconds.
| nsec | Number of nanoseconds to step by |
|
overridevirtual |
Output time as string.
Get object represented as string
| output | The output string |
| size | The maximum size of the variable to write string to |
Reimplemented from clockwerk::GraphTreeObject.
Function to subtract a - b = res.
| b | Time to subtract |
| res | Result of the subtraction operation |
|
protected |