Txc3 Class Reference

Inheritance diagram for Txc3:
cSimpleModule cModule cComponent cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject

List of all members.

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Private Attributes

int counter

Detailed Description

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


Member Function Documentation

void Txc3::handleMessage ( cMessage msg  )  [protected, virtual]

Reimplemented from cSimpleModule.

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

void Txc3::initialize (  )  [protected, virtual]

Reimplemented from cComponent.

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


Member Data Documentation

int Txc3::counter [private]

Referenced by handleMessage(), and initialize().


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:33 2014 for Tictoc Tutorial by  doxygen 1.6.3