WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
DataIOBase.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, INC. 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, INC.
15******************************************************************************/
16/*
17Data IO Base File
18
19Author: Alex Reynolds
20*/
21#ifndef DATA_MANAGEMENT_DATA_IO_BASE_H
22#define DATA_MANAGEMENT_DATA_IO_BASE_H
23
24#include <array>
25#if CLOCKWERK_ALLOW_VECTOR
26#include <vector>
27#endif
28
29#include "types.h"
30#include "GraphTreeObject.h"
32#include "core/Matrix.hpp"
33#include "architecture/Time.h"
34
35namespace clockwerk {
36
53
63 class DataIOBase : public GraphTreeObject {
64 public:
68
72
75 virtual int dataSize() {return -1;}
76
78 void allowWrite() {_writeAllowed = true;}
79 void blockWrite() {_writeAllowed = false;}
80 bool writeAllowed() {return _writeAllowed;}
81
85 void mapTo(DataIOBase &data_source) {_data = &data_source; _root = false;}
86
89 void resetMap() {_data = this; _writeAllowed = true; _root = true;}
90
94
97 void* writePtr();
98
101 void* read() const;
102
105 uint8 dataType() {return _type_id;}
106
109
112 virtual int16 getValueAsString(char* retval, size_t size) {return ERROR_BUFFER_NOT_IMPLEMENTED;}
113
117 virtual int16 setValueFromString(const char* value) {return ERROR_BUFFER_NOT_IMPLEMENTED;}
118
119 protected:
122 template <typename T> typename std::enable_if<std::is_integral<T>::value>::type _typeID(T var);
123 template <typename T> typename std::enable_if<std::is_floating_point<T>::value>::type _typeID(T var);
124#if CLOCKWERK_ALLOW_VECTOR
125 template <typename T> void _typeID(std::vector<T> var);
126#endif
127 template <typename T, long unsigned int N> void _typeID(std::array<T, N> var);
128 template <uint32 R, uint32 C> void _typeID(Matrix<R, C> var);
129#if CLOCKWERK_ALLOW_STD_STRING
130 void _typeID(std::string &var);
131#endif
132 void _typeID(const GraphTreeObject &var);
133 void _typeID(const Time &var);
134 void _typeID(void* var);
135 void _typeID(int8 var);
136 void _typeID(int16 var);
137 void _typeID(int32 var);
138 void _typeID(int64 var);
139 void _typeID(uint8 var);
140 void _typeID(uint16 var);
141 void _typeID(uint32 var);
142 void _typeID(uint64 var);
143 void _typeID(char* var);
144
148
151 void* _data_ptr = nullptr;
152
156
159 bool _root;
160
165 };
166
167 template <typename T>
168 typename std::enable_if<std::is_integral<T>::value>::type DataIOBase::_typeID(T var) {_type_id = INTEGER;}
169 template <typename T>
170 typename std::enable_if<std::is_floating_point<T>::value>::type DataIOBase::_typeID(T var) {_type_id = FLOATING_POINT;}
171#if CLOCKWERK_ALLOW_VECTOR
172 template <typename T>
173 void DataIOBase::_typeID(std::vector<T> var) {_type_id = VECTOR;}
174#endif
175 template <typename T, long unsigned int N>
176 void DataIOBase::_typeID(std::array<T, N> var) {_type_id = ARRAY;}
177 template <uint32 R, uint32 C>
179
180}
181
182#endif
DataIOBase()
Default constructor.
Definition DataIOBase.h:66
void * writePtr()
Function to write value to mapped location – root data or map.
Definition DataIOBase.cpp:20
virtual int16 syncExternal()
Synchronize DataIO to some external source – Socket, shared memory, etc.
Definition DataIOBase.h:71
void * read() const
Function to read value from mapped location – root data or map.
Definition DataIOBase.cpp:32
DataIOBase * _data
Definition DataIOBase.h:147
std::enable_if< std::is_integral< T >::value >::type _typeID(T var)
Overloaded functions to identify type held by DataIO.
Definition DataIOBase.h:168
bool writeAllowed()
Definition DataIOBase.h:80
void resetMap()
Definition DataIOBase.h:89
void blockWrite()
Definition DataIOBase.h:79
DataIOBase * dataSource()
Access the target to which the DataIO is mapped.
Definition DataIOBase.h:93
bool _root
Definition DataIOBase.h:159
virtual int dataSize()
Get the size of the core data held by the object.
Definition DataIOBase.h:75
uint8 dataType()
Function to return the type of data held by the DataIO.
Definition DataIOBase.h:105
virtual int16 getValueAsString(char *retval, size_t size)
Return the value held by the DataIO object as a string.
Definition DataIOBase.h:112
void allowWrite()
Functions to manipulate write permissions on DataIO object.
Definition DataIOBase.h:78
bool _writeAllowed
Definition DataIOBase.h:155
void mapTo(DataIOBase &data_source)
Function to map DataIO object to new upstream data source.
Definition DataIOBase.h:85
void * _data_ptr
Definition DataIOBase.h:151
~DataIOBase()
Definition DataIOBase.h:67
virtual int16 setValueFromString(const char *value)
Set the value held by the DataIO object from a string.
Definition DataIOBase.h:117
dataio_types_e _type_id
Definition DataIOBase.h:164
int8 _graph_tree_type
Variable to store graph tree object type.
Definition GraphTreeObject.h:270
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
int8 type()
Function to indicate type – -1 by default unless implemented downstream.
Definition GraphTreeObject.h:143
Matrix math implementation.
Definition Matrix.hpp:55
Wrapper to manage and convert time as timespce.
Definition Time.h:53
#define ERROR_BUFFER_NOT_IMPLEMENTED
Variable to raise an error if an appropriate buffer is not in place.
Definition clockwerkerrors.h:126
Definition CircularBuffer.hpp:28
dataio_types_e
Definition DataIOBase.h:40
@ INTEGER
Definition DataIOBase.h:41
@ STD_STRING
Definition DataIOBase.h:48
@ VECTOR
Definition DataIOBase.h:43
@ ARRAY
Definition DataIOBase.h:44
@ MATRIX
Definition DataIOBase.h:45
@ TIME
Definition DataIOBase.h:51
@ GRAPH_TREE
Definition DataIOBase.h:46
@ UNDEFINED
Definition DataIOBase.h:49
@ FLOATING_POINT
Definition DataIOBase.h:42
@ C_STRING
Definition DataIOBase.h:50
@ POINTER
Definition DataIOBase.h:47
@ DATAIO
Definition GraphTreeObject.h:49