BaseLayer.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        BaseLayer.h
00003  *
00004  * author:      Andreas Koepke
00005  *
00006  * copyright:   (C) 2006 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: basic layer class
00019  *              subclass to create your own layer
00020  **************************************************************************/
00021 
00022 
00023 #ifndef BASE_LAYER_H
00024 #define BASE_LAYER_H
00025 
00026 #include "BatteryAccess.h"
00027 #include "PassedMessage.h"
00028 
00038 class BaseLayer : public BatteryAccess
00039 {
00040  protected:
00041 
00044     int upperGateIn;
00045     int upperGateOut;
00046     int lowerGateIn;
00047     int lowerGateOut;
00048     int upperControlIn;
00049     int upperControlOut;
00050     int lowerControlIn;
00051     int lowerControlOut;
00052 
00056     bool doStats;
00058     int  catPassedMsg;
00060     PassedMessage *passedMsg;
00062     int  hostId;
00063 
00064 public:
00065     //Module_Class_Members(BaseLayer, BaseModule, 0 );
00066 
00068     virtual void initialize(int);
00069 
00071     virtual void handleMessage( cMessage* );
00072 
00074   virtual void finish();
00075   virtual ~BaseLayer();
00076 
00077 protected:
00088 
00091     virtual void handleSelfMsg(cMessage* msg) = 0;
00092 
00098     virtual void handleUpperMsg(cMessage *msg) = 0;
00099 
00101     virtual void handleLowerMsg(cMessage *msg) = 0;
00102 
00104     virtual void handleLowerControl(cMessage *msg) = 0;
00105 
00107     virtual void handleUpperControl(cMessage *msg) = 0;
00108 
00123 
00131     void sendDown(cMessage *msg);
00132 
00140     void sendUp(cMessage *msg);
00141 
00143     void sendControlUp(cMessage *msg);
00144 
00146     void sendControlDown(cMessage *msg);
00147 
00148     void recordPacket(PassedMessage::direction_t dir,
00149                       PassedMessage::gates_t gate,
00150                       const cMessage *m);
00151 
00152 // private:
00153 //    void recordPacket(bool in, MsgType type, const cMessage *);
00154 //  void printPackets(std::map<MsgType,std::map<int,std::pair<char *,int>* > *> *use, bool in);
00156 };
00157 
00158 #endif