Debian Codegraph @

gobi-api/Gobi_2012-06-18-1054/Core/Connection.h

raw
1 /*===========================================================================
2 FILE:
3 Connection.h
4
5 DESCRIPTION:
6 Declaration of cConnection class
7
8 PUBLIC CLASSES AND METHODS:
9 cComm
10 This class defines a prototype for low level communications
11
12 Copyright (c) 2012, Code Aurora Forum. All rights reserved.
13
14 Redistribution and use in source and binary forms, with or without
15 modification, are permitted provided that the following conditions are met:
16 * Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 * Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21 * Neither the name of Code Aurora Forum nor
22 the names of its contributors may be used to endorse or promote
23 products derived from this software without specific prior written
24 permission.
25
26
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 POSSIBILITY OF SUCH DAMAGE.
38 ===========================================================================*/
39
40 //---------------------------------------------------------------------------
41 // Include Files
42 //---------------------------------------------------------------------------
43 #include "Event.h"
44
45 //---------------------------------------------------------------------------
46 // Pragmas
47 //---------------------------------------------------------------------------
48 #pragma once
49
50 /*=========================================================================*/
51 // Class cIOCallback
52 /*=========================================================================*/
53 class cIOCallback
54 {
55 public:
56 // (Inline) Constructor
57 cIOCallback() { };
58
59 // (Inline) Destructor
60 virtual ~cIOCallback() { };
61
62 // The I/O has been completed, process the results
63 virtual void IOComplete(
64 DWORD status,
65 DWORD bytesTransferred ) = 0;
66 };
67
68 /*=========================================================================*/
69 // Class cConnection
70 /*=========================================================================*/
71 class cConnection
72 {
73 public:
74 // Constructor
75 cConnection()
76 : mpRxCallback( 0 )
77 { };
78
79 // Is this object valid?
80 virtual bool IsValid()
81 {
82 return false;
83 };
84
85 // Connect to the specified interface
86 virtual bool Connect( LPCSTR pPort )
87 {
88 return false;
89 };
90
91 // Send a control message
92 virtual int SendCtl(
93 UINT type,
94 void * pData )
95 {
96 return -1;
97 };
98
99 // Disconnect from the current port
100 virtual bool Disconnect()
101 {
102 return false;
103 };
104
105 // Cancel any in-progress I/O
106 virtual bool CancelIO()
107 {
108 return false;
109 };
110
111 // Cancel any in-progress receive operation
112 virtual bool CancelRx()
113 {
114 return false;
115 };
116
117 // Cancel any in-progress transmit operation
118 virtual bool CancelTx()
119 {
120 return false;
121 };
122
123 // Receive data
124 virtual bool RxData(
125 BYTE * pBuf,
126 ULONG bufSz,
127 cIOCallback * pCallback )
128 {
129 return false;
130 };
131
132 // Transmit data
133 virtual bool TxData(
134 const BYTE * pBuf,
135 ULONG bufSz )
136 {
137 return false;
138 };
139
140 // Are we currently connected to a port?
141 virtual bool IsConnected()
142 {
143 return false;
144 };
145
146 protected:
147 /* Read callbacks */
148 cIOCallback * mpRxCallback;
149 };