bugfixes in overall coroutine handling to allow the overwriting of onTrigger.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1721 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -24,6 +24,9 @@ CoroutineManager::~CoroutineManager() { }
|
||||
|
||||
void CoroutineManager::toggle(ExperimentFlow* flow)
|
||||
{
|
||||
assert((co_current() != m_simCoro || flow != SIM_FLOW) &&
|
||||
"FATAL ERROR: We are already in the simulators coroutine flow! \
|
||||
(Maybe you forgot to overwrite the (default) onTrigger() method?)");
|
||||
m_togglerstack.push(co_current());
|
||||
//std::cerr << "CORO toggle from " << m_togglerstack.top() << " to ";
|
||||
if (flow == SIM_FLOW) {
|
||||
@ -86,8 +89,7 @@ ExperimentFlow* CoroutineManager::getCurrent()
|
||||
if (it->second == cr)
|
||||
return it->first;
|
||||
|
||||
assert(false && "FATAL ERROR: The current flow could not be retrieved!");
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ExperimentFlow* CoroutineManager::SIM_FLOW = NULL;
|
||||
|
||||
@ -13,7 +13,14 @@ int interrupt_to_fire = -1;
|
||||
bool SimulatorController::addListener(BaseListener* li)
|
||||
{
|
||||
assert(li != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!");
|
||||
m_LstList.add(li, m_Flows.getCurrent());
|
||||
// If addListener() was called from onTrigger(), there is no parent
|
||||
// to retrieve/assign. In this case, we simple expect the parent-member
|
||||
// to be valid ('as is'). (Otherwise, the current flow is retrieved by
|
||||
// calling CoroutineManager::getCurrent().)
|
||||
ExperimentFlow* pFlow = m_Flows.getCurrent();
|
||||
if (pFlow == CoroutineManager::SIM_FLOW)
|
||||
pFlow = li->getParent();
|
||||
m_LstList.add(li, pFlow);
|
||||
// Call the common postprocessing function:
|
||||
if (!li->onAddition()) { // If the return value signals "false"...,
|
||||
m_LstList.remove(li); // ...skip the addition
|
||||
|
||||
@ -19,7 +19,11 @@ public:
|
||||
bool addListener(fail::BPSingleListener* sli)
|
||||
{
|
||||
assert(sli != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!");
|
||||
m_LstList.add(sli, m_Flows.getCurrent());
|
||||
// Check whether we were called from onTrigger (see SimulatorController.cc@addListener).
|
||||
ExperimentFlow* pFlow = m_Flows.getCurrent();
|
||||
if (pFlow == CoroutineManager::SIM_FLOW)
|
||||
pFlow = sli->getParent();
|
||||
m_LstList.add(sli, pFlow);
|
||||
// Call the common postprocessing function:
|
||||
if (!sli->onAddition()) { // If the return value signals "false"...,
|
||||
m_LstList.remove(sli); // ...skip the addition
|
||||
@ -32,7 +36,11 @@ public:
|
||||
bool addListener(fail::BPRangeListener* rli)
|
||||
{
|
||||
assert(rli != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!");
|
||||
m_LstList.add(rli, m_Flows.getCurrent());
|
||||
// Check whether we were called from onTrigger (see above).
|
||||
ExperimentFlow* pFlow = m_Flows.getCurrent();
|
||||
if (pFlow == CoroutineManager::SIM_FLOW)
|
||||
pFlow = rli->getParent();
|
||||
m_LstList.add(rli, pFlow);
|
||||
// Call the common postprocessing function:
|
||||
if (!rli->onAddition()) { // If the return value signals "false"...,
|
||||
m_LstList.remove(rli); // ...skip the addition
|
||||
|
||||
Reference in New Issue
Block a user