BaseModule.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        BaseModule.h
00003  *
00004  * author:      Steffen Sroka
00005  *              Andreas Koepke
00006  *
00007  * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at
00008  *              Technische Universitaet Berlin, Germany.
00009  *
00010  *              This program is free software; you can redistribute it
00011  *              and/or modify it under the terms of the GNU General Public
00012  *              License as published by the Free Software Foundation; either
00013  *              version 2 of the License, or (at your option) any later
00014  *              version.
00015  *              For further information see file COPYING
00016  *              in the top level directory
00017  ***************************************************************************
00018  * part of:     framework implementation developed by tkn
00019  **************************************************************************/
00020 
00021 
00022 #ifndef BASE_MODULE_H
00023 #define BASE_MODULE_H
00024 
00025 #include <sstream>
00026 #include <omnetpp.h>
00027 
00028 #include "ImNotifiable.h"
00029 #include "FindModule.h"
00030 
00031 #include "HostState.h"
00032 #include "BaseUtility.h"
00033 
00034 #ifndef debugEV
00035 #define debugEV_clear (ev.isDisabled()||!debug) ? ev : ev
00036 #define debugEV (ev.isDisabled()||!debug) ? ev : ev << logName() << "::" << getClassName() << ": "
00037 #endif
00038 
00039 #ifndef coreEV
00040 #define coreEV_clear (ev.isDisabled()||!coreDebug) ? ev : ev
00041 #define coreEV (ev.isDisabled()||!coreDebug) ? ev : ev << logName() << "::" << getClassName() <<": "
00042 #endif
00043 
00079 class BaseModule: public cSimpleModule, public ImNotifiable {
00080   protected:
00082     BaseUtility *utility;
00083 
00085     bool debug;
00086 
00087 
00088 
00092   bool notAffectedByHostState;
00093 
00095   int hostStateCat;
00096 
00098   int hostId;
00099 protected:
00100 
00110   virtual void handleHostState(const HostState& state);
00111 
00122   void switchHostState(HostState::States state);
00123 
00125     cModule *findHost(void);
00127     //std::string getLogName(int);
00128 
00129 
00130 
00131   public:
00132     BaseModule();
00133 
00135     virtual void initialize(int);
00136 
00149     virtual int numInitStages() const {
00150       return 2;
00151     }
00152 
00160     std::string logName(void);
00161 
00165     cModule * getNode(){
00166       return findHost();
00167     };
00168 
00175     virtual void receiveBBItem(int category, const BBItem *details, int scopeModuleId);
00176 };
00177 
00178 #endif