Txc9 Class Reference

Inheritance diagram for Txc9:

cSimpleModule cModule cDefaultList cObject cPolymorphic List of all members.

Detailed Description

Let's make it more interesting by using several (n) `tic' modules, and connecting every module to every other. For now, let's keep it simple what they do: module 0 generates a message, and the others keep tossing it around in random directions until it arrives at module 2.


Protected Member Functions

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


Member Function Documentation

void Txc9::forwardMessage cMessage msg  )  [protected, virtual]
 

00061 {
00062     // In this example, we just pick a random gate to send it on.
00063     // We draw a random number between 0 and the size of gate `out[]'.
00064     int n = gate("out")->size();
00065     int k = intuniform(0,n-1);
00066 
00067     ev << "Forwarding message " << msg << " on port out[" << k << "]\n";
00068     send(msg, "out", k);
00069 }

void Txc9::handleMessage cMessage msg  )  [protected, virtual]
 

Reimplemented from cSimpleModule.

00046 {
00047     if (index()==3)
00048     {
00049         // Message arrived.
00050         ev << "Message " << msg << " arrived.\n";
00051         delete msg;
00052     }
00053     else
00054     {
00055         // We need to forward the message.
00056         forwardMessage(msg);
00057     }
00058 }

void Txc9::initialize  )  [protected, virtual]
 

Reimplemented from cModule.

00034 {
00035     if (index()==0)
00036     {
00037         // Boot the process scheduling the initial message as a self-message.
00038         char msgname[20];
00039         sprintf(msgname, "tic-%d", index());
00040         cMessage *msg = new cMessage(msgname);
00041         scheduleAt(0.0, msg);
00042     }
00043 }


The documentation for this class was generated from the following file:
Generated on Sat Oct 21 17:48:02 2006 for Tictoc Tutorial by  doxygen 1.4.6