Changeset 4462
- Timestamp:
- Jun 24, 2009, 8:48:35 AM (16 years ago)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/pingpong/main.cpp
r3041 r4462 18 18 // this will do the main functionality and block 19 19 PingPong ping; 20 StartupWrapper::startup(&ping , true);20 StartupWrapper::startup(&ping); 21 21 22 22 // --> we will run blocking until <enter> is hit -
source/ariba/utility/system/StartupInterface.h
r3690 r4462 47 47 namespace utility { 48 48 49 /** 50 * TODO: Mies -- to be replaced by a general Module! 51 */ 49 class StartupWrapper; 50 52 51 class StartupInterface 53 52 #ifdef UNDERLAY_OMNET … … 63 62 virtual void startup() = 0; 64 63 virtual void shutdown() = 0; 64 StartupWrapper* wrapper; 65 65 }; 66 66 -
source/ariba/utility/system/StartupWrapper.cpp
r4181 r4462 47 47 #endif 48 48 49 SystemEventType StartupWrapperEventType("StartupWrapperEventType"); 49 SystemEventType StartupWrapperEventStartup("StartupWrapperEventStartup"); 50 SystemEventType StartupWrapperEventShutdown("StartupWrapperEventShutdown"); 50 51 51 StartupWrapper::StartupWrapper(StartupInterface* _service, bool _block) 52 : blocking( _block ), service( _service ){ 52 StartupWrapper::StartupWrapper(StartupInterface* _service) : service( _service ){ 53 53 } 54 54 … … 126 126 } 127 127 128 void StartupWrapper::handleSystemEvent(const SystemEvent& event){ 129 130 if( event.getType() == StartupWrapperEventStartup ){ 131 132 string config = configurations.front(); 133 configurations.pop(); 134 Configuration::setConfigFilename( config ); 135 136 // 137 // start the actual application 138 // 139 140 // TODO: im falle von omnet ist service = null, da von SpoVNetOmnetModule so ÃŒbergeben 141 // wie wird im Falle von omnet die anwendung erstellt? 142 143 service->startup(); 144 145 } else if( event.getType() == StartupWrapperEventShutdown ){ 146 147 service->shutdown(); 148 SystemQueue::instance().cancel(); 149 150 } 151 152 } 153 128 154 void StartupWrapper::startup(StartupInterface* service, bool block){ 129 155 130 StartupWrapper* startup = new StartupWrapper(service, block); 156 StartupWrapper* startup = new StartupWrapper(service); 157 service->wrapper = startup; 131 158 132 #ifdef UNDERLAY_OMNET133 159 SystemQueue::instance().scheduleEvent( 134 SystemEvent( startup, StartupWrapperEventType, NULL), 0 ); 135 #else 136 SystemQueue::instance().scheduleEvent( 137 SystemEvent( startup, StartupWrapperEventType, NULL), 0 ); 160 SystemEvent( startup, StartupWrapperEventStartup, NULL), 0 ); 138 161 162 #ifndef UNDERLAY_OMNET 139 163 if( block ) getchar(); 140 164 #endif 141 165 } 142 166 143 void StartupWrapper:: handleSystemEvent(const SystemEvent& event){167 void StartupWrapper::shutdown(StartupInterface* service, bool block){ 144 168 145 string config = configurations.front(); 146 configurations.pop(); 147 Configuration::setConfigFilename( config ); 169 if( service == NULL || service->wrapper == NULL ) return; 148 170 149 //150 // start the actual application151 //152 153 // TODO: im falle von omnet ist service = null, da von SpoVNetOmnetModule so ÃŒbergeben154 // wie wird im Falle von omnet die anwendung erstellt?155 156 service->startup();157 }158 159 void StartupWrapper::shutdown(StartupInterface* service){160 171 #ifdef UNDERLAY_OMNET 161 172 //TODO: service->shutdown(); 162 173 #endif 163 174 164 service->shutdown(); 165 SystemQueue::instance().cancel(); 175 if(block){ 176 SystemEvent ev (service->wrapper, StartupWrapperEventShutdown); 177 service->wrapper->handleSystemEvent(ev); 178 179 }else{ 180 SystemQueue::instance().scheduleEvent( 181 SystemEvent( service->wrapper, StartupWrapperEventShutdown, NULL), 0 ); 182 } 166 183 } 167 184 -
source/ariba/utility/system/StartupWrapper.h
r3690 r4462 72 72 static void initConfig(string filename); 73 73 static void startup(StartupInterface* service, bool block = true); 74 static void shutdown(StartupInterface* service );74 static void shutdown(StartupInterface* service, bool block = true); 75 75 76 76 #ifdef UNDERLAY_OMNET … … 80 80 81 81 protected: 82 StartupWrapper(StartupInterface* _service , bool _block);82 StartupWrapper(StartupInterface* _service); 83 83 virtual ~StartupWrapper(); 84 84 … … 94 94 #endif 95 95 96 volatile bool blocking;97 96 void waitForExit(); 98 97 StartupInterface* service;
Note:
See TracChangeset
for help on using the changeset viewer.