WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
clockwerk::GraphTreeObject Class Reference

Base class for object organization. More...

#include <GraphTreeObject.h>

Inheritance diagram for clockwerk::GraphTreeObject:

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.
GraphTreeObjectparent ()
 Functions to get object's parent/children.
GraphTreeObject ** children ()
GraphTreeObjectchildAtIndex (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.
GraphTreeObjectgetRootDataPointer ()
 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.

Detailed Description

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

Constructor & Destructor Documentation

◆ GraphTreeObject()

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.

◆ ~GraphTreeObject()

virtual clockwerk::GraphTreeObject::~GraphTreeObject ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ _addChild()

int16 clockwerk::GraphTreeObject::_addChild ( GraphTreeObject * child)
protected

Function to decompose a string into a series of substrings via indexing.

Parameters
addressThe address to be decomposed
Returns
A vector of strings containing each delimeter-separated substring

Function to add a child to the graph tree object

Parameters
childA pointer to the graph tree object to add to the tree
Returns
An error code corresponding to success/failure

◆ _recalculateDescendants()

void clockwerk::GraphTreeObject::_recalculateDescendants ( )
protected

Function to recursively re-calculate the number of descendants of a given node on the tree.

◆ _recalculateRank()

void clockwerk::GraphTreeObject::_recalculateRank ( )
protected

Function to recursively re-calculate the rank of a given node on the tree.

◆ _removeChild()

int16 clockwerk::GraphTreeObject::_removeChild ( GraphTreeObject * child)
protected

Function to remove a child from the graph node's children.

Parameters
childThe child to remove
Returns
Success/fail error code based on whether the child is present

◆ _setStorage()

int16 clockwerk::GraphTreeObject::_setStorage ( GraphTreeObject ** storage_array,
uint8 storage_size )
protected

Getter for object's string address.

Parameters
add_outImplicit return of the string address for the object

Set the storage for the GraphTreeObject from the default (none) to a new source

Parameters
storage_arrayAn array of GraphTreeObject which will store the children of this object
storage_sizeThe number of values which may be held by storage_array
Note
Assumes internal array is nullptr/no children. Returns error otherwise

◆ capacity()

uint8 clockwerk::GraphTreeObject::capacity ( ) const
inline

◆ childAtIndex()

GraphTreeObject * clockwerk::GraphTreeObject::childAtIndex ( uint8 i) const
inline

◆ children()

GraphTreeObject ** clockwerk::GraphTreeObject::children ( )
inline

◆ fromStr()

virtual int16 clockwerk::GraphTreeObject::fromStr ( const char * val)
inlinevirtual

Set value of graphtreeobject from string.

Parameters
valThe value to set object from
Returns
Error code corresponding to success/failure
Note
Should be set in derived class – this one is useless.

Reimplemented in clockwerk::Time.

◆ getRootDataPointer()

GraphTreeObject * clockwerk::GraphTreeObject::getRootDataPointer ( )

Get the pointer to the highest object in the graph tree.

Returns
Pointer to the root graph tree object

◆ loggable()

bool clockwerk::GraphTreeObject::loggable ( )
inline

Getter for object logability flag – note no setter because should only be set by this or a derived class in its definition.

◆ name() [1/2]

const char * clockwerk::GraphTreeObject::name ( ) const
inline

Getter and setter for object name.

◆ name() [2/2]

int16 clockwerk::GraphTreeObject::name ( const char * new_name)

◆ nChildren()

uint8 clockwerk::GraphTreeObject::nChildren ( ) const
inline

Getters for number of children and descendants.

◆ nDescendants()

uint16 clockwerk::GraphTreeObject::nDescendants ( ) const
inline

◆ parent() [1/3]

GraphTreeObject * clockwerk::GraphTreeObject::parent ( )
inline

Functions to get object's parent/children.

◆ parent() [2/3]

int16 clockwerk::GraphTreeObject::parent ( GraphTreeObject & new_parent)

Function to assign the node's parent via reference.

Parameters
new_parentThe new parent to assign the node to
Returns
Error code corresponding to success/failure
Note
This function is the only method to ADD or REMOVE a node from a tree. To add, pass the address to a GraphTreeObject to this function. To remove, pass a nullptr. Note that parents for objects on an existing tree can be reassigned

◆ parent() [3/3]

int16 clockwerk::GraphTreeObject::parent ( GraphTreeObject * new_parent)

Function to assign the node's parent via pointer.

Parameters
new_parentThe new parent to assign the node to
Returns
Error code corresponding to success/failure
Note
This function is the only method to ADD or REMOVE a node from a tree. To add, pass the address to a GraphTreeObject to this function. To remove, pass a nullptr. Note that parents for objects on an existing tree can be reassigned

◆ rank()

uint8 clockwerk::GraphTreeObject::rank ( )
inline

Getter for the object rank.

◆ str()

virtual int16 clockwerk::GraphTreeObject::str ( char * output,
size_t size ) const
inlinevirtual

Get object represented as string.

Parameters
outputThe output string
sizeThe maximum size of the variable to write string to
Note
Should be set in derived class

Reimplemented in clockwerk::Time.

◆ type()

int8 clockwerk::GraphTreeObject::type ( )
inline

Function to indicate type – -1 by default unless implemented downstream.

Returns
Int indicating frame type – unimplemented always -1

Member Data Documentation

◆ _children_ptr

GraphTreeObject** clockwerk::GraphTreeObject::_children_ptr = nullptr
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

◆ _graph_tree_type

int8 clockwerk::GraphTreeObject::_graph_tree_type = BASE_GRAPH_TREE
protected

Variable to store graph tree object type.

◆ _index

uint32 clockwerk::GraphTreeObject::_index = 0
protected

Index pointing to the next write location for the graph tree children.

◆ _loggable

bool clockwerk::GraphTreeObject::_loggable = false
protected

Variable to indicate whether the selected object is loggable. Set to false by default.

◆ _max_num_children

uint32 clockwerk::GraphTreeObject::_max_num_children = 0
protected

◆ _name

char clockwerk::GraphTreeObject::_name[MAXIMUM_NAME_CHARS] = ""
protected

String name for object.

◆ _num_children

uint8 clockwerk::GraphTreeObject::_num_children = 0
protected

Number of direct children of the tree (not including the tree itself).

◆ _num_descendants

uint16 clockwerk::GraphTreeObject::_num_descendants = 0
protected

Total number of descendants (includes children of children) of the tree, again not including the tree itself

◆ _parent

GraphTreeObject* clockwerk::GraphTreeObject::_parent = nullptr
protected

Pointer to the object's parent – should be null if the object is the root. Is set to null by default

◆ _rank

uint8 clockwerk::GraphTreeObject::_rank = 0
protected

Rank for how far down on the graph tree the object is – starts at zero and maxes out at 255 via variable size


The documentation for this class was generated from the following files:
  • /Users/mickey/Documents/Projects/warptwin/warpos/clockwerk/src/architecture/GraphTreeObject.h
  • /Users/mickey/Documents/Projects/warptwin/warpos/clockwerk/src/architecture/GraphTreeObject.cpp