Changeset 4462


Ignore:
Timestamp:
Jun 24, 2009, 8:48:35 AM (16 years ago)
Author:
Christoph Mayer
Message:

startup wrapper für gui gefixt

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/main.cpp

    r3041 r4462  
    1818        // this will do the main functionality and block
    1919        PingPong ping;
    20         StartupWrapper::startup(&ping, true);
     20        StartupWrapper::startup(&ping);
    2121
    2222        // --> we will run blocking until <enter> is hit
  • source/ariba/utility/system/StartupInterface.h

    r3690 r4462  
    4747namespace utility {
    4848
    49 /**
    50  * TODO: Mies -- to be replaced by a general Module!
    51  */
     49class StartupWrapper;
     50
    5251class StartupInterface
    5352#ifdef UNDERLAY_OMNET
     
    6362        virtual void startup() = 0;
    6463        virtual void shutdown() = 0;
     64        StartupWrapper* wrapper;
    6565};
    6666
  • source/ariba/utility/system/StartupWrapper.cpp

    r4181 r4462  
    4747#endif
    4848
    49 SystemEventType StartupWrapperEventType("StartupWrapperEventType");
     49SystemEventType StartupWrapperEventStartup("StartupWrapperEventStartup");
     50SystemEventType StartupWrapperEventShutdown("StartupWrapperEventShutdown");
    5051
    51 StartupWrapper::StartupWrapper(StartupInterface* _service, bool _block)
    52         : blocking( _block ), service( _service ){
     52StartupWrapper::StartupWrapper(StartupInterface* _service) : service( _service ){
    5353}
    5454
     
    126126}
    127127
     128void 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
    128154void StartupWrapper::startup(StartupInterface* service, bool block){
    129155
    130         StartupWrapper* startup = new StartupWrapper(service, block);
     156        StartupWrapper* startup = new StartupWrapper(service);
     157        service->wrapper = startup;
    131158
    132 #ifdef UNDERLAY_OMNET
    133159        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 );
    138161
     162#ifndef UNDERLAY_OMNET
    139163        if( block ) getchar();
    140164#endif
    141165}
    142166
    143 void StartupWrapper::handleSystemEvent(const SystemEvent& event){
     167void StartupWrapper::shutdown(StartupInterface* service, bool block){
    144168
    145         string config = configurations.front();
    146         configurations.pop();
    147         Configuration::setConfigFilename( config );
     169        if( service == NULL || service->wrapper == NULL ) return;
    148170
    149         //
    150         // start the actual application
    151         //
    152 
    153         // TODO: im falle von omnet ist service = null, da von SpoVNetOmnetModule so ÃŒbergeben
    154         // wie wird im Falle von omnet die anwendung erstellt?
    155 
    156         service->startup();
    157 }
    158 
    159 void StartupWrapper::shutdown(StartupInterface* service){
    160171#ifdef UNDERLAY_OMNET
    161172        //TODO: service->shutdown();
    162173#endif
    163174
    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        }
    166183}
    167184
  • source/ariba/utility/system/StartupWrapper.h

    r3690 r4462  
    7272        static void initConfig(string filename);
    7373        static void startup(StartupInterface* service, bool block = true);
    74         static void shutdown(StartupInterface* service);
     74        static void shutdown(StartupInterface* service, bool block = true);
    7575
    7676#ifdef UNDERLAY_OMNET
     
    8080
    8181protected:
    82         StartupWrapper(StartupInterface* _service, bool _block);
     82        StartupWrapper(StartupInterface* _service);
    8383        virtual ~StartupWrapper();
    8484
     
    9494#endif
    9595
    96         volatile bool blocking;
    9796        void waitForExit();
    9897        StartupInterface* service;
Note: See TracChangeset for help on using the changeset viewer.