rasdaman complete source
rnpembedded.hh
Go to the documentation of this file.
1 #ifndef RNPEMBEDDED_HH
2 #define RNPEMBEDDED_HH
3 /*
4 * This file is part of rasdaman community.
5 *
6 * Rasdaman community is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Rasdaman community is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
20 rasdaman GmbH.
21 *
22 * For more information please see <http://www.rasdaman.org>
23 * or contact Peter Baumann via <baumann@rasdaman.com>.
24 */
25 /****************************************************************************
26  *
27  *
28  * COMMENTS:
29  *
30  *
31  ****************************************************************************/
32 #include "rnprotocol/rnprotocol.hh"
33 
34 namespace rnp
35 {
36 
50 {
51 public:
53  {
58  //....
60  };
61 
62  static const char* getCarrierName(CarrierProtocol) throw();
63 private:
64  static const char* carrierNames[];
65 };
66 
83 {
84 public:
86  RnpReceiver() throw();
87 
89  ~RnpReceiver() throw();
90 
92  void reset() throw();
93 
95  akg::CommBuffer* getCurrentBuffer() throw();
96 
99  akg::CommBuffer* getMessageBuffer() throw();
100 
102  bool validateMessage() throw();
103 
106  bool isDiscarding() const throw();
107 
109  RnpTransport::CarrierProtocol getCarrierProtocol() const throw();
110 
112  int getCarrierHeaderSize() const throw();
113 
115  const void* getCarrierHeader() throw();
116 
117 private:
118 
119  enum Status
120  {
121  waitingHeader,
122  readingMessage,
123  discarding
124  };
125 
126 
127  Status status;
128 
129  akg::CommBuffer headerBuffer;
130  akg::CommBuffer rnpMessageBuffer;
131 
132  RnpHeader *rnpHeader;
133 
135  int carrierHeaderLength;
136 
137  static const int headerBufferLength;
138 
139  bool isHttpCarrier() throw();
140  bool isRnpCarrier() throw();
141  bool prepareMessageBuffer() throw();
142 
143 };
144 
145 class RnpCarrier;
146 
156 {
157 public:
159  RnpTransmitter() throw();
160 
162  ~RnpTransmitter() throw();
163 
165  bool startRequest(RnpQuark serverType, RnpTransport::CarrierProtocol) throw();
166 
168  bool startAnswer(RnpQuark serverType, RnpTransport::CarrierProtocol) throw();
169 
171  akg::CommBuffer* endMessage() throw();
172 
174  RnpTransport::CarrierProtocol getCarrierProtocol() throw();
175 
177  int getBufferSize() const throw();
178 
180  int getNotFilledSize() const throw();
181 
183  int getDataSize() const throw();
184 private:
185 
186  RnpTransport::CarrierProtocol carrierType;
187 
192  RnpCarrier* getCarrierObject(RnpTransport::CarrierProtocol) throw();
193  RnpCarrier* carrier;
194 };
195 
203 {
204 public:
206  RnpCarrier() throw();
207 
209  virtual ~RnpCarrier() throw();
210 
212  RnpTransport::CarrierProtocol getType() throw();
213 
215  virtual int getRequestHeaderLength() throw();
216 
218  virtual int getAnswerHeaderLength() throw();
219 
222  virtual void putHeader(akg::CommBuffer*) throw();
223 
224 protected:
227 
230 
231 };
232 
240 {
241 public:
243  HttpRnpCarrier() throw();
244 
246  int getRequestHeaderLength() throw();
247 
249  int getAnswerHeaderLength() throw();
250 
252  void putHeader(akg::CommBuffer*) throw();
253 
254 private:
255  static const char theRequestHeader[];
256  static const char theAnswerHeader[];
257 };
258 
265 class BadRnpCarrier : public RnpCarrier
266 {
267 public:
268  BadRnpCarrier() throw();
269 
270  int getRequestHeaderLength() throw();
271  int getAnswerHeaderLength() throw();
272  void putHeader(akg::CommBuffer*) throw();
273 
274 private:
275  static const char theHeader[];
276 };
277 
278 } //namespace
279 #endif
RnpTransport::CarrierProtocol type
The type of the carrier.
Definition: rnpembedded.hh:226
Definition: rnpembedded.hh:155
Definition: rnpembedded.hh:57
Definition: rnpembedded.hh:59
int RnpQuark
The basic type used in RNP. It is always 32-bit long.
Definition: rnprotocol.hh:51
Definition: rnprotocol.hh:264
Definition: rnpembedded.hh:49
Definition: rnpembedded.hh:55
Definition: rnpembedded.hh:265
Definition: rnpembedded.hh:82
Definition: rnpcommunication.hh:44
Definition: rnpembedded.hh:202
Definition: rnprotocol.hh:153
CarrierProtocol
Definition: rnpembedded.hh:52
Definition: rnpembedded.hh:54
Definition: rnpembedded.hh:239
Definition: rnpembedded.hh:56
bool requestHeader
Flag for 'putHeader' to know which header to write.
Definition: rnpembedded.hh:229
static const char * getCarrierName(CarrierProtocol)
Definition: akgnet_commbuffer.hh:57