another directory rename: failstar -> fail
"failstar" sounds like a name for a cruise liner from the 80s. As "*" isn't a desirable part of directory names, just name the whole thing "fail/", the core parts being stored in "fail/core/". Additionally fixing two build system dependency issues: - missing jobserver -> protomessages dependency - broken bochs -> fail dependency (add_custom_target DEPENDS only allows plain file dependencies ... cmake for the win) git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@956 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
136
core/controller/EventList.cc
Normal file
136
core/controller/EventList.cc
Normal file
@ -0,0 +1,136 @@
|
||||
#include <set>
|
||||
|
||||
#include "EventList.hpp"
|
||||
#include "../SAL/SALInst.hpp"
|
||||
|
||||
namespace fi
|
||||
{
|
||||
|
||||
EventId EventList::add(BaseEvent* ev, ExperimentFlow* pExp)
|
||||
{
|
||||
assert(ev != NULL && "FATAL ERROR: Event (of base type BaseEvent*) cannot be NULL!");
|
||||
// a zero counter does not make sense
|
||||
assert(ev->getCounter() != 0);
|
||||
ev->setParent(pExp); // event is linked to experiment flow
|
||||
m_BufferList.push_back(ev);
|
||||
return (ev->getId());
|
||||
}
|
||||
|
||||
bool EventList::remove(BaseEvent* ev)
|
||||
{
|
||||
if(ev != NULL)
|
||||
{
|
||||
iterator it = std::find(m_BufferList.begin(), m_BufferList.end(), ev);
|
||||
if(it != end())
|
||||
{
|
||||
m_BufferList.erase(it);
|
||||
m_DeleteList.push_back(ev);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(iterator it = m_BufferList.begin(); it != m_BufferList.end();
|
||||
it++)
|
||||
m_DeleteList.push_back(*it);
|
||||
m_BufferList.clear();
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
EventList::iterator EventList::remove(iterator it)
|
||||
{
|
||||
return (m_remove(it, false));
|
||||
}
|
||||
|
||||
EventList::iterator EventList::m_remove(iterator it, bool skip_deletelist)
|
||||
{
|
||||
if(!skip_deletelist)
|
||||
m_DeleteList.push_back(*it);
|
||||
return (m_BufferList.erase(it));
|
||||
}
|
||||
|
||||
void EventList::getEventsOf(ExperimentFlow* pWhat,
|
||||
std::vector<BaseEvent*>& dest) const
|
||||
{
|
||||
assert(pWhat && "FATAL ERROR: The context cannot be NULL!");
|
||||
for(bufferlist_t::const_iterator it = m_BufferList.begin();
|
||||
it != m_BufferList.end(); it++)
|
||||
if((*it)->getParent() == pWhat)
|
||||
dest.push_back(*it);
|
||||
}
|
||||
|
||||
EventList::~EventList()
|
||||
{
|
||||
// nothing to do here yet
|
||||
}
|
||||
|
||||
BaseEvent* EventList::getEventFromId(EventId id)
|
||||
{
|
||||
// Loop through all events:
|
||||
for(bufferlist_t::iterator it = m_BufferList.begin();
|
||||
it != m_BufferList.end(); it++)
|
||||
if((*it)->getId() == id)
|
||||
return (*it);
|
||||
return (NULL); // Nothing found.
|
||||
}
|
||||
|
||||
void EventList::makeActive(BaseEvent* ev)
|
||||
{
|
||||
assert(ev && "FATAL ERROR: Event object pointer cannot be NULL!");
|
||||
ev->decreaseCounter();
|
||||
if (ev->getCounter() > 0) {
|
||||
return;
|
||||
}
|
||||
ev->resetCounter();
|
||||
if(remove(ev)) // remove event from buffer-list
|
||||
m_FireList.push_back(ev);
|
||||
}
|
||||
|
||||
EventList::iterator EventList::makeActive(iterator it)
|
||||
{
|
||||
assert(it != m_BufferList.end() &&
|
||||
"FATAL ERROR: Iterator has already reached the end!");
|
||||
BaseEvent* ev = *it;
|
||||
assert(ev && "FATAL ERROR: Event object pointer cannot be NULL!");
|
||||
ev->decreaseCounter();
|
||||
if (ev->getCounter() > 0) {
|
||||
return ++it;
|
||||
}
|
||||
ev->resetCounter();
|
||||
// Note: This is the one and only situation in which remove() should NOT
|
||||
// store the removed item in the delete-list.
|
||||
iterator it_next = m_remove(it, true); // remove event from buffer-list
|
||||
m_FireList.push_back(ev);
|
||||
return (it_next);
|
||||
}
|
||||
|
||||
void EventList::fireActiveEvents()
|
||||
{
|
||||
for(firelist_t::iterator it = m_FireList.begin();
|
||||
it != m_FireList.end(); it++)
|
||||
{
|
||||
if(std::find(m_DeleteList.begin(), m_DeleteList.end(), *it)
|
||||
== m_DeleteList.end()) // not found in delete-list?
|
||||
{
|
||||
m_pFired = *it;
|
||||
ExperimentFlow* pFlow = m_pFired->getParent();
|
||||
assert(pFlow && "FATAL ERROR: The event has no parent experiment (owner)!");
|
||||
sal::simulator.m_Flows.toggle(pFlow);
|
||||
}
|
||||
}
|
||||
m_FireList.clear();
|
||||
m_DeleteList.clear();
|
||||
}
|
||||
|
||||
size_t EventList::getContextCount() const
|
||||
{
|
||||
set<ExperimentFlow*> uniqueFlows; // count unique ExperimentFlow-ptr
|
||||
for(bufferlist_t::const_iterator it = m_BufferList.begin();
|
||||
it != m_BufferList.end(); it++)
|
||||
uniqueFlows.insert((*it)->getParent());
|
||||
return (uniqueFlows.size());
|
||||
}
|
||||
|
||||
} // end-of-namespace: fi
|
||||
Reference in New Issue
Block a user