OverSim
MyApplication.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
23 #ifndef MYAPPLICATION_H
24 #define MYAPPLICATION_H
25 
26 #include <omnetpp.h>
27 
28 #include "BaseApp.h"
29 
30 
31 class MyApplication : public BaseApp
32 {
33  // module parameters
34  simtime_t sendPeriod; // we'll store the "sendPeriod" parameter here
35  int numToSend; // we'll store the "numToSend" parameter here
36  int largestKey; // we'll store the "largestKey" parameter here
37 
38  // statistics
39  int numSent; //number of packets sent
40  int numReceived; //number of packets received
41 
42  // our timer
43  cMessage *timerMsg;
44 
45  // application routines
46  void initializeApp(int stage); // called when the module is being created
47  void finishApp(); // called when the module is about to be destroyed
48  void handleTimerEvent(cMessage* msg); // called when we received a timer message
49  void deliver(OverlayKey& key, cMessage* msg); // called when we receive a message from the overlay
50  void handleUDPMessage(cMessage* msg); // called when we receive a UDP message
51 
52 public:
53  MyApplication() { timerMsg = NULL; };
54  ~MyApplication() { cancelAndDelete(timerMsg); };
55 };
56 
57 
58 #endif