Listener handler revisited (onTrigger toggles the current flow), typo.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1713 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -8,6 +8,12 @@ BaseListener::~BaseListener()
|
|||||||
simulator.removeListener(this);
|
simulator.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseListener::onTrigger()
|
||||||
|
{
|
||||||
|
assert(m_Parent && "FATAL ERROR: The listener has no parent!");
|
||||||
|
simulator.toggle(m_Parent);
|
||||||
|
}
|
||||||
|
|
||||||
bool TroubleListener::isMatching(const TroubleEvent* pEv) const
|
bool TroubleListener::isMatching(const TroubleEvent* pEv) const
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < m_WatchNumbers.size(); i++) {
|
for (unsigned i = 0; i < m_WatchNumbers.size(); i++) {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool onAddition() { return true; }
|
virtual bool onAddition() { return true; }
|
||||||
/**
|
/**
|
||||||
* This method is called when an experiment flow removes an listener from
|
* This method is called when an experiment flow removes a listener from
|
||||||
* the listener-management by calling \c removeListener(), \c clearListeners()
|
* the listener-management by calling \c removeListener(), \c clearListeners()
|
||||||
* or by deleting a complete flow (\c removeFlow()). More specifically, this
|
* or by deleting a complete flow (\c removeFlow()). More specifically, this
|
||||||
* listener handler will be called *before* the listener is actually deleted.
|
* listener handler will be called *before* the listener is actually deleted.
|
||||||
@ -50,11 +50,11 @@ public:
|
|||||||
virtual void onDeletion() { }
|
virtual void onDeletion() { }
|
||||||
/**
|
/**
|
||||||
* This method is called when an previously added listener is about to be
|
* This method is called when an previously added listener is about to be
|
||||||
* triggered by the simulator-backend. More specifically, this listener handler
|
* triggered by the simulator-backend. \c onTrigger() toggles the experiment
|
||||||
* will be called *before* the listener is actually triggered, i.e. before the
|
* flow specified by \c BaseListener::getParent(). You can use this handler
|
||||||
* corresponding coroutine is toggled.
|
* as a callback function by overwriting this method appropriately.
|
||||||
*/
|
*/
|
||||||
virtual void onTrigger() { }
|
virtual void onTrigger();
|
||||||
/**
|
/**
|
||||||
* Decreases the listener counter by one. When this counter reaches zero, the
|
* Decreases the listener counter by one. When this counter reaches zero, the
|
||||||
* listener will be triggered.
|
* listener will be triggered.
|
||||||
|
|||||||
@ -236,10 +236,8 @@ void ListenerManager::triggerActiveListeners()
|
|||||||
m_pFired = *it;
|
m_pFired = *it;
|
||||||
// Inform (call) the simulator's (internal) listener handler that we are about
|
// Inform (call) the simulator's (internal) listener handler that we are about
|
||||||
// to trigger an listener (*before* we actually toggle the experiment flow):
|
// to trigger an listener (*before* we actually toggle the experiment flow):
|
||||||
m_pFired->onTrigger();
|
m_pFired->onDeletion(); // the listener has already been deleted (in the buffer-list)!
|
||||||
ExperimentFlow* pFlow = m_pFired->getParent();
|
m_pFired->onTrigger(); // onTrigger will toggle the correct coroutine
|
||||||
assert(pFlow && "FATAL ERROR: The listener has no parent experiment (owner)!");
|
|
||||||
simulator.m_Flows.toggle(pFlow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_FireList.clear();
|
m_FireList.clear();
|
||||||
|
|||||||
@ -235,6 +235,11 @@ public:
|
|||||||
* @see ListenerManager::dereference()
|
* @see ListenerManager::dereference()
|
||||||
*/
|
*/
|
||||||
inline BaseListener* dereference(index_t idx) { return m_LstList.dereference(idx); }
|
inline BaseListener* dereference(index_t idx) { return m_LstList.dereference(idx); }
|
||||||
|
/**
|
||||||
|
* Toggles the provided experiment flow by activating its coroutine.
|
||||||
|
* @param pfl the experiment flow to be activated
|
||||||
|
*/
|
||||||
|
void toggle(ExperimentFlow* pfl) { m_Flows.toggle(pfl); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME (see SimulatorController.cc): Weird, homeless global variable
|
// FIXME (see SimulatorController.cc): Weird, homeless global variable
|
||||||
|
|||||||
Reference in New Issue
Block a user