Commit 71cdd1ec authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Added vlErrorMacro()

parent e3e2cb16
......@@ -231,6 +231,13 @@ type *Get##name () { \
// vlDebugMacro(<< "this is debug info" << this->SomeVariable << "\n");
//
#define vlDebugMacro(x) \
if (Debug) cerr << "In " __FILE__ << ", line " << __LINE__ << "\n : " x
if (Debug) cerr << "In " __FILE__ << ", line " << __LINE__ << "\n" << this->GetClassName() << ": " x
//
// This macro is used to print out errors
// vlErrorMacro(<< "Error message" << variable << "\n");
//
#define vlErrorMacro(x) \
cerr << "In " __FILE__ << ", line " << __LINE__ << "\n" << this->GetClassName() << ": " x
#endif
......@@ -124,7 +124,7 @@ char *vlCharArray::Resize(const int sz)
if ( (newArray = new char[newSize]) == 0 )
{
cerr << "Cannot allocate memory\n";
vlErrorMacro(<< "Cannot allocate memory\n");
return 0;
}
......
......@@ -126,7 +126,7 @@ float *vlFloatArray::Resize(const int sz)
if ( (newArray = new float[newSize]) == 0 )
{
cerr << "Cannot allocate memory\n";
vlErrorMacro(<< "Cannot allocate memory\n");
return 0;
}
......
......@@ -122,7 +122,7 @@ int *vlIntArray::Resize(const int sz)
if ( (newArray = new int[newSize]) == 0 )
{
cerr << "Cannot allocate memory\n";
vlErrorMacro(<< "Cannot allocate memory\n");
return 0;
}
......
......@@ -34,32 +34,22 @@ vlObject::~vlObject()
{
if (this->RefCount > 0)
{
cerr << this->GetClassName()
<<": Trying to delete object with non-zero refCount\n\n";
}
if (this->Debug)
{
cerr << this->GetClassName() << " " << this <<", Destructing!\n\n";
vlErrorMacro(<<": Trying to delete object with non-zero refCount\n\n");
}
vlDebugMacro(<< this <<", Destructing!\n\n");
}
void vlObject::Register(void *p)
{
this->RefCount++;
if ( this->Debug )
{
cerr << this->GetClassName() << " " << this
<< ", Registered by " << (void *)p << "\n\n";
}
vlDebugMacro(<< this << ", Registered by " << (void *)p << "\n\n");
}
void vlObject::UnRegister(void *p)
{
if ( this->Debug )
{
cerr << this->GetClassName() << " " << this
<< ", UnRegistered by " << (void *)p << "\n\n";
}
vlDebugMacro(<< this << ", UnRegistered by " << (void *)p << "\n\n");
if (--this->RefCount <= 0) delete this;
}
......
......@@ -125,7 +125,7 @@ short *vlShortArray::Resize(const int sz)
if ( (newArray = new short[newSize]) == 0 )
{
cerr << "Cannot allocate memory\n";
vlErrorMacro(<< "Cannot allocate memory\n");
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment