Newer
Older

Martin Unzner
committed
#include <algorithm>
#include <vector>

Martin Unzner
committed
#include "BufferCache.hpp"
#include "Event.hpp"

Martin Unzner
committed
#include "EventList.hpp"

Martin Unzner
committed

Adrian Böckenkamp
committed
namespace fail {

Martin Unzner
committed

Adrian Böckenkamp
committed
template<class T>

Martin Unzner
committed
typename BufferCache<T>::iterator BufferCache<T>::makeActive(EventList &ev_list, BufferCache<T>::iterator idx)

Adrian Böckenkamp
committed
{

Martin Unzner
committed
assert(idx != end() &&

Martin Unzner
committed
"FATAL ERROR: Index larger than cache!");

Martin Unzner
committed
T ev = *idx;

Martin Unzner
committed
assert(ev && "FATAL ERROR: Object pointer cannot be NULL!");
ev->decreaseCounter();
if (ev->getCounter() > 0) {
return ++idx;
}
ev->resetCounter();
// Note: This is the one and only situation in which remove() should NOT
// store the removed item in the delete-list.
EventList::iterator it = std::find(ev_list.begin(), ev_list.end(), static_cast<BaseEvent*>(ev));
ev_list.m_remove(it, true); // remove event from buffer-list
ev_list.m_FireList.push_back(ev);
return erase(idx);
}

Martin Unzner
committed
// Declare here whatever instances of the template you are going to use:

Martin Unzner
committed
template class BufferCache<BPEvent*>;

Martin Unzner
committed
template class BufferCache<IOPortEvent*>;

Martin Unzner
committed

Adrian Böckenkamp
committed
} // end-of-namespace: fail