index previous next




file name: netproc.hpp, netproc.cpp
classification: pure simulation
contents: abstract class ACNetworkProcess
derived from: class ACProcess
use: base class for all processes used to delay messages for the network


global items used:


member variables:

 EBool initCalled_: is set to True by Init(), and to False by Dispose().

 CMessageList *listOfMessages: contains the list of messages that are waiting.

 SMcb *msg_: points to the next message that has to be delivered. If no message is to be delivered, it is set to NULL.


member functions:

 ACNetworkProcess(): Creates a list object for storing messages of type SMsg.

 virtual ~ACNetworkProcess(): Deletes the list object and any messages that may still be stored in it.

 EBool Active(): returns True if the process is currently active, otherwise False.

 virtual void Body(): The main function of the process. It contains an endless loop and checks if the earliest message is due for delivery. If it is, Deliver() is called for the message and afterwards the message is deleted. This is repeated until there are no messages due for delivery at the current time. If the list of messages is empty at this state, the process suspends itself (calling Cancel()), otherwise it schedules itself for the processing time of the earliest message in the list.

 virtual void Deliver (SMsg *msg): pure virtual
The function is called by body if a message has become ready for processing. Derived classes should overload the function to do whatever has to be done with the message when its delay time has passed.

 virtual void Dispose(): If initCalled is False, nothing happens. Otherwise, the function deletes the list object and if Active() returns False, Cancel() is called to deschedule the process and msg is deleted. Member initCalled is set to False.

 SMsg *GetFirst (): Returns either the first message in the list of messages, or NULL if no messages are in the list.
Note: The currently handled message, which is stored in msg, is not considered.

 SMsg *GetNext (): Returns either the next message in the list of messages, or NULL if there are no messages in the list or if the last entry has been reached.

 virtual void Init(): If initCalled is True, nothing happens. Otherwise, the function creates a list object for storing messages of type SMsg and sets initCalled to True. If Active() returns False, msg is set to NULL.

 void Insert (SMsg *msg, double afterTime): Puts the message into a list, where it is stored for afterTime seconds. The process is scheduled for the time at which the message with the least delay should be processed. If msg is NULL, an assert fails.

 void Reset(): Calls Dispose() and then Init(), thus causing all messages to be discarded and the process to be suspended (if it was active).


last modified: Fri Feb 5 18:56:29 1999