CDPTransport Class
(CDP::IO::CDPTransport)The CDPTransport is used to transport data over the CDP Messenger protocol, using CM_MESSAGE_RAW messages. More...
Header: | #include <CDPTransport> |
Inherits: | Transport |
Public Functions
CDPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > &readCallbackHandler) | |
virtual void | FillNodeChildren(StudioAPI::NodeStream &serializer) const override |
Reimplemented Public Functions
virtual void | Close() override |
virtual void | Configure(XMLElementEx *transportElement, CDPComponent *owner) override |
virtual std::string | GetNodeTypeName() const override |
virtual double | GetTimeout() const override |
virtual bool | IsError() override |
virtual bool | IsOpen() const override |
virtual bool | Open(Transport::OpenMode mode) override |
virtual unsigned int | Read(char *data, unsigned int length, double timeout = 0.0) override |
virtual unsigned int | Write(const char *data, unsigned int length, double timeout = 0.0) override |
- 12 public functions inherited from CDP::IO::Transport
- 27 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Macros
Additional Inherited Members
- 1 static public member inherited from CDP::IO::Transport
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Detailed Description
The CDPTransport is used to transport data over the CDP Messenger protocol, using CM_MESSAGE_RAW messages.
MessageArguments
Name | Description |
---|---|
Write | The Write message contains the payload to write, formatted as a CM_MESSAGE_RAW message. |
Read | The Read message contains the payload to read, formatted as a CM_MESSAGE_RAW message. |
WriteSuccess | WriteSuccess is used to confirm that the correct amount of data was written. It is typically a loopback from the Write MessageArgument. |
Properties
Name | Description |
---|---|
Timeout | The timeout, in seconds, that the transport will 'block' when lengthy transfers are taking place. Read and Write calls will not return for (at most) this amount of time before returning the number of bytes read or written. |
Usage
Connect Write to a sink that expects CM_MESSAGE_RAW messages, and connect Read and WriteSuccess from sources that provide the read and write feedback as CM_MESSAGE_RAW messages. Set Timeout to a suitable value.
See also Transport.
Member Function Documentation
CDPTransport::CDPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > &readCallbackHandler)
Constructs CDPTransport and sets callbackHandler
[override virtual]
void CDPTransport::Close()
Reimplemented from Transport::Close().
Closes the transport, resets internal state
[override virtual]
void CDPTransport::Configure(XMLElementEx *transportElement, CDPComponent *owner)
[override virtual]
void CDPTransport::FillNodeChildren(StudioAPI::NodeStream &serializer) const
[override virtual]
std::string CDPTransport::GetNodeTypeName() const
Reimplemented from ICDPNode::GetNodeTypeName().
Returns "CDPTransport"
[override virtual]
double CDPTransport::GetTimeout() const
[override virtual]
bool CDPTransport::IsError()
Reimplemented from Transport::IsError().
Returns true if Read and Write MessageArguments are not connected.
[override virtual]
bool CDPTransport::IsOpen() const
Reimplemented from Transport::IsOpen().
Returns true if any of Read or Write MessageArguemtns are connected, and the transport is not closed.
[override virtual]
bool CDPTransport::Open(Transport::OpenMode mode)
Reimplemented from Transport::Open().
Opens the transport and activates underlying MessageArguments
[override virtual]
unsigned int CDPTransport::Read(char *data, unsigned int length, double timeout = 0.0)
Reimplemented from Transport::Read().
Reads length bytes of data from the incoming message(s) within timeout [seconds]. If timeout<=0.0, the timeout from the configuration is used. Returns Number of bytes read.
It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Read will block for how long it takes to read the data, or for timeout seconds, whichever comes first.
As Read() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.
[override virtual]
unsigned int CDPTransport::Write(const char *data, unsigned int length, double timeout = 0.0)
Reimplemented from Transport::Write().
Writes the packet data to the configured MessageArguments. Returns number of bytes written (as received by WriteSuccess).
It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Write will block for up to timeout seconds for the output to be ready before attempting to write the data.
As Write() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.