WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::DataIOSocketRelay Class Reference

Relay DataIO data over a socket. More...

#include <DataIOSocketRelay.h>

Inheritance diagram for warptwin::DataIOSocketRelay:

Public Member Functions

 DataIOSocketRelay (DataIOBase &map_target, const char *ip, int port, bool is_read=true)
 Only constructor for this object – requires mapping target, socket info.
 ~DataIOSocketRelay ()
int16 syncExternal () override
 Synchronize DataIO values to socket – both write and read.
Public Member Functions inherited from clockwerk::DataIOBase
 DataIOBase ()
 Default constructor.
 ~DataIOBase ()
virtual int dataSize ()
 Get the size of the core data held by the object.
void allowWrite ()
 Functions to manipulate write permissions on DataIO object.
void blockWrite ()
bool writeAllowed ()
void mapTo (DataIOBase &data_source)
 Function to map DataIO object to new upstream data source.
void resetMap ()
DataIOBasedataSource ()
 Access the target to which the DataIO is mapped.
void * writePtr ()
 Function to write value to mapped location – root data or map.
void * read () const
 Function to read value from mapped location – root data or map.
uint8 dataType ()
 Function to return the type of data held by the DataIO.
virtual int16 getValueAsString (char *retval, size_t size)
 Return the value held by the DataIO object as a string.
virtual int16 setValueFromString (const char *value)
 Set the value held by the DataIO object from a string.
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.
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 _syncWriteSocket ()
 Write DataIO information to socket.
int16 _syncReadSocket ()
 Read DataIO information from socket.
Protected Member Functions inherited from clockwerk::DataIOBase
template<typename T>
std::enable_if< std::is_integral< T >::value >::type _typeID (T var)
 Overloaded functions to identify type held by DataIO.
template<typename T>
std::enable_if< std::is_floating_point< T >::value >::type _typeID (T var)
template<typename T, long unsigned int N>
void _typeID (std::array< T, N > var)
template<uint32 R, uint32 C>
void _typeID (Matrix< R, C > var)
void _typeID (const GraphTreeObject &var)
void _typeID (const Time &var)
void _typeID (void *var)
void _typeID (int8 var)
void _typeID (int16 var)
void _typeID (int32 var)
void _typeID (int64 var)
void _typeID (uint8 var)
void _typeID (uint16 var)
void _typeID (uint32 var)
void _typeID (uint64 var)
void _typeID (char *var)
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.

Protected Attributes

std::string _ip
 IP address.
int _port = 0
 Port we read info from.
int _sock_fd = -1
 File descriptor for write socket.
sockaddr_in _addr
 Socket struct to set IP, etc.
bool _is_read
 Flag indicating whether socket is read or write.
DataIOBase_tgt
 Reference information on type and size.
char _buffer [DATASOCK_IO_BUFFER_SIZE]
 Buffer stuff for io on string conversion.
Protected Attributes inherited from clockwerk::DataIOBase
DataIOBase_data
void * _data_ptr = nullptr
bool _writeAllowed
bool _root
dataio_types_e _type_id = UNDEFINED
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.

Detailed Description

Relay DataIO data over a socket.

This class establishes a relay between a DataIO object and some object on the other side of a socket, which could be a dataio or could be some other means of interpreting data. It uses the built-in DataIO to string conversion to convert data to a string, which it sends over a socket.

This relay is designed to map to other DataIO objects and mirror exactly their behavior – that is, if an object is mapped to this object and it is read, it attempts to pull the latest data from the socket and outputs it. When written, it attempts to write the latest to the socket.

This class assumes Linux sockets.

Constructor & Destructor Documentation

◆ DataIOSocketRelay()

warptwin::DataIOSocketRelay::DataIOSocketRelay ( DataIOBase & map_target,
const char * ip,
int port,
bool is_read = true )

Only constructor for this object – requires mapping target, socket info.

Parameters
map_targetDataIOBase object the socket is mapped to
ipThe IP address to connect on
portThe port to connect on
is_readtrue - this target reads from socket and is upstream of map_target false - this target writes to socket and is downstream of map_target

◆ ~DataIOSocketRelay()

warptwin::DataIOSocketRelay::~DataIOSocketRelay ( )
inline

Member Function Documentation

◆ _syncReadSocket()

int16 warptwin::DataIOSocketRelay::_syncReadSocket ( )
protected

Read DataIO information from socket.

Returns
Error code corresponding to success/failure

◆ _syncWriteSocket()

int16 warptwin::DataIOSocketRelay::_syncWriteSocket ( )
protected

Write DataIO information to socket.

Returns
Error code corresponding to success/failure

◆ syncExternal()

int16 warptwin::DataIOSocketRelay::syncExternal ( )
overridevirtual

Synchronize DataIO values to socket – both write and read.

Returns
Error code corresponding to success/failure

Reimplemented from clockwerk::DataIOBase.

Member Data Documentation

◆ _addr

sockaddr_in warptwin::DataIOSocketRelay::_addr
protected

Socket struct to set IP, etc.

◆ _buffer

char warptwin::DataIOSocketRelay::_buffer[DATASOCK_IO_BUFFER_SIZE]
protected

Buffer stuff for io on string conversion.

◆ _ip

std::string warptwin::DataIOSocketRelay::_ip
protected

IP address.

◆ _is_read

bool warptwin::DataIOSocketRelay::_is_read
protected

Flag indicating whether socket is read or write.

◆ _port

int warptwin::DataIOSocketRelay::_port = 0
protected

Port we read info from.

◆ _sock_fd

int warptwin::DataIOSocketRelay::_sock_fd = -1
protected

File descriptor for write socket.

◆ _tgt

DataIOBase& warptwin::DataIOSocketRelay::_tgt
protected

Reference information on type and size.


The documentation for this class was generated from the following files: