NAME
ACE_Message_Block -
Object used to store messages in the ASX framework.
SYNOPSIS
#include <ace/Message_Block.h>
class ACE_Message_Block
{
public:
enum ACE_Message_Type{ MB_DATA = 0x01,
MB_PROTO = 0x02,
MB_BREAK = 0x03,
MB_PASSFP = 0x04,
MB_EVENT = 0x05,
MB_SIG = 0x06,
MB_IOCTL = 0x07,
MB_SETOPTS = 0x08,
MB_IOCACK = 0x81,
MB_IOCNAK = 0x82,
MB_PCPROTO = 0x83,
MB_PCSIG = 0x84,
MB_READ = 0x85,
MB_FLUSH = 0x86,
MB_STOP = 0x87,
MB_START = 0x88,
MB_HANGUP = 0x89,
MB_ERROR = 0x8a,
MB_PCEVENT = 0x8b,
MB_NORMAL = 0x00,
MB_PRIORITY = 0x80,
MB_USER = 0x200 };
typedef u_long Message_Flags;
enum{ DONT_DELETE = 01, USER_FLAGS = 0x1000 };
ACE_Message_Block (void);
ACE_Message_Block (const char *data, size_t size = 0);
ACE_Message_Block (
size_t size,
ACE_Message_Type type = MB_DATA,
ACE_Message_Block *cont = 0,
const char *data = 0,
ACE_Allocator *allocator = 0
);
int init (const char *data, size_t size = 0);
int init (
size_t size,
ACE_Message_Type type = MB_DATA,
ACE_Message_Block *cont = 0,
const char *data = 0,
ACE_Allocator *allocator = 0
);
~ACE_Message_Block (void);
int is_data_msg (void) const;
ACE_Message_Type msg_class (void) const;
ACE_Message_Type msg_type (void) const;
Message_Flags set_flags (Message_Flags more_flags);
Message_Flags clr_flags (Message_Flags less_flags);
Message_Flags flags (void) const;
void msg_type (ACE_Message_Type type);
u_long msg_priority (void) const;
void msg_priority (u_long priority);
ACE_Message_Block *clone (
Message_Flags mask = ACE_Message_Block::DONT_DELETE
) const;
int copy (const char *buf, size_t n);
char *base (void) const;
void base (char *data, size_t size, Message_Flags = DONT_DELETE);
char *end (void) const;
char *rd_ptr (void);
void rd_ptr (char *ptr);
void rd_ptr (size_t n);
char *wr_ptr (void);
void wr_ptr (char *ptr);
void wr_ptr (size_t n);
size_t length (void) const;
void length (size_t n);
size_t size (void) const;
int size (size_t length);
ACE_Message_Block *cont (void) const;
void cont (ACE_Message_Block *);
ACE_Message_Block *next (void) const;
void next (ACE_Message_Block *);
ACE_Message_Block *prev (void) const;
void prev (ACE_Message_Block *);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
Message_Flags flags_;
char *base_;
size_t cur_size_;
size_t max_size_;
char *rd_ptr_;
char *wr_ptr_;
ACE_Message_Type type_;
u_long priority_;
ACE_Message_Block *cont_;
ACE_Message_Block *next_;
ACE_Message_Block *prev_;
ACE_Allocator *allocator_;
ACE_Message_Block &operator= (const ACE_Message_Block &);
ACE_Message_Block (const ACE_Message_Block &);
};
DESCRIPTION
An ACE_Message_Block is modeled after the message data
structures used in System V STREAMS. A Message_Block is
composed of one or more Message_Blocks that are linked
together by PREV and NEXT pointers. In addition, a
ACE_Message_Block may also be linked to a chain of other
Message_Blocks. This structure enables efficient
manipulation of arbitrarily-large messages *without*
incurring memory copying overhead.
Initialization and termination.
ACE_Message_Block (void);
ACE_Message_Block (const char *data, size_t size = 0);
Create a Message Block that assumes ownership of data without
copying it (i.e., we don't delete it since we don't malloc it!).
ACE_Message_Block (
size_t size,
ACE_Message_Type type = MB_DATA,
ACE_Message_Block *cont = 0,
const char *data = 0,
ACE_Allocator *allocator = 0
);
Create an initialized message of type type containing size
bytes. The cont argument initializes the continuation field in
the Message_Block. If data == 0 then we create and own the
data, using allocator to get the data if it's non-0. If
data != 0 we assume ownership of the data (and don't delete
it).
int init (const char *data, size_t size = 0);
Create a Message Block that assumes ownership of data (i.e.,
doesn't delete it since it didn't malloc it!).
int init (
size_t size,
ACE_Message_Type type = MB_DATA,
ACE_Message_Block *cont = 0,
const char *data = 0,
ACE_Allocator *allocator = 0
);
Create an initialized message of type type containing size
bytes. The cont argument initializes the continuation field in
the Message_Block. If data == 0 then we create and own the
data, using allocator to get the data if it's non-0. If
data != 0 we assume ownership of the data (and don't delete
it).
~ACE_Message_Block (void);
Delete all the resources held in the message.
int is_data_msg (void) const;
Find out what type of message this is.
ACE_Message_Type msg_class (void) const;
Find out what class of message this is (there are two classes,
normal messages and high-priority messages).
ACE_Message_Type msg_type (void) const;
Set/Unset/Inspect the message flags.
Message_Flags set_flags (Message_Flags more_flags);
Message_Flags clr_flags (Message_Flags less_flags);
Message_Flags flags (void) const;
void msg_type (ACE_Message_Type type);
u_long msg_priority (void) const;
Get priority of the message.
void msg_priority (u_long priority);
Set priority of the message.
ACE_Message_Block *clone (
Message_Flags mask = ACE_Message_Block::DONT_DELETE
) const;
Return an exact "deep copy" of the message.
Operations on Message data
int copy (const char *buf, size_t n);
Copies n bytes from buf into the Message_Block starting at
the wr_ptr() offset. Return 0 if succeeds and -1 if the size of
the message is too small...
char *base (void) const;
void base (char *data, size_t size, Message_Flags = DONT_DELETE);
char *end (void) const;
Return a pointer to 1 past the end of the data in a message.
char *rd_ptr (void);
void rd_ptr (char *ptr);
Set the read pointer to ptr.
void rd_ptr (size_t n);
Set the read pointer ahead n bytes.
char *wr_ptr (void);
void wr_ptr (char *ptr);
Set the write pointer to ptr.
void wr_ptr (size_t n);
Set the write pointer ahead n bytes.
The length of a message is computed as the length between the
wr_ptr() - rd_ptr ()).
size_t length (void) const;
Get the length of the message
void length (size_t n);
Set the length of the message
The size of the allocated buffer is the total amount of space
alloted.
size_t size (void) const;
Get the total amount of space in the message.
int size (size_t length);
Set the total amount of space in the message. Returns 0 if
successful, else -1.
The coninuation field is used to chain together composite
messages.
ACE_Message_Block *cont (void) const;
Get the continuation field.
void cont (ACE_Message_Block *);
Set the continuation field.
= The next_ pointer points to the Message_Block directly ahead
in the Message_Queue.
ACE_Message_Block *next (void) const;
Get link to next message.
void next (ACE_Message_Block *);
Set link to next message.
= The prev_ pointer points to the Message_Block directly
ahead in the Message_Queue.
ACE_Message_Block *prev (void) const;
Get link to prev message.
void prev (ACE_Message_Block *);
Set link to prev message.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
Links to other ACE_Message_Block *s.
ACE_Message_Block *cont_;
Pointer to next message block in the chain.
ACE_Message_Block *next_;
Pointer to next message in the list.
ACE_Message_Block *prev_;
Pointer to previous message in the list.
ACE_Allocator *allocator_;
Pointer to the allocator defined for this message block.
= Disallow these operations for now (use clone instead).
ACE_Message_Block &operator= (const ACE_Message_Block &);
ACE_Message_Block (const ACE_Message_Block &);
AUTHOR
Doug Schmidt
LIBRARY
ace