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

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.


Private Member Functions

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


Member Function Documentation

void Txc9::forwardMessage (  cMessage *  msg  )  [private, virtual]
 

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

void Txc9::handleMessage (  cMessage *  msg  )  [private, virtual]
 

Reimplemented from cSimpleModule.

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

void Txc9::initialize (   )  [private, virtual]
 

Reimplemented from cModule.

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

Txc9::Module_Class_Members (  Txc9  ,
cSimpleModule  ,
0 
)  [private]
 


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