Codemesh Runtime v3 C++ API Reference  3.9.205
xmog_reply.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 1999-2020 by Codemesh, Inc.. ALL RIGHTS RESERVED.
3 //
4 
5 // -*- C++ -*-
6 
7 //==========================================================================
15 //==========================================================================
16 
17 #ifndef __XMOG_REPLY_H
18 #define __XMOG_REPLY_H
19 
20 class ACE_Message_Block;
21 #include "ace/Basic_Types.h"
22 
23 #include "xmog.h"
24 #include "xmog_util.h"
25 #include "xmog_java_value.h"
26 #include "xmog_message_types.h"
27 
28 class xmog_request;
29 
30 
32 {
33 public:
34 
47  static xmog_reply *decode (ACE_Message_Block *b);
48 
53  typedef enum { SUCCESS = 1, TIMEOUT, COMM_FAILURE } Disposition;
54 
55  enum { INIT_BLOCK_SIZE = 4096 };
56 
66  xmog_reply (Disposition disp,
67  xmog::xmog_message_id t = xmog::NONE,
68  ACE_Message_Block *b = 0);
69  xmog_reply (const xmog_reply &r);
70  xmog_reply &operator= (const xmog_reply &r);
71 
72  virtual ~xmog_reply ();
73 
74  Disposition disposition (void) const;
75 
78  xmog::xmog_message_id type (void) const;
79 
84  virtual bool matches (const xmog_request *req) const;
85 
86  void dump();
87 
88 protected:
89  virtual bool unmarshal (void) { return false; } // Reimplement this
90 
94  int readBoolean( bool &b );
95 
99  int readByte( jbyte &b);
100 
104  int readChar( jchar &c );
105 
109  int readDouble( jdouble &d );
110 
114  int readFloat ( jfloat &f );
115 
121  int readInt( jint &i );
122 
128  int readShort( jshort &s );
129 
135  int readLong( jlong &l );
136 
142  int readClassName( char ** str );
143 
152  int readUTF( char ** str, jint * len = NULL );
153 
162  int readLongUTF( char ** str, jint * len = NULL );
163 
167  int readStringProxy( xmog_remote_java_value & data, xmog::xmog_data_code code );
168 
174  int read_data_code( xmog::xmog_data_code & code );
175 
181  int readData( xmog_remote_java_value & data );
182 
188  int readExc( xmog_remote_java_exception & data );
189 
196 
197 private:
198  xmog_reply () {}; // Must supply at least the type
199 
200  Disposition disp_;
201  xmog::xmog_message_id type_;
202  ACE_Message_Block *b_;
203 };
204 
205 // Now declare the individual reply types, reimplementing anything needed.
206 // All the subtypes need to reimplement unmarshal() since it's pure virtual
207 // in xmog_reply.
208 
210 {
211 public:
212  enum sign_on_status {
213  STATUS_OK = 0,
214  STATUS_NO_NEW_SESSIONS = 1,
215  STATUS_NOT_AUTHORIZED = 2,
216  STATUS_SHUTTING_DOWN = 3,
217  STATUS_UNSUPPORTED_PROTOCOL = 4
218  };
219 
220  xmog_reply_sign_on_status (ACE_Message_Block *b)
221  : xmog_reply (xmog_reply::SUCCESS, xmog::SIGN_ON_STATUS, b) {}
222 
223  sign_on_status status (void) const;
224 
225  jint RemoteStringUtilsId() const;
226 
227  jint ObjectId() const;
228 
229  jint ClassId() const;
230 
231  jint ThrowableId() const;
232 
233  jint ExceptionId() const;
234 
235  jint StringId() const;
236 
237 protected:
238  virtual bool unmarshal (void);
239 
240 private:
241  sign_on_status status_;
242  jint jni_version_;
243  jint clsRemoteStringUtils_;
244  jint clsObject_;
245  jint clsClass_;
246  jint clsThrowable_;
247  jint clsException_;
248  jint clsString_;
249  jbyte required_major_version_;
250 };
251 
252 
254 {
255 public:
256  xmog_reply_thread_id_assignment (ACE_Message_Block *b)
257  : xmog_reply (xmog_reply::SUCCESS, xmog::THREAD_ID_ASSIGNMENT, b) {}
258 
259  jint assigned_thread_id (void) const { return this->assigned_thread_id_; }
260  void *originator (void) const { return this->originator_; }
261  bool matches (const xmog_request *req) const;
262 
263 protected:
264  virtual bool unmarshal (void);
265 
266 private:
267  jint thread_id_;
268  void *originator_;
269  jint assigned_thread_id_;
270 };
271 
272 
274 {
275 public:
276  xmog_reply_member_ids_assignment (ACE_Message_Block *b)
277  : xmog_reply (xmog_reply::SUCCESS, xmog::MEMBER_IDS_ASSIGNMENT, b),
278  memberIds_( 0 ) {}
279 
280  jclass getClassId (void) const { return this->class_id_; }
281  jsize getNumMembers() const { return this->numMembers_; }
282  jint getMemberId( size_t index ) const { return memberIds_[ index ]; }
283  void *originator (void) const { return this->originator_; }
284  bool matches (const xmog_request *req) const;
285 
287 
288 protected:
289  virtual bool unmarshal (void);
290 
291 private:
292  void *originator_;
293  jclass class_id_;
294  jsize numMembers_;
295  jint * memberIds_;
296 };
297 
298 
300 {
301  jint id_;
302  char * name_;
303  jint super_;
304  jsize numIfcs_;
305  jint * ifcs_;
306 
307  class_info( const class_info & );
308  class_info & operator = ( const class_info & );
309 
310 public:
311 
312  class_info() : name_( 0 ), ifcs_( 0 ) {}
313  ~class_info() { if( ifcs_ ) delete ifcs_; xmog_util::setString( name_, 0 ); }
314  void set_class( jint id ) { id_ = id; }
315  jint get_class() const { return id_; }
316  void set_class_name( char * name ) { xmog_util::setString( name_, name ); }
317  char * get_class_name() const { return name_; }
318  void set_super( jint id ) { super_ = id; }
319  jint get_super() const { return super_; }
320  void set_num_ifcs( jint num ) { numIfcs_ = num; ifcs_ = new jint[ numIfcs_ ]; }
321  jsize get_num_ifcs() const { return numIfcs_; }
322  void set_ifc( int index, jint id ) { ifcs_[ index ] = id; }
323  jint get_ifc( int index ) const { return ifcs_[ index ]; }
324 
325 };
326 
327 
329 {
330 public:
331  xmog_reply_class_info (ACE_Message_Block *b)
332  : xmog_reply (xmog_reply::SUCCESS, xmog::CLASS_INFO_RESPONSE, b),
333  infos_( 0 ) {}
334 
335  jsize getNumInfos() const { return this->numInfos_; }
336  class_info & getInfo( size_t index ) const { return infos_[ index ]; }
337  void *originator (void) const { return this->originator_; }
338  bool matches (const xmog_request *req) const;
339 
341 
342 protected:
343  virtual bool unmarshal (void);
344 
345 private:
346  void *originator_;
347  jsize numInfos_;
348  class_info * infos_;
349 };
350 
352 {
353 public:
354  xmog_reply_field_get( ACE_Message_Block *b )
355  : xmog_reply (xmog_reply::SUCCESS, xmog::GET_FIELD_RESPONSE, b) {}
356 
357  void * originator (void) const { return this->originator_; }
358  xmog_remote_java_value & getData() { return data_; }
359  const xmog_remote_java_exception & getExc() const { return exc_; }
360  jlong getException() const { return (jlong)exc_.exc_; }
361  bool matches (const xmog_request *req) const;
362 
363 protected:
364  virtual bool unmarshal (void);
365 
366 private:
367  jint thread_id_;
368  void *originator_;
371 };
372 
373 
375 {
376 public:
377  xmog_reply_field_set( ACE_Message_Block *b )
378  : xmog_reply (xmog_reply::SUCCESS, xmog::SET_FIELD_RESPONSE, b) {}
379 
380  void * originator (void) const { return this->originator_; }
381  jlong getException() const { return (jlong)exc_.exc_; }
382  const xmog_remote_java_exception & getExc() const { return exc_; }
383  bool matches (const xmog_request *req) const;
384 
385 protected:
386  virtual bool unmarshal (void);
387 
388 private:
389  jint thread_id_;
390  void *originator_;
393 };
394 
395 
397 {
398 public:
399  xmog_reply_method_call( ACE_Message_Block *b )
400  : xmog_reply (xmog_reply::SUCCESS, xmog::METHOD_RETURN, b) {}
401 
402  jint thread_id() const { return thread_id_; }
403  void * originator (void) const { return this->originator_; }
404  xmog_remote_java_value & getData() { return data_; }
405  const xmog_remote_java_exception & getExc() const { return exc_; }
406  jlong getException() const { return (jlong)exc_.exc_; }
407  bool matches (const xmog_request *req) const;
408 
409 protected:
410  virtual bool unmarshal (void);
411 
412 private:
413  jint thread_id_;
414  void *originator_;
417 };
418 
419 
421 {
422 public:
423  xmog_reply_ctor_call( ACE_Message_Block *b )
424  : xmog_reply (xmog_reply::SUCCESS, xmog::CONSTRUCTOR_RETURN, b) {}
425 
426  jint thread_id() const { return thread_id_; }
427  void * originator (void) const { return this->originator_; }
428  const xmog_remote_java_value & getData() const { return data_; }
429  const xmog_remote_java_exception & getExc() const { return exc_; }
430  jlong getException() const { return (jlong)exc_.exc_; }
431  bool matches (const xmog_request *req) const;
432 
433 protected:
434  virtual bool unmarshal (void);
435 
436 private:
437  jint thread_id_;
438  void *originator_;
441 };
442 
443 #endif /* __XMOG_REPLY_H */
xmog_util::setString
static char * setString(char *&strVar, const char *value, size_t len=(size_t) -1)
Sets a string to another string after cleaning up the previous string.
xmog_reply_member_ids_assignment
Definition: xmog_reply.h:273
xmog_reply::readInt
int readInt(jint &i)
Reads a 32bit integer from the message.
xmog_reply_thread_id_assignment::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply_ctor_call::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply::readBoolean
int readBoolean(bool &b)
Reads a bool from the message.
xmog_request
Represents a request communicated between client and server.
Definition: xmog_request.h:50
xmog_reply::Disposition
Disposition
The Disposition indicates whether the requested operation was even carried out. If not SUCCESS,...
Definition: xmog_reply.h:53
xmog_reply::readByte
int readByte(jbyte &b)
Reads a byte from the message.
xmog_remote_java_value
A helper type used to convey remote Java arguments around.
Definition: xmog_java_value.h:20
xmog_reply_class_info
Definition: xmog_reply.h:328
xmog_reply::decode
static xmog_reply * decode(ACE_Message_Block *b)
Factory function that decodes an incoming reply and creates a xmog_reply-descended reply object.
xmog_reply_method_call::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply::readFloat
int readFloat(jfloat &f)
Reads a jfloat from the message.
xmog_reply::readDouble
int readDouble(jdouble &d)
Reads a jdouble from the message.
xmog_reply::readStringProxy
int readStringProxy(xmog_remote_java_value &data, xmog::xmog_data_code code)
Reads a string proxy from the message.
xmog_reply::readChar
int readChar(jchar &c)
Reads a jchar from the message.
xmog_reply_field_set::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply::readUTF
int readUTF(char **str, jint *len=NULL)
Reads a UTF string from the message.
xmog_reply::read_data_code
int read_data_code(xmog::xmog_data_code &code)
Reads a data code.
xmog::xmog_message_id
xmog_message_id
The message types that are used in the framework.
Definition: xmog_message_types.h:26
xmog_message_types.h
xmog_remote_java_exception
A utility class used to hold on to exceptions thrown on the other side.
Definition: xmog_java_value.h:68
xmog_reply::matches
virtual bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
class_info
Definition: xmog_reply.h:299
xmog_reply_class_info::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply_ctor_call
Definition: xmog_reply.h:420
xmog_reply_thread_id_assignment
Definition: xmog_reply.h:253
xmog_reply_field_get
Definition: xmog_reply.h:351
xmog_reply_sign_on_status
Definition: xmog_reply.h:209
xmog_reply_field_set
Definition: xmog_reply.h:374
xmog_reply::readLongUTF
int readLongUTF(char **str, jint *len=NULL)
Reads a long UTF string from the message.
xmog_reply::readShort
int readShort(jshort &s)
Reads a 16bit integer from the message.
xmog_reply
Definition: xmog_reply.h:31
xmog_reply::readData
int readData(xmog_remote_java_value &data)
Reads a data object from the message.
xmog_reply::type
xmog::xmog_message_id type(void) const
type() returns the message reply type. If the disposition is not SUCCESS, this value is meaningless.
xmog_reply::readClassName
int readClassName(char **str)
Reads a UTF string from the message.
xmog_reply::readExc
int readExc(xmog_remote_java_exception &data)
Reads an exception from the message.
xmog_reply::readDataProxy
int readDataProxy(xmog_remote_java_value &data)
Reads a data proxy object from the message.
xmog_reply_member_ids_assignment::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply_field_get::matches
bool matches(const xmog_request *req) const
Check to see if the specified xmog_request matches this xmog_reply. The reply type needs to match the...
xmog_reply_method_call
Definition: xmog_reply.h:396
xmog_reply::readLong
int readLong(jlong &l)
Reads a 64-bit integer from the message.

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.