Commit 2cb7bbd2 authored by iulian's avatar iulian
Browse files

change to semantics of observer eventset: an observation will remove events...

change to semantics of observer eventset: an observation will remove events preceding the one observed
parent cd842c6e
......@@ -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();
}
}
......
......@@ -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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment