TPDU: don't use exceptions
[bcusdk.git] / eibd / libserver / tpdu.h
blob8f651dd32450df65320baaa5ed805821f967a2f7
1 /*
2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2008 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef TPDU_H
21 #define TPDU_H
23 #include "common.h"
25 /** enumaration of TPDU types */
26 typedef enum
28 /** unknown TPDU */
29 T_UNKNOWN,
30 /** any connectionless TPDU */
31 T_DATA_XXX_REQ,
32 /** connectionoriented TPDU */
33 T_DATA_CONNECTED_REQ,
34 /** T_Connect */
35 T_CONNECT_REQ,
36 /** T_Disconnect */
37 T_DISCONNECT_REQ,
38 /** T_ACK */
39 T_ACK,
40 /** T_NACK */
41 T_NACK,
43 TPDU_Type;
45 /** represents a TPDU */
46 class TPDU
48 public:
49 virtual ~ TPDU ()
53 virtual bool init (const CArray & c) = 0;
54 /** convert to character array */
55 virtual CArray ToPacket () = 0;
56 /** decode content as string */
57 virtual String Decode () = 0;
58 /** gets TPDU type */
59 virtual TPDU_Type getType () const = 0;
60 /** converts character array to a TPDU */
61 static TPDU *fromPacket (const CArray & c);
64 class T_UNKNOWN_PDU:public TPDU
66 public:
67 CArray pdu;
69 T_UNKNOWN_PDU ();
70 bool init (const CArray & c);
71 CArray ToPacket ();
72 String Decode ();
73 TPDU_Type getType () const
75 return T_UNKNOWN;
78 class T_DATA_XXX_REQ_PDU:public TPDU
80 public:
81 CArray data;
83 T_DATA_XXX_REQ_PDU ();
84 bool init (const CArray & c);
85 CArray ToPacket ();
86 String Decode ();
87 TPDU_Type getType () const
89 return T_DATA_XXX_REQ;
92 class T_DATA_CONNECTED_REQ_PDU:public TPDU
94 public:
95 uchar serno;
96 CArray data;
98 T_DATA_CONNECTED_REQ_PDU ();
99 bool init (const CArray & c);
100 CArray ToPacket ();
101 String Decode ();
102 TPDU_Type getType () const
104 return T_DATA_CONNECTED_REQ;
107 class T_CONNECT_REQ_PDU:public TPDU
109 public:
111 T_CONNECT_REQ_PDU ();
112 bool init (const CArray & c);
113 CArray ToPacket ();
114 String Decode ();
115 TPDU_Type getType () const
117 return T_CONNECT_REQ;
120 class T_DISCONNECT_REQ_PDU:public TPDU
122 public:
124 T_DISCONNECT_REQ_PDU ();
125 bool init (const CArray & c);
126 CArray ToPacket ();
127 String Decode ();
128 TPDU_Type getType () const
130 return T_DISCONNECT_REQ;
133 class T_ACK_PDU:public TPDU
135 public:
136 uchar serno;
138 T_ACK_PDU ();
139 bool init (const CArray & c);
140 CArray ToPacket ();
141 String Decode ();
142 TPDU_Type getType () const
144 return T_ACK;
147 class T_NACK_PDU:public TPDU
149 public:
150 uchar serno;
152 T_NACK_PDU ();
153 bool init (const CArray & c);
154 CArray ToPacket ();
155 String Decode ();
156 TPDU_Type getType () const
158 return T_NACK;
162 #endif