# Txc3 Class Reference

Inheritance diagram for Txc3:

List of all members.

## Detailed Description

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

## Protected Member Functions

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

## Private Attributes

int | counter

## 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 << name() << "'s counter reached zero, deleting message\n";
    00060         delete msg;
    00061     }
    00062     else
    00063     {
    00064         ev << name() << "'s counter is " << counter << ", sending back message\n";
    00065         send(msg, "out");
    00066     }
    00067 }

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

Reimplemented from cModule.

    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", name()) == 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]`

The documentation for this class was generated from the following file:

- txc3.cc