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

Relay DataIO data over a shared memory. More...

#include <DataIOShmemRelay.h>

Inheritance diagram for warptwin::DataIOShmemRelay:

Public Member Functions

 DataIOShmemRelay (DataIOBase &map_target, const char *shmem_name, bool is_read=true)
 Only constructor for this object – requires mapping target, name for shared memory.
 ~DataIOShmemRelay ()
int16 syncExternal () override
 Synchronize DataIO values to shared memory.
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 _syncWriteShmem ()
 Write DataIO information to shared memory.
int16 _syncReadShmem ()
 Read DataIO information from shared memory.
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

int _fd = -1
 File descriptor for shmem access.
bool _is_read
 Bool indicating whether this DataIO is read or write.
void * _addr
 Pointer to our shared memory.
uint8 * _droot
 Pointer for malloc of our data space to copy out of shmem.
int _data_size
 Amount of data space reserved in shmem and allocated.
DataIOBase_tgt
 Reference information on type and size.
std::string _created = ""
 Reference for created file to clear on creation.
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 shared memory.

This class establishes a relay between a DataIO object and some object on the other side of shared memory, which could be a dataio or could be some other means of interpreting data. It performs a simple memcpy on DataIO data into shared memory space, which can be read freely.

Essentially it comes in two configurations: "Read" (object read shared memory) --> (read downstream by connected signal) "Write" (reads from upstream connected signal) --> (object write shared memory)

This relay is structured differently than other DataIO objects, in that it must be mapped to a target at construction. Like other DataIO objects, it should only be mapped to a single type, given by the DataIO to which it is mapped. It does not itself hold values, and only reflects the values in the mapped object.

This class assumes Linux.

Constructor & Destructor Documentation

◆ DataIOShmemRelay()

warptwin::DataIOShmemRelay::DataIOShmemRelay ( DataIOBase & map_target,
const char * shmem_name,
bool is_read = true )

Only constructor for this object – requires mapping target, name for shared memory.

Parameters
map_targetDataIOBase object the shared memory is mapped to
shmem_nameThe name of the shared memory address. Should begin with a /
is_readtrue - this target reads from shared memory and is upstream of map_target false - this target writes to shared memory and is downstream of map_target

◆ ~DataIOShmemRelay()

warptwin::DataIOShmemRelay::~DataIOShmemRelay ( )

Member Function Documentation

◆ _syncReadShmem()

int16 warptwin::DataIOShmemRelay::_syncReadShmem ( )
protected

Read DataIO information from shared memory.

Returns
Error code corresponding to success/failure

◆ _syncWriteShmem()

int16 warptwin::DataIOShmemRelay::_syncWriteShmem ( )
protected

Write DataIO information to shared memory.

Returns
Error code corresponding to success/failure

◆ syncExternal()

int16 warptwin::DataIOShmemRelay::syncExternal ( )
overridevirtual

Synchronize DataIO values to shared memory.

Returns
Error code corresponding to success/failure

Reimplemented from clockwerk::DataIOBase.

Member Data Documentation

◆ _addr

void* warptwin::DataIOShmemRelay::_addr
protected

Pointer to our shared memory.

◆ _created

std::string warptwin::DataIOShmemRelay::_created = ""
protected

Reference for created file to clear on creation.

◆ _data_size

int warptwin::DataIOShmemRelay::_data_size
protected

Amount of data space reserved in shmem and allocated.

◆ _droot

uint8* warptwin::DataIOShmemRelay::_droot
protected

Pointer for malloc of our data space to copy out of shmem.

◆ _fd

int warptwin::DataIOShmemRelay::_fd = -1
protected

File descriptor for shmem access.

◆ _is_read

bool warptwin::DataIOShmemRelay::_is_read
protected

Bool indicating whether this DataIO is read or write.

◆ _tgt

DataIOBase& warptwin::DataIOShmemRelay::_tgt
protected

Reference information on type and size.


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