BaseApplLayer.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        BaseApplLayer.h
00003  *
00004  * author:      Daniel Willkomm
00005  *
00006  * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at
00007  *              Technische Universitaet Berlin, Germany.
00008  *
00009  *              This program is free software; you can redistribute it
00010  *              and/or modify it under the terms of the GNU General Public
00011  *              License as published by the Free Software Foundation; either
00012  *              version 2 of the License, or (at your option) any later
00013  *              version.
00014  *              For further information see file COPYING
00015  *              in the top level directory
00016  ***************************************************************************
00017  * part of:     framework implementation developed by tkn
00018  * description: application layer: general class for the application layer
00019  *              subclass to create your own application layer
00020  **************************************************************************/
00021 
00022 
00023 #ifndef BASE_APPL_LAYER_H
00024 #define BASE_APPL_LAYER_H
00025 
00026 #include <assert.h>
00027 #include "BaseLayer.h"
00028 #include "ApplPkt_m.h"
00029 
00030 
00043 class BaseApplLayer : public BaseLayer
00044 {
00045 public:
00047   enum BaseApplMessageKinds {
00050     LAST_BASE_APPL_MESSAGE_KIND = 25000,
00051   };
00053   enum BaseApplControlKinds {
00056     LAST_BASE_APPL_CONTROL_KIND = 25500,
00057   };
00058 protected:
00062   int headerLength;
00063 
00064 public:
00065   //Module_Class_Members(BaseApplLayer, BaseLayer, 0);
00066 
00068   virtual void initialize(int);
00069 
00070 protected:
00081 
00088   virtual void handleSelfMsg(cMessage* msg) {
00089     EV << "BaseApplLayer: handleSelfMsg not redefined; delete msg\n";
00090     delete msg;
00091   };
00092 
00102   virtual void handleLowerMsg(cMessage* msg) {
00103     EV << "BaseApplLayer: handleLowerMsg not redefined; delete msg\n";
00104     delete msg;
00105   };
00106 
00113   virtual void handleLowerControl(cMessage* msg) {
00114     EV << "BaseApplLayer: handleLowerControl not redefined; delete msg\n";
00115     delete msg;
00116   };
00117 
00123   virtual void handleUpperMsg(cMessage *msg) {
00124     assert(false);
00125     opp_error("Application has no upper layers!");
00126     delete msg;
00127   }
00128 
00130   virtual void handleUpperControl(cMessage *msg) {
00131     assert(false);
00132     opp_error("Application has no upper layers!");
00133     delete msg;
00134   }
00135 
00139   void sendDelayedDown(cMessage *, simtime_t);
00140 
00146   virtual const int myApplAddr() {
00147     return getParentModule()->getIndex();
00148   };
00149 
00150 };
00151 
00152 #endif