I3Composite Class Reference

Composite test application for I3. More...

Inheritance diagram for I3Composite:
I3BaseApp

List of all members.

Public Member Functions

void initializeApp (int stage)
 App initialization - should be overwritten by application.
void initializeI3 ()
 Application I3 initialize - should be overwritten by application.
void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
 Delivers packets coming from I3 - should be overwritten by application.
void handleTimerEvent (cMessage *msg)
 Handles timers - should be overwritten by application.
void createMessage ()

Public Attributes

int myIndex
cMessage * sendPacketTimer

Static Private Attributes

static int index = 0

Detailed Description

Composite test application for I3.

This tests the ability of I3 to realize service composition in which the receving node decides the routing of a packet. First, all nodes insert their own trigger. Then, node 0 creates an packet containing an empty sentence (""), and sends it to I3 with an identifier stack containing the triggers of service nodes 1, 2, 3, 4 and then node 0. I3 then routes the packet to each of those triggers in that order. Each service node adds some words to the sentence ands sends it back to I3 with the same identifier stack it received. When it returns to node 0 it displays the sentence it received and starts again.

Definition at line 43 of file I3Composite.cc.


Member Function Documentation

void I3Composite::createMessage (  ) 

Definition at line 80 of file I3Composite.cc.

Referenced by deliver(), and handleTimerEvent().

00080                                 {
00081     I3CompositeMessage *cmsg = new I3CompositeMessage();
00082 
00083     cmsg->sentence = "";
00084 
00085     I3Identifier id0("Composite 0"),
00086     id1("Composite 1"),
00087     id2("Composite 2"),
00088     id3("Composite 3"),
00089     id4("Composite 4");
00090 
00091     I3IdentifierStack stack;
00092     stack.push(id0);
00093     stack.push(id4);
00094     stack.push(id3);
00095     stack.push(id2);
00096     stack.push(id1);
00097 
00098     sendPacket(stack, cmsg);
00099 }

void I3Composite::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
) [virtual]

Delivers packets coming from I3 - should be overwritten by application.

Parameters:
trigger Application trigger to which the packet was sent
stack Identifier stack passed from I3
msg Arriving message

Reimplemented from I3BaseApp.

Definition at line 110 of file I3Composite.cc.

00111 {
00112     I3CompositeMessage *cmsg = check_and_cast<I3CompositeMessage*>(msg);
00113 
00114     switch (myIndex) {
00115     case 0:
00116     {
00117         string final = "Final sentence: " + cmsg->sentence;
00118         getParentModule()->bubble(final.c_str());
00119         delete msg;
00120         createMessage();
00121         return;
00122     }
00123     case 1:
00124         getParentModule()->bubble("Adding 'He pounds'");
00125         cmsg->sentence += "He pounds ";
00126         break;
00127     case 2:
00128         getParentModule()->bubble("Adding 'his fists'");
00129         cmsg->sentence += "his fists ";
00130         break;
00131     case 3:
00132         getParentModule()->bubble("Adding 'against'");
00133         cmsg->sentence += "against ";
00134         break;
00135     case 4:
00136         getParentModule()->bubble("Adding 'the posts'");
00137         cmsg->sentence += "the posts ";
00138         break;
00139     default:
00140         delete msg;
00141         return;
00142     }
00143     sendPacket(stack, cmsg);
00144 }

void I3Composite::handleTimerEvent ( cMessage *  msg  )  [virtual]

Handles timers - should be overwritten by application.

Parameters:
msg Timer to be handled

Reimplemented from I3BaseApp.

Definition at line 101 of file I3Composite.cc.

00102 {
00103     if (myIndex == 0) { // only the first node
00104         getParentModule()->bubble("Starting chain!");
00105         createMessage();
00106     }
00107     delete msg;
00108 }

void I3Composite::initializeApp ( int  stage  )  [virtual]

App initialization - should be overwritten by application.

I3 related commands should go in initializeI3.

Parameters:
stage Initialization stage passed from initialize()

Reimplemented from I3BaseApp.

Definition at line 60 of file I3Composite.cc.

00061 {
00062     myIndex = index++;
00063 
00064 }

void I3Composite::initializeI3 (  )  [virtual]

Application I3 initialize - should be overwritten by application.

Reimplemented from I3BaseApp.

Definition at line 66 of file I3Composite.cc.

00067 {
00068     if (myIndex == 0) {
00069         sendPacketTimer = new cMessage("packet timer");
00070         scheduleAt(simTime() + 50, sendPacketTimer);
00071     }
00072 
00073     ostringstream os;
00074     os << "Composite " << myIndex;
00075 
00076     I3Identifier identifier(os.str());
00077     insertTrigger(identifier);
00078 }


Member Data Documentation

int I3Composite::index = 0 [static, private]

Definition at line 46 of file I3Composite.cc.

Referenced by initializeApp().

Definition at line 48 of file I3Composite.cc.

Referenced by deliver(), handleTimerEvent(), initializeApp(), and initializeI3().

Definition at line 49 of file I3Composite.cc.

Referenced by initializeI3().


The documentation for this class was generated from the following file:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3