shmem

Metrics


toc >>

class COMM_SERVER_HEADER : public GENERIC_MSG_HEADER

#include "CommServerHeader.H"

Class: COMM_SERVER_HEADER Summary: Header of all messages sent with the comm server Description: Messages sent with the comm server using the client server code require that they have a header that is derived from the GENERIC_MSG_HEADER class. This extends that class to have 4 additional pieces of information that is important for the comm server and the client for SpComm_NET.H Examples: Look SpComm_TCPIP.C and CommmServer.C.

Public Interface

getData getNode getType
getUnused setData setNode
setType setUnused

Public Interface

int getData( ) ;
Method: getData Summary: Returns the value of the Data member for this message Description: Returns the value of the Data member for this message Return: Returns the value of the Data member for this message.
int getNode( ) ;
Method: getNode
Summary: Returns the node of the message
Description: Returns the node of the message
Return: Returns the node of the message
int getType( ) ;
Method: getType
Summary: Returns the type of the message
Description: Returns the type of the message
Return: Returns the type of the message
int getUnused( ) ;
Method: getUnused
Summary: unused
Description: not used
Return: unused value
void setData( int ival ) ;
Method: setData
Summary: Sets the Data member to ival
Description: Sets the Data member to ival
Return: void
void setNode( int nodeNum ) ;
Method: setNode
Summary: Sets the node of the message
Description: Sets the node of the message
Return: void
nodeNum
In: Either the node of the sender or receiver of this message.
void setType( int t ) ;
Method: setType
Summary: Sets the type of the message to t
Description: Sets the type of the message to t
Return: void
t
In: The type of the message.
void setUnused( int ival ) ;
Method: setUnused
Summary: Not Used
Description: Not Used
Return: void

<<toc

class C_QUEUE

#include "queue.H"

Class: C_QUEUE Summary: Singly linked list non-rollbackable data structure Description: This class does not have any rollback support, and is thus simply a generic queue that sorts C_ITEMs according to simulated time tags. It can also be used as a stack. That is, popping must always be from the top of the queue (since it is singly linked) but pushing can be to the top or the bottom of the queue.

When consistantly pushing to the top, this data structure acts as a stack. When consistantly pushing to the bottom, it acts as a queue. Sorting and inserting always put the low time value on top so that popping off the sorted queue or stack occurs in simulated time order.

This basic class is used throughout SPEEDES. It is used to implement the SPEEDES qheap, it shows up in the class C_HASH and in many other places.

One gotcha to watch out for is that the queue is not NULL terminated. In order to iterate through the queue, you need to first find out how many items are in the queue and then stop when that number is reached.

Public Interface

C_QUEUE clear concat
copy deque deque
fast_pop_top get_bot get_item
get_length get_top init
insert insert_after join
length merge next
pbot pop_top print
printstream ptop push_bot
push_top remove remove
reset set_bot set_length
set_top sort

Public Interface

C_QUEUE( ) ;
void clear( ) ;
Method: clear
Summary: Clear this queue and delete all the items
Description: Sets top and bottom of this queue to NULL, and number of items
             to zero
Return: None
void concat( C_QUEUE* q ) ;
Method: concat
Summary: Concatenate a specified queue with this queue, and reset the 
         specified (passed in) queue
Description: 
Return: None
q
IN: specified queue to concatenate with this queue.
C_QUEUE* copy( ) ;
Method: copy
Summary: Copy this queue
Description: 
Return: A copy of this queue
void deque( C_ITEM* item ) ;
Overloaded Method: deque
Summary: Remove (but don't delete) an item from the queue
Description: 
Return: None
item
IN: item to remove.
C_ITEM* deque( int rid ) ;
Overloaded Method: deque
Summary: Remove (but don't delete) an item from the queue
Description: 
Return: A removed (but not deleted) item from the queue
rid
IN: ID of item to remove.
C_ITEM* fast_pop_top( ) ;
Method: fast_pop_top Summary: Pops a specified item off of (ie, removes a specified item from) the top of the queue and returns it, but loses track of the number of items in the queue Description: This method has undefined (erroneous) behavior when the queue is empty or has only one item in it. It also does not decrement the number of items. If either of these issues are (or potentially are) a problem, use pop_top, which is a slower but safe routine, instead.

One reason you may use this method is that you want to quickly grab all the items off of a queue while emptying the queue. You could first find the number of items in the queue, use fast_pop_top() to get all the items and then call queue->init(NULL, NULL, 0) to set the number of items to zero. Be very careful in using this method!.

Return: Item that has been popped off of (removed from) the top of the queue.

C_ITEM* get_bot( ) ;
Method: get_bot (same as pbot)
Summary: Get a pointer to the item at the bottom of the queue without
         removing it from the queue.
Description: 
Return: A pointer to the item at the bottom of the queue
C_ITEM* get_item( int id ) ;
Method: get_item
Summary: Get a pointer to the item with a specified ID
Description: 
Return: A pointer to the item with a specified ID
id
IN: ID of item.
int get_length( ) ;
Method: get_length (same as length)
Summary: Get the number of items in the queue
Description: This method is perfect for finding out how many items
             are in a queue before you start iterating through those
             items.
Return: The number of items in the queue
C_ITEM* get_top( ) ;
Method: get_top (same as ptop)
Summary: Get a pointer to the item at the top of the queue without removing
         it from the queue.
Description: 
Return: A pointer to the item at the top of the queue
void init( C_ITEM* t , C_ITEM* b , int len ) ;
Method: init 
Summary: Initialize the queue object
Description: This should be called initially or just after clearing
             the queue. Otherwise, calling this method will
             permanently lose the current information in the queue
             and create memory leaks.
Return: None
t
IN: top of the queue.
b
IN: bottom of the queue.
len
IN: number of items in the queue.
void insert( C_ITEM* item ) ;
Method: insert (same as insert_after)
Summary: Insert a specified item into this queue, with the item having the
         lower simulated time tag on top
Description: 
Return: None
item
IN: specified item to insert into this queue.
void insert_after( C_ITEM* item ) ;
Method: insert_after (same as insert)
Summary: Insert an item into this queue, with the item having the lower 
         simulated time tag on top
Description: 
Return: None
item
IN: specified item to insert into this queue.
void join( C_QUEUE* q ) ;
Method: join
Summary: Concatenate a specified queue to this queue, but do not reset 
         the specified (passed in) queue
Description: 
Return: None
q
IN: specified queue to concatenate with this queue.
int length( ) ;
Method: length (same as get_length)
Summary: Get the number of items in the queue
Description: This method is perfect for finding out how many items
             are in a queue before you start iterating through those
             items.
Return: The number of items in the queue
void merge( C_QUEUE* q ) ;
Method: merge
Summary: Merge a specified queue into this queue in simulated time order
Description: 
Return: None
q
IN: specified queue to merge with this queue.
C_ITEM* next( C_ITEM* item ) ;
Method: next.

Summary: Get a pointer to the item in the queue immediately following (ie below) a specified item without removing it from the queue.

Description: This is a great way to walk through a queue and examine all the items. Notice that this list is not NULL terminated so you need to first find out how many items are in the list as in the following code:

C_ITEM * tempItem = queue->get_top(); int numItems = queue->get_length(); for (int i=0; i < numItems; ++i){ //Process tempItem here tempItem = queue->next(tempItem); }.

Return: A pointer to the item in the queue immediately following (ie below) a specified item without removing it from the queue.

item
IN: specified item after which the requested item lies.
C_ITEM* pbot( ) ;
Method: pbot (same as get_bot)
Summary: Get a pointer to the item at the bottom of the queue without
         removing it from the queue.
Description: 
Return: A pointer to the item at the bottom of the queue
C_ITEM* pop_top( ) ;
Method: pop_top
Summary: Pops a specified item off of (ie, removes a specified item
         from) the top of the queue and returns it
Description: 
Return: Item that has been popped off of (removed from) the top of the queue
void print( ) ;
Method: print
Summary: Print the items in this queue
Description: This calls the virtual method print() on each of the
             items in the queue.
Return: None
void printstream( ostream& out ) ;
Method: printstream
Summary: print the items in this queue using stream io
Description: This calls the virtual method printstream() on each of
             the items in the queue.
Return: None
out
IN: the ostream to which to print.
C_ITEM* ptop( ) ;
Method: ptop (same as get_top)
Summary: Get a pointer to the item at the top of the queue without removing
         it from the queue.
Description: 
Return: A pointer to the item at the top of the queue
void push_bot( C_ITEM* item ) ;
Method: push_bot
Summary: Pushes a specified item onto (ie, inserts a specified item
         at) the bottom of the queue
Description: 
Return: None
item
IN: specified item to insert.
void push_top( C_ITEM* item d item to insert ) ;
Method: push_top
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
         top of the queue
Description: This method moves the top pointer in this queue to the
             specified item, which then points to the old top item
Return: None
void remove( C_ITEM* item ) ;
Overloaded Method: remove
Summary: Remove (delete) an item from the queue
Description: 
Return: None
item
IN: item to remove.
void remove( int id ) ;
Overloaded Method: remove
Summary: Remove (delete) an item from the queue
Description: This removes the item from the queue and it also
             deletes the item.  Be sure not to try to access it if
             you have a stale pointer to it!
Return: None
id
IN: ID of item to remove.
void reset( ) ;
Method: reset
Summary: Clear this queue without deleting the items
Description: Sets top and bottom of this queue to NULL, and number of items
             to zero
Return: None
void set_bot( C_ITEM* item ) ;
Method: set_bot
Summary: Set the bottom of the queue to point to a specified item
Description: This should be called initially or just after clearing
             the queue. Otherwise, calling this method will
             permanently lose the current information in the queue
             and create memory leaks.
Return: None
item
In: Item to be set as the top of the queue.
void set_length( int l ) ;
Method: set_length
Summary: Set the number of items in the queue (GET RID OF!)
Description: It is dangerous to try and use this method.  Don't use
             it unless you really know what you are doing.  It can
             result in the loss of data and the loss of pointers to
             dynamically allocated memory.
Return: None
void set_top( C_ITEM* item ) ;
IN: number of items in the queue.
item
In: Item to be set as the top of the queue.
void sort( ) ;
Method: sort Summary: Sort the queue in time order Description: If the number of items is 15 or less, this method uses insertion sort. Otherwise, it recursively divides the items into pairs of two halves until the number of items in each resulting half is 15 or less. These are sorted with insertion sort. Once each each pair has two sorted halves, the two halves are merged into one sorted temporary queue. Finally, it recursively merges all sorted temporary queues into the final sorted queue. Ie. It uses merge sort. Return: None.