topical media & game development
professional-program-21-ErrorCorrelatorStack-ErrorCorrelator.c
? /
professional-program-21-ErrorCorrelatorStack-ErrorCorrelator.c
include <ErrorCorrelator.h>
using namespace std;
bool operator<(const Error& lhs, const Error& rhs)
{
return (lhs.mPriority < rhs.mPriority);
}
ostream& operator<<(ostream& str, const Error& err)
{
str << err.mError << " (priority " << err.mPriority << ")";
return (str);
}
void ErrorCorrelator::addError(const Error& error)
{
mErrors.push(error);
}
Error ErrorCorrelator::getError() throw (out_of_range)
{
//
// If there are no more errors, throw an exception.
//
if (mErrors.empty()) {
throw (out_of_range("No elements!"));
}
// Save the top element
Error top = mErrors.top();
// Remove the top element.
mErrors.pop();
// Return the saved element.
return (top);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.