Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CompletionTrans.cc

Go to the documentation of this file.
00001 #include "CompletionTrans.h"
00002 
00003 void CompletionTrans::postStart() {
00004   Transition::postStart();
00005   unsigned int const numsrcs = getSources().size();
00006   completions = new bool[numsrcs];
00007   for (unsigned int i = 0; i < numsrcs; i++) {
00008     completions[i] = false;
00009     erouter->addListener(this, EventBase::stateMachineEGID, 
00010                          reinterpret_cast<size_t>(getSources()[i]), EventBase::statusETID);
00011   };
00012 }
00013 
00014 void CompletionTrans::stop() {
00015   erouter->removeListener(this);
00016   delete completions;
00017   completions = NULL;
00018   Transition::stop();
00019 }
00020 
00021 void CompletionTrans::doEvent() {
00022   switch ( event->getGeneratorID() ) {
00023 
00024   case EventBase::stateMachineEGID: {
00025     int numcomplete = 0;
00026     for ( unsigned int i=0; i<getSources().size(); i++ ) {
00027       if ( event->getSourceID() == reinterpret_cast<size_t>(getSources()[i]) )
00028         completions[i] = true;
00029       if ( completions[i] )
00030         ++numcomplete;
00031     }
00032     int const threshold = ( (minsrcs > 0) ? minsrcs : (int)getSources().size() );
00033     if ( numcomplete >= threshold )
00034       savedEvent = *event;
00035       erouter->addTimer(this, 9999, 0, false);
00036     break;
00037   }
00038 
00039   case EventBase::timerEGID:
00040     fire(savedEvent);
00041 
00042   default: ;
00043   }
00044 }
00045 

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3