NDEVR
API Documentation
ConnectionForwarding.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Connection.h>
4#include <NDEVR/Translator.h>
5namespace NDEVR
6{
13 class HARDWARE_API ConnectionForwarding : public Device
14 {
15 public:
40 virtual void update(Time time) override;
46 virtual bool open(bool start_forward_thread = true);
51 virtual bool isOpen() const;
56 Connection* a() const { return m_a; }
61 Connection* b() const { return m_b; }
65 void close();
80 void setForwardAToB(bool forward);
85 void setForwardBToA(bool forward);
90 bool forwardAToB() const { return m_forward_a_to_b; }
95 bool forwardBToA() const { return m_forward_b_to_a; }
100 TimeSpan updateInterval() const override;
105 void setUpdateInterval(const TimeSpan& span);
106 private:
110 virtual void _close();
111 protected:
113 Connection* m_a = nullptr;
114 Connection* m_b = nullptr;
115 bool m_forward_a_to_b = true;
116 bool m_forward_b_to_a = true;
117 bool m_is_open = false;
118 bool m_request_close = false;
119 };
120}
void setForwardAToB(bool forward)
Enables or disables forwarding data from A to B.
void setAConnectionInfo(const ConnectionInfo &info)
Sets the connection info for endpoint A.
bool m_is_open
Whether the forwarding link is currently active.
bool forwardBToA() const
Checks whether data is being forwarded from B to A.
bool m_forward_b_to_a
Whether to forward data from B to A.
Connection * b() const
Returns the second connection endpoint.
Connection * a() const
Returns the first connection endpoint.
TimeSpan m_update_span
Interval between forwarding updates.
ConnectionForwarding(Connection *a, Connection *b, LogPtr log=nullptr)
Constructs a ConnectionForwarding from two existing Connection pointers.
bool forwardAToB() const
Checks whether data is being forwarded from A to B.
ConnectionForwarding(ConnectionInfo a, ConnectionInfo b, LogPtr log=nullptr)
Constructs a ConnectionForwarding from two connection info objects.
void setUpdateInterval(const TimeSpan &span)
Sets the interval between forwarding updates.
ConnectionForwarding(LogPtr log=nullptr)
Constructs a ConnectionForwarding with no connections.
virtual void update(Time time) override
Performs a single forwarding update, moving data between the two connections.
virtual bool isOpen() const
Checks whether both connections are currently open.
Connection * m_a
The first connection endpoint.
void setBConnectionInfo(const ConnectionInfo &info)
Sets the connection info for endpoint B.
Connection * m_b
The second connection endpoint.
bool m_forward_a_to_b
Whether to forward data from A to B.
void close()
Closes both connections and stops forwarding.
void setForwardBToA(bool forward)
Enables or disables forwarding data from B to A.
TimeSpan updateInterval() const override
Returns the interval between forwarding updates.
virtual void _close()
Internal close implementation that tears down the forwarding link.
bool m_request_close
Whether a close has been requested.
virtual bool open(bool start_forward_thread=true)
Opens both connections and optionally starts a forwarding thread.
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
Definition Connection.h:316
Device(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs a Device from a Model with the given log and optional Qt parent.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
The primary namespace for the NDEVR SDK.
A structure designed to store information about a specific Connection.
Definition Connection.h:90