WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
GraphTreeObject.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Graph tree header file
18
19Author: Alex Reynolds
20*/
21#ifndef DATA_MANAGEMENT_GRAPH_TREE_H
22#define DATA_MANAGEMENT_GRAPH_TREE_H
23
24#include "configuration.h"
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <array>
29#if CLOCKWERK_ALLOW_VECTOR
30#include <vector>
31#endif
32#if CLOCKWERK_ALLOW_STD_STRING
33#include <string>
34#endif
35
37
38#define DELIMETER "."
39#define DEFAULT_NAME ""
40
41namespace clockwerk {
42
47 enum graph_tree_types_e : int8 {
49 DATAIO = 1,
50 TASK = 2,
52 FRAME = 4,
53 BODY = 5,
54 NODE = 6
55 };
56
99 public:
101 GraphTreeObject(const char* gt_nme = "", GraphTreeObject** storage_array=nullptr, uint32 storage_size=0);
102
104 virtual ~GraphTreeObject() {}
105
109 GraphTreeObject* childAtIndex(uint8 i) const {return (_children_ptr && i < _max_num_children) ? _children_ptr[i] : nullptr;}
110
118 int16 parent(GraphTreeObject* new_parent);
119
127 int16 parent(GraphTreeObject& new_parent);
128
130 uint8 nChildren() const {return _num_children;}
131 uint16 nDescendants() const {return _num_descendants;}
132 uint8 capacity() const { return _max_num_children; }
133
135 const char* name() const {return _name;}
136 int16 name(const char* new_name);
137
139 uint8 rank() {return _rank;}
140
143 int8 type() {return _graph_tree_type;}
144
147 bool loggable() {return _loggable;}
148
152
157 virtual int16 str(char* output, size_t size) const {return ERROR_BUFFER_NOT_IMPLEMENTED;}
158
163 virtual int16 fromStr(const char* val) {return ERROR_CANNOT_CONVERT_STRING;}
164
167#if CLOCKWERK_ALLOW_STD_STRING
168 std::string address();
169
170#if CLOCKWERK_ALLOW_VECTOR
171 std::vector<std::string> search(const std::string &address);
172
177 GraphTreeObject* getByAddress(const std::string &address);
178
182 virtual int16 header(void* logger) {return WARN_NOT_LOGGABLE;}
183
184 virtual std::vector<std::string> header_info() const {return std::vector<std::string>();}
185
189 virtual int16 log(void* logger) {return WARN_NOT_LOGGABLE;}
190#endif
191#endif
192
193#if CLOCKWERK_ALLOW_VECTOR
196 void findLoggable(std::vector<GraphTreeObject*> &matches);
197#endif
198 protected:
203 int16 _setStorage(GraphTreeObject** storage_array, uint8 storage_size);
204
208
210 void _recalculateRank();
211
215#if CLOCKWERK_ALLOW_VECTOR
216#if CLOCKWERK_ALLOW_STD_STRING
217 std::vector<std::string> _decomposeAddress(std::string address);
218
225 void _findMatches(const std::vector<std::string> &subaddresses, uint32 num_subaddresses,
226 uint32 index, bool match_found, std::vector<GraphTreeObject*> &matches);
227
231 std::vector<GraphTreeObject*> _searchNodes(const std::string &address);
232#endif
233#endif
234
238 int16 _addChild(GraphTreeObject* child);
239
243 int16 _removeChild(GraphTreeObject* child);
244
248
252 GraphTreeObject** _children_ptr = nullptr; // Pointer to children array
253 uint32 _max_num_children = 0; // Max number of allowable children
254
258
260 char _name[MAXIMUM_NAME_CHARS] = "";
261
263 uint8 _num_children = 0;
264
267 uint8 _rank = 0;
268
271
273 bool _loggable = false;
274
276 uint32 _index = 0;
277 };
278
279}
280
281#endif
Base class for object organization.
Definition GraphTreeObject.h:98
uint16 nDescendants() const
Definition GraphTreeObject.h:131
GraphTreeObject ** _children_ptr
Definition GraphTreeObject.h:252
uint32 _max_num_children
Definition GraphTreeObject.h:253
uint16 _num_descendants
Definition GraphTreeObject.h:257
GraphTreeObject ** children()
Definition GraphTreeObject.h:108
virtual ~GraphTreeObject()
Destructor.
Definition GraphTreeObject.h:104
void _recalculateDescendants()
Function to recursively re-calculate the number of descendants of a given node on the tree.
Definition GraphTreeObject.cpp:301
int16 _setStorage(GraphTreeObject **storage_array, uint8 storage_size)
Getter for object's string address.
Definition GraphTreeObject.cpp:31
bool loggable()
Getter for object logability flag – note no setter because should only be set by this or a derived cl...
Definition GraphTreeObject.h:147
int8 _graph_tree_type
Variable to store graph tree object type.
Definition GraphTreeObject.h:270
GraphTreeObject * _parent
Definition GraphTreeObject.h:247
uint8 _num_children
Number of direct children of the tree (not including the tree itself).
Definition GraphTreeObject.h:263
virtual int16 fromStr(const char *val)
Set value of graphtreeobject from string.
Definition GraphTreeObject.h:163
bool _loggable
Variable to indicate whether the selected object is loggable. Set to false by default.
Definition GraphTreeObject.h:273
uint32 _index
Index pointing to the next write location for the graph tree children.
Definition GraphTreeObject.h:276
GraphTreeObject * parent()
Functions to get object's parent/children.
Definition GraphTreeObject.h:107
uint8 capacity() const
Definition GraphTreeObject.h:132
int16 _addChild(GraphTreeObject *child)
Function to decompose a string into a series of substrings via indexing.
Definition GraphTreeObject.cpp:132
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.
Definition GraphTreeObject.cpp:23
char _name[MAXIMUM_NAME_CHARS]
String name for object.
Definition GraphTreeObject.h:260
uint8 _rank
Definition GraphTreeObject.h:267
GraphTreeObject * childAtIndex(uint8 i) const
Definition GraphTreeObject.h:109
int16 _removeChild(GraphTreeObject *child)
Function to remove a child from the graph node's children.
Definition GraphTreeObject.cpp:157
virtual int16 str(char *output, size_t size) const
Get object represented as string.
Definition GraphTreeObject.h:157
uint8 rank()
Getter for the object rank.
Definition GraphTreeObject.h:139
const char * name() const
Getter and setter for object name.
Definition GraphTreeObject.h:135
int8 type()
Function to indicate type – -1 by default unless implemented downstream.
Definition GraphTreeObject.h:143
uint8 nChildren() const
Getters for number of children and descendants.
Definition GraphTreeObject.h:130
GraphTreeObject * getRootDataPointer()
Get the pointer to the highest object in the graph tree.
Definition GraphTreeObject.cpp:79
void _recalculateRank()
Function to recursively re-calculate the rank of a given node on the tree.
Definition GraphTreeObject.cpp:324
#define WARN_NOT_LOGGABLE
Definition clockwerkerrors.h:82
#define ERROR_BUFFER_NOT_IMPLEMENTED
Variable to raise an error if an appropriate buffer is not in place.
Definition clockwerkerrors.h:126
#define ERROR_CANNOT_CONVERT_STRING
Error in the case where dynamics model overruns steps or gets out of whack.
Definition clockwerkerrors.h:182
Definition CircularBuffer.hpp:28
graph_tree_types_e
Definition GraphTreeObject.h:47
@ TASK
Definition GraphTreeObject.h:50
@ FRAME
Definition GraphTreeObject.h:52
@ BASE_GRAPH_TREE
Definition GraphTreeObject.h:48
@ DATAIO
Definition GraphTreeObject.h:49
@ EXECUTIVE
Definition GraphTreeObject.h:51
@ NODE
Definition GraphTreeObject.h:54
@ BODY
Definition GraphTreeObject.h:53
half log(half arg)
Definition half.hpp:3050