00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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