![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
Base class for object organization. More...
#include <GraphTreeObject.h>

Public Member Functions | |
| 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. | |
| virtual int16 | str (char *output, size_t size) const |
| Get object represented as string. | |
| virtual int16 | fromStr (const char *val) |
| Set value of graphtreeobject from string. | |
Protected Member Functions | |
| 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. | |
Protected Attributes | |
| 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. | |
Base class for object organization.
This file defines a base class for data organization into a format we're calling here a "graph tree". The graph tree is set up to connect a single parent to any number of children, which may be done upon construction or at runtime. Graph trees allow connections between any number of inherited objects and their parents/children, allowing for recursive math and search functionality. In essence, the class is a doubly linked list with multiple children and search functionality.
Parent
|
---------------------------------------
| | | |
Child 1 Child 2 Child 3 Child 4
Also, note that trees objects are entirely independent of their position in that tree, so a child can be treated as if it were root in the case where a local search should be performed.
String Address Functionality String addressing is one of the most critical functions of the graph tree. It allows for easy access to data, in addition to search and write functions. String addresses are constructed from the names of individual objects on the tree, separated by a delimiter defined in this file (a period by default). So a standard string address could look like:
.firstObj.secondObj.thirdObj.otherThing
which would indicate four levels of heirarchy on the tree, with otherThing being the furthest down on the tree. The object at the location otherThing can be accessed by requesting the string address.
Graph tree has the following restrictions driven by data size: Number of children – restricted by variable size and uint8 size Number of descendants – restricted by uint16 size
NOTE: As of the Great ModelSpace Restructure of July 2025, the GraphTreeObject is configured to allow for a resizing by pointing to an external array. This makes the GraphTreeObject flexible on size, which is necessary to ensure it works well in embedded and simulation environments
| 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.
|
inlinevirtual |
Destructor.
|
protected |
Function to decompose a string into a series of substrings via indexing.
| address | The address to be decomposed |
Function to add a child to the graph tree object
| child | A pointer to the graph tree object to add to the tree |
|
protected |
Function to recursively re-calculate the number of descendants of a given node on the tree.
|
protected |
Function to recursively re-calculate the rank of a given node on the tree.
|
protected |
Function to remove a child from the graph node's children.
| child | The child to remove |
|
protected |
Getter for object's string address.
| add_out | Implicit return of the string address for the object |
Set the storage for the GraphTreeObject from the default (none) to a new source
| storage_array | An array of GraphTreeObject which will store the children of this object |
| storage_size | The number of values which may be held by storage_array |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Set value of graphtreeobject from string.
| val | The value to set object from |
Reimplemented in clockwerk::Time.
| GraphTreeObject * clockwerk::GraphTreeObject::getRootDataPointer | ( | ) |
Get the pointer to the highest object in the graph tree.
|
inline |
Getter for object logability flag – note no setter because should only be set by this or a derived class in its definition.
|
inline |
Getter and setter for object name.
| int16 clockwerk::GraphTreeObject::name | ( | const char * | new_name | ) |
|
inline |
Getters for number of children and descendants.
|
inline |
|
inline |
Functions to get object's parent/children.
| int16 clockwerk::GraphTreeObject::parent | ( | GraphTreeObject & | new_parent | ) |
Function to assign the node's parent via reference.
| new_parent | The new parent to assign the node to |
| int16 clockwerk::GraphTreeObject::parent | ( | GraphTreeObject * | new_parent | ) |
Function to assign the node's parent via pointer.
| new_parent | The new parent to assign the node to |
|
inline |
Getter for the object rank.
|
inlinevirtual |
Get object represented as string.
| output | The output string |
| size | The maximum size of the variable to write string to |
Reimplemented in clockwerk::Time.
|
inline |
Function to indicate type – -1 by default unless implemented downstream.
|
protected |
Pointers to the object's children – nominally empty but can be resized based on need, due to the fact that GraphTreeObject is primarily used to feed other classes
|
protected |
Variable to store graph tree object type.
|
protected |
Index pointing to the next write location for the graph tree children.
|
protected |
Variable to indicate whether the selected object is loggable. Set to false by default.
|
protected |
|
protected |
String name for object.
|
protected |
Number of direct children of the tree (not including the tree itself).
|
protected |
Total number of descendants (includes children of children) of the tree, again not including the tree itself
|
protected |
Pointer to the object's parent – should be null if the object is the root. Is set to null by default
|
protected |
Rank for how far down on the graph tree the object is – starts at zero and maxes out at 255 via variable size