Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / Core / NptSerialPort.h
blobb543c112c65c51f9c43640da7c866e78e2571032
1 /*****************************************************************
3 | Neptune - Serial Ports
5 | Copyright (c) 2002-2008, Axiomatic Systems, LLC.
6 | All rights reserved.
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of Axiomatic Systems nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
19 | THIS SOFTWARE IS PROVIDED BY AXIOMATIC SYSTEMS ''AS IS'' AND ANY
20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL AXIOMATIC SYSTEMS BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 ****************************************************************/
32 #ifndef _NPT_SERIAL_PORT_H_
33 #define _NPT_SERIAL_PORT_H_
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "NptTypes.h"
39 #include "NptStreams.h"
41 /*----------------------------------------------------------------------
42 | constants
43 +---------------------------------------------------------------------*/
44 const int NPT_ERROR_NO_SUCH_SERIAL_PORT = NPT_ERROR_BASE_SERIAL_PORT - 0;
45 const int NPT_ERROR_SERIAL_PORT_NOT_OPEN = NPT_ERROR_BASE_SERIAL_PORT - 1;
46 const int NPT_ERROR_SERIAL_PORT_ALREADY_OPEN = NPT_ERROR_BASE_SERIAL_PORT - 2;
47 const int NPT_ERROR_SERIAL_PORT_BUSY = NPT_ERROR_BASE_SERIAL_PORT - 3;
49 typedef enum {
50 NPT_SERIAL_PORT_PARITY_NONE,
51 NPT_SERIAL_PORT_PARITY_EVEN,
52 NPT_SERIAL_PORT_PARITY_ODD,
53 NPT_SERIAL_PORT_PARITY_MARK
54 } NPT_SerialPortParity;
56 typedef enum {
57 NPT_SERIAL_PORT_STOP_BITS_1,
58 NPT_SERIAL_PORT_STOP_BITS_1_5,
59 NPT_SERIAL_PORT_STOP_BITS_2
60 } NPT_SerialPortStopBits;
62 typedef enum {
63 NPT_SERIAL_PORT_FLOW_CONTROL_NONE,
64 NPT_SERIAL_PORT_FLOW_CONTROL_HARDWARE,
65 NPT_SERIAL_PORT_FLOW_CONTROL_XON_XOFF
66 } NPT_SerialPortFlowControl;
68 /*----------------------------------------------------------------------
69 | NPT_SerialPortInterface
70 +---------------------------------------------------------------------*/
71 class NPT_SerialPortInterface
73 public:
74 // constructors and destructor
75 virtual ~NPT_SerialPortInterface() {}
77 // methods
78 virtual NPT_Result Open(unsigned int speed,
79 NPT_SerialPortStopBits stop_bits,
80 NPT_SerialPortFlowControl flow_control,
81 NPT_SerialPortParity parity) = 0;
82 virtual NPT_Result Close() = 0;
83 virtual NPT_Result GetInputStream(NPT_InputStreamReference& stream) = 0;
84 virtual NPT_Result GetOutputStream(NPT_OutputStreamReference& stream) = 0;
87 /*----------------------------------------------------------------------
88 | NPT_SerialPort
89 +---------------------------------------------------------------------*/
90 class NPT_SerialPort : public NPT_SerialPortInterface
92 public:
93 // constructors and destructor
94 NPT_SerialPort(const char* name);
95 ~NPT_SerialPort() override { delete m_Delegate; }
97 // NPT_SerialPortInterface methods
98 NPT_Result Open(unsigned int speed,
99 NPT_SerialPortStopBits stop_bits = NPT_SERIAL_PORT_STOP_BITS_1,
100 NPT_SerialPortFlowControl flow_control = NPT_SERIAL_PORT_FLOW_CONTROL_NONE,
101 NPT_SerialPortParity parity = NPT_SERIAL_PORT_PARITY_NONE) override {
102 return m_Delegate->Open(speed, stop_bits, flow_control, parity);
104 NPT_Result Close() override {
105 return m_Delegate->Close();
107 NPT_Result GetInputStream(NPT_InputStreamReference& stream) override {
108 return m_Delegate->GetInputStream(stream);
110 NPT_Result GetOutputStream(NPT_OutputStreamReference& stream) override {
111 return m_Delegate->GetOutputStream(stream);
114 protected:
115 // members
116 NPT_SerialPortInterface* m_Delegate;
119 #endif // _NPT_SERIAL_PORT_H_