NDEVR
API Documentation
SocketIODriver.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Hardware
28File: SocketIODriver
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <QIODevice>
35#include <NDEVR/Connection.h>
36#include <NDEVR/SocketIOChannel.h>
37#include "Base/Headers/Buffer.hpp"
38#include "Base/Headers/Dictionary.h"
39#include "Base/Headers/Pointer.hpp"
40
41namespace NDEVR
42{
43 class TimeSpan;
44 class SocketIOChannel;
50 class SOCKET_IO_API SocketIODriver : public ConnectionBackend
51 {
52 public:
56 SocketIODriver(InfoPipe* log = nullptr);
61 SocketIODriver(DynamicPointer<SocketIOChannel> socket, InfoPipe* log = nullptr);
62 ~SocketIODriver() = default;
63 SocketIODriver(const SocketIODriver& other) = delete;
64 SocketIODriver(SocketIODriver&& other) = delete;
65 SocketIODriver& operator=(const SocketIODriver& other) = delete;
66 SocketIODriver& operator=(SocketIODriver&& other) = delete;
67
73 virtual uint04 peek(char* s, uint04 size = Constant<uint04>::Max) const override;
79 virtual uint04 rx(char* s, uint04 max_size = Constant<uint04>::Max) override;
83 virtual void tx(const StringView& command) override;
88 virtual bool open(const ConnectionInfo& request) override;
90 virtual void close() override;
94 virtual bool isOpen() const override;
99 virtual bool waitForReadyRead(const TimeSpan& span) override;
103 virtual TranslatedString lastError() const override;
107 virtual uint04 bytesAvailable() const override;
108 private:
109 DynamicPointer<SocketIOChannel> m_socket;
110 QByteArray m_channel_write_buffer;
111 QByteArray m_channel_read_buffer;
112 Dictionary<int, unsigned int> m_received_bytes;
113 std::mutex m_critical_section;
114 bool m_is_open = false;
115 };
121 {
122 public:
127 virtual bool handlesType(const StringView& request) const override;
132 virtual ConnectionBackend* createConnection(const ConnectionInfo& request) override;
142 };
143}
144
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type...
Definition Connection.h:169
Stores factories that can be registered for creating Connections of various types by instantiating a ...
Definition Connection.h:250
A specific channel of communication within the SocketIO framework.
A ConnectionBackend that allows the software to interface with SocketIO for communicating with across...
virtual Buffer< ConnectionInfo > availableConnections(const ConnectionSearchParameters &params) override
Enumerates available SocketIO connections matching the search parameters.
virtual ConnectionBackend * createConnection(const ConnectionInfo &request) override
Creates a new SocketIODriver connection backend.
virtual bool handlesType(const StringView &request) const override
Checks whether this factory handles the given connection type.
virtual Buffer< ConnectionCategory > availableConnectionCategories() override
Gets the categories of connections this factory provides.
The core String View class for the NDEVR API.
Definition StringView.h:58
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
A structure designed to store information about a specific Connection.
Definition Connection.h:90
Describes settings for performing a Connection search.
Definition Connection.h:149