Rework error reporting to allow either immediate or amalgamated error reporting

This commit is contained in:
Alex Harker
2019-11-24 23:09:17 +00:00
parent 678e987a40
commit 6dd0c4a64f
3 changed files with 33 additions and 17 deletions
+18 -15
View File
@@ -37,19 +37,6 @@ class FrameLib_ErrorReporter
public:
/**
@class HostNotifier
@brief a virtual struct used to supply a method for notifying the host of errors.
*/
struct HostNotifier : public FrameLib_Proxy
{
virtual void notify() = 0;
};
/**
@class ErrorReport
@@ -158,6 +145,7 @@ public:
size_t size() const { return mReportsSize; }
ConstIterator begin() const { return mReports; }
ConstIterator last() const { return mReports + mReportsSize - 1; }
ConstIterator end() const { return mReports + mReportsSize; }
bool isFull() const { return mFull; }
@@ -259,6 +247,19 @@ public:
bool mFull;
};
/**
@class HostNotifier
@brief a virtual struct used to supply a method for notifying the host of errors.
*/
struct HostNotifier : public FrameLib_Proxy
{
virtual bool notify(const ErrorReport& report) = 0;
};
// Constructor
FrameLib_ErrorReporter(HostNotifier *notifier) : mNotifier(notifier), mNotified (false), mReports(new ErrorList()) {}
@@ -272,8 +273,10 @@ public:
if (mNotifier && !mNotified)
{
mNotifier->notify();
mNotified = true;
if (mNotifier->notify(*(mReports->last())))
mReports->remove();
else
mNotified = true;
}
}
@@ -42,9 +42,10 @@ public:
qelem_free(mQelem);
}
void notify()
bool notify(const FrameLib_ErrorReporter::ErrorReport& report) override
{
qelem_set(mQelem);
return false;
}
static void errorReport(FrameLib_MaxGlobals* x)
+13 -1
View File
@@ -27,6 +27,17 @@ static void FLTest_Dtor(FrameLib_SC_UGen* unit);
struct SC_FrameLib_Global
{
class Notifier : public FrameLib_ErrorReporter::HostNotifier
{
bool notify(const FrameLib_ErrorReporter::ErrorReport& report) override
{
char errorText[512];
report.getErrorText(errorText, 512);
ft->fPrint("error: %s\n", errorText);
return true;
}
};
struct InitParameters
{
InitParameters() : mSerial(nullptr), mInputsSerial(nullptr) {}
@@ -56,7 +67,7 @@ struct SC_FrameLib_Global
SC_FrameLib_Global() : mGlobal(nullptr)
{
FrameLib_Global::get(&mGlobal);
FrameLib_Global::get(&mGlobal, &mNotifier);
}
~SC_FrameLib_Global()
@@ -149,6 +160,7 @@ struct SC_FrameLib_Global
FrameLib_Global *mGlobal;
Notifier mNotifier;
std::vector<InitParameters> mInitParameters;
};