Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

Txc3 Class Reference

Inheritance diagram for Txc3:

cSimpleModule cModule cDefaultList cObject cPolymorphic List of all members.

Detailed Description

In this class we add a counter, and delete the message after ten exchanges.


Public Member Functions

 Module_Class_Members (Txc3, cSimpleModule, 0)
virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Protected Attributes

int counter


Member Function Documentation

void Txc3::handleMessage (  cMessage *  msg  )  [virtual]
 

Reimplemented from cSimpleModule.

00053 {
00054     // Increment counter and check value.
00055     counter--;
00056     if (counter==0)
00057     {
00058         // If counter is zero, delete message. If you run the model, you'll
00059         // find that the simulation will stop at this point with the message
00060         // "no more events".
00061         ev << name() << "'s counter reached zero, deleting message\n";
00062         delete msg;
00063     }
00064     else
00065     {
00066         ev << name() << "'s counter is " << counter << ", sending back message\n";
00067         send(msg, "out");
00068     }
00069 }

void Txc3::initialize (   )  [virtual]
 

Reimplemented from cModule.

00033 {
00034     // Initialize counter to ten. We'll decrement it every time and delete
00035     // the message when it reaches zero.
00036     counter = 10;
00037 
00038     // The WATCH() statement below will let you examine the variable under
00039     // Tkenv. After doing a few steps in the simulation, double-click either
00040     // `tic' or `toc', select the Contents tab in the dialog that pops up,
00041     // and you'll find "counter" in the list.
00042     WATCH(counter);
00043 
00044     if (strcmp("tic", name()) == 0)
00045     {
00046         ev << "Sending initial message\n";
00047         cMessage *msg = new cMessage("tictocMsg");
00048         send(msg, "out");
00049     }
00050 }

Txc3::Module_Class_Members (  Txc3  ,
cSimpleModule  ,
0 
) 
 


Member Data Documentation

int Txc3::counter [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Apr 1 12:25:42 2005 for Tictoc Tutorial by  doxygen 1.3.9.1