diff --git a/src/simulator/observer.C b/src/simulator/observer.C index eae6e25ae988eb7f57474da88a4583ca7b92bdbd..545367c755209a158daff2741c70dcb02eb29ca3 100644 --- a/src/simulator/observer.C +++ b/src/simulator/observer.C @@ -64,11 +64,11 @@ void IfObserverInstance::copy(const IfInstance* inst) { m_bCut = obs->m_bCut; } -void IfObserverInstance::clearEventAt(const int i) { - // m_curLabel = m_curLabel->copy(); - // m_curLabel->setAt(i, IfEvent::NIL); +void IfObserverInstance::clearEventsUpTo(int i) { IfLabel l(*m_curLabel); - l.setAt(i, IfEvent::NIL); + i++; + while(--i >= 0) + l.setAt(i, IfEvent::NIL); m_curLabel = l.store(); } @@ -193,7 +193,7 @@ IfMessage* IfObserverInstance::if_obs_input_ext(unsigned sid, if_pid_type* pid) if ( evt->getKind() == IfEvent::INPUT && (sid == (unsigned)-1 || ((IfMessage*)evt->getAuxObj())->getSid() == sid ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(pid != NULL) *pid = evt->getAuxPid(); return (IfMessage*)evt->getAuxObj(); } @@ -222,7 +222,7 @@ IfMessage* IfObserverInstance::if_obs_discard_ext(unsigned sid, if_pid_type* pid if ( evt->getKind() == IfEvent::DISCARD && (sid == (unsigned)-1 || ((IfMessage*)evt->getAuxObj())->getSid() == sid ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(pid != NULL) *pid = evt->getAuxPid(); return (IfMessage*)evt->getAuxObj(); } @@ -255,7 +255,7 @@ IfMessage* IfObserverInstance::if_obs_output_ext(unsigned sid, unsigned index, if ( evt->getKind() == IfEvent::OUTPUT && (sid == (unsigned)-1 || ((IfMessage*)evt->getAuxObj())->getSid() == sid ) && !(index--) ) { - clearEventAt(i); + clearEventsUpTo(i); if(from != NULL) *from = evt->getPid(); if(via != NULL) *via = evt->getAuxPid(); if(to != NULL) { @@ -290,7 +290,7 @@ void IfObserverInstance::if_obs_fork_ext(unsigned process, if_pid_type* var, if_ if ( evt->getKind() == IfEvent::FORK && ( process == (unsigned)-1 || process == if_pid_proc(evt->getAuxPid()) ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(var != NULL) *var = evt->getAuxPid(); if(in != NULL) *in = evt->getPid(); return ; @@ -323,7 +323,7 @@ void IfObserverInstance::if_obs_kill_ext(unsigned process, if_pid_type* var, if_ if ( evt->getKind() == IfEvent::KILL && ( process == (unsigned)-1 || if_pid_proc( evt->getAuxPid() ) == process ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(var != NULL) *var = evt->getAuxPid(); if(in != NULL) *in = evt->getPid(); return ; @@ -354,7 +354,7 @@ IfMessage* IfObserverInstance::if_obs_deliver_ext(unsigned sid, if_pid_type* fro if ( evt->getKind() == IfEvent::DELIVER && (sid == (unsigned)-1 || ((IfMessage*)evt->getAuxObj())->getSid() == sid ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(from != NULL) *from = evt->getPid(); return (IfMessage*)evt->getAuxObj(); } @@ -383,7 +383,7 @@ void IfObserverInstance::if_obs_informal_ext(char* name, if_pid_type* in) if ( evt->getKind() == IfEvent::INFORMAL && ( name == NULL || !strcmp(name,(char*)evt->getAuxObj()) ) ) { - clearEventAt(i); + clearEventsUpTo(i); if(in != NULL) *in = evt->getPid(); return; } @@ -408,7 +408,7 @@ if_real_type IfObserverInstance::if_obs_probability_ext() IfEvent* evt = m_curLabel->getAt(i); if ( evt->getKind() == IfEvent::PROBABILITY ) { - clearEventAt(i); + clearEventsUpTo(i); return evt->getAuxProbability(); } } diff --git a/src/simulator/observer.h b/src/simulator/observer.h index dc5df7b0361e4210553b2dbe0f5b50c7f5e4590f..4b251a91d7f7c88adc5569e5556e889876f6bc8c 100644 --- a/src/simulator/observer.h +++ b/src/simulator/observer.h @@ -64,7 +64,7 @@ class IfObserverInstance : public IfInstance { DECLARE_STORABLE(IfInstance) protected: - void clearEventAt(const int); + void clearEventsUpTo(int); unsigned if_pid_obs_queue_length(const if_pid_type pid) const; protected: