Codemesh Runtime v3 C++ API Reference  3.9.205
Public Types | Public Member Functions | Protected Attributes | List of all members
xmog_request Class Reference

Represents a request communicated between client and server. More...

#include <xmog_request.h>

Inheritance diagram for xmog_request:
Inheritance graph
[legend]

Public Types

enum  { INIT_BLOCK_SIZE = 4096 }
 

Public Member Functions

 xmog_request (xmog::xmog_message_id reqtype, const void *orig=0, bool reply_expected=true)
 
void dump ()
 
xmog::xmog_message_id type (void) const
 
ACE_Future< xmog_reply * > & reply (void)
 
ACE_Message_Block * block (void) const
 
const void * originator (void) const
 
void expires (const ACE_Time_Value &expiration)
 
bool expired (const ACE_Time_Value &now) const
 
void complete (xmog_reply *reply)
 
bool reply_expected (void) const
 
int writeBoolean (bool b)
 Appends a bool to the message.
 
int writeByte (jbyte b)
 Appends a byte to the message.
 
int writeChar (jchar c)
 Appends a jchar to the message.
 
int writeDouble (jdouble d)
 Appends a jdouble to the message.
 
int writeFloat (jfloat d)
 Appends a jfloat to the message.
 
int writeInt (jint i)
 Appends a 32bit integer to the message. More...
 
int writeShort (jshort s)
 Appends a 16bit integer to the message. More...
 
int writeLong (jlong l)
 Appends a 64-bit integer to the message. More...
 
int writeDataCode (xmog::xmog_data_code code, int align=4)
 Appends a data code with optional padding. More...
 
int writeDataBoolean (bool b)
 
int writeDataByte (jbyte b)
 
int writeDataChar (jchar ch)
 
int writeDataDouble (jdouble d)
 
int writeDataFloat (jfloat f)
 
int writeDataInt (jint i)
 
int writeDataLong (jlong l)
 
int writeDataShort (jshort s)
 
int writeDataNull (int align)
 
int writeDataProxy (xmog_base *obj, int align, xmog_localenv *env=NULL)
 
int writeEncodedDataString (xmog_remote_java_value &data)
 Appends an encoded string to the message.
 
int writeDataStringUtf (const char *str, size_t len=(size_t) -1)
 Appends a UTF-8 encoded string to the message. More...
 
int writeDataStringUtf16 (const unsigned short *str, size_t len=(size_t) -1)
 Appends a UTF-16 encoded string to the message. More...
 
int writeString (const char *str, size_t len=(size_t) -1)
 Appends a platform string to the message. More...
 
int writeString (const XMOG_WCHAR *str, size_t len=(size_t) -1)
 Appends a wide string to the message. More...
 
int writeUTF (const char *utf, size_t len=(size_t) -1)
 Appends a UTF string to the message. More...
 
int writeParameter (const xmog_remote_java_value &val, int align, int &cbAdded)
 Writes a parameter to the message. More...
 

Protected Attributes

ACE_Message_Block * block_
 

Detailed Description

Represents a request communicated between client and server.

xmog_request allows formation of a request message. Can add information to the message and obtain a ACE_Message_Block pointer for a block containing the formed message for transmission.

Note
This class is intended as a base for more specific messaeg type classes only. It should not be used directly.

Constructor & Destructor Documentation

◆ xmog_request()

xmog_request::xmog_request ( xmog::xmog_message_id  reqtype,
const void *  orig = 0,
bool  reply_expected = true 
)
explicit

Constructor. Specifies the message request type and the originating party as a pointer that can be matched up with the reply later. Also can specify whether or not the message being formed expects a reply from the peer.

Member Function Documentation

◆ block()

ACE_Message_Block* xmog_request::block ( void  ) const

Obtain a pointer to an ACE_Message_Block containing the formed message. The caller is responsible for ensuring that the block is released when no longer needed.

Return values
ACE_Message_Blockpointer for a block containing the formed message. 0 on failure.

◆ complete()

void xmog_request::complete ( xmog_reply reply)

Finalize this request with the specified xmog_reply. Sets the enclosed ACE_Future from which the initiator will get the reply.

Parameters
replyxmog_reply reference to set the reply from. Any needed content is copied, and the reply can be safely deleted upon return.

◆ expired()

bool xmog_request::expired ( const ACE_Time_Value &  now) const

Check to see if the request has timed out (expired).

Parameters
nowThe current time of day. If this request's expiration is the same or earlier than now, returns true.

◆ expires()

void xmog_request::expires ( const ACE_Time_Value &  expiration)

Set the request's expiration time. This is an absolute time in the future. This object does not act on the time value. It can be checked for expiration by calling the expired() method with the current time.

◆ originator()

const void* xmog_request::originator ( void  ) const

Obtain the originating party's pointer.

◆ reply()

ACE_Future<xmog_reply*>& xmog_request::reply ( void  )

Obtain a reference to the ACE_Future that represents this request's completion. Requester can wait on this future or insert it in a ACE_Future_Observer. Since it's a reference to the ACE_Future contained within this request, it's only valid as long as this request object. Note that if this request was created with reply_expected == false, this method will throw xmog_exception_impl.

◆ reply_expected()

bool xmog_request::reply_expected ( void  ) const

Check to see whether or not this xmog_request expects a reply from the peer.

Return values
trueif a reply is expected, else false.

◆ writeDataCode()

int xmog_request::writeDataCode ( xmog::xmog_data_code  code,
int  align = 4 
)

Appends a data code with optional padding.

Parameters
codea data code.
alignthe alignment for the next data element

◆ writeDataStringUtf()

int xmog_request::writeDataStringUtf ( const char *  str,
size_t  len = (size_t) -1 
)

Appends a UTF-8 encoded string to the message.

This is the UTF-8 encoding message for user strings. See writeUTF() for internal UTF-8 strings.

Parameters
stra string in utf8 encoding.
lenthe optional number of characters to encode. The default is -1, which stands for all characters.

◆ writeDataStringUtf16()

int xmog_request::writeDataStringUtf16 ( const unsigned short *  str,
size_t  len = (size_t) -1 
)

Appends a UTF-16 encoded string to the message.

This is the UTF-16 encoding message for user strings.

Parameters
stra string in utf16 encoding.
lenthe optional number of characters to encode. The default is -1, which stands for all characters.

◆ writeInt()

int xmog_request::writeInt ( jint  i)

Appends a 32bit integer to the message.

This method converts the number from host to network order.

◆ writeLong()

int xmog_request::writeLong ( jlong  l)

Appends a 64-bit integer to the message.

This method converts the number from host to network order.

◆ writeParameter()

int xmog_request::writeParameter ( const xmog_remote_java_value val,
int  align,
int &  cbAdded 
)

Writes a parameter to the message.

This does not update any message fields that track counts and positions; Use the returned cbAdded value to do this in the caller.

◆ writeShort()

int xmog_request::writeShort ( jshort  s)

Appends a 16bit integer to the message.

This method converts the number from host to network order.

◆ writeString() [1/2]

int xmog_request::writeString ( const char *  str,
size_t  len = (size_t) -1 
)

Appends a platform string to the message.

This method converts the platform string to UTF before appending it to the message.

Parameters
stra string in platform encoding.
lenthe optional number of characters to encode. The default is -1, which stands for all characters.

◆ writeString() [2/2]

int xmog_request::writeString ( const XMOG_WCHAR *  str,
size_t  len = (size_t) -1 
)

Appends a wide string to the message.

This method converts the wide string to UTF before appending it to the message.

Parameters
stra string in platform encoding.
lenthe optional number of characters to encode. The default is -1, which stands for all characters. Notice that the argument is the number of characters, not the number of bytes.

◆ writeUTF()

int xmog_request::writeUTF ( const char *  utf,
size_t  len = (size_t) -1 
)

Appends a UTF string to the message.

This method is different from writeStringUtf() because it is not meant for user data, but only for internal strings like method names, etc.

Parameters
stra string in UTF encoding. In many cases, developers can directly use this method, which is much faster than the corresponding writeString() methods because no conversion has to be performed.
lenthe optional number of characters to encode. The default is -1, which stands for all characters.

The documentation for this class was generated from the following file:

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