Closed GoogleCodeExporter closed 9 years ago
I think I agree on that :)
Original comment by memono...@gmail.com
on 24 Aug 2010 at 8:05
Actually, I'd do the following (taking into account issue #111):
note: This could be done just for the "build" functions as logging is called
much less frequently and doesn't impact build performance.
struct rcBuildContext
{
void callLogFunctions( bool call ) { callLogFuncs = call }
void resetLog() { if (callLogFuncs) doResetLog(); }
void log(const rcLogCategory category, const char* format, ...) { if (callLogFuncs) { va_list args; va_start(args, format); log(category,format,va_args); va_end (args); }
void callBuildFunctions( bool call ) { callBuildFuncs = call }
void resetBuild() { if (callBuildFuncs) doResetBuild(); }
void startBuild(const rcBuildTimeLabel label ) { if (callBuildFuncs) doStartBuild(); }
void endBuild(const rcBuildTimeLabel label ) { if (callBuildFuncs) doEndBuild(); }
protected:
// Client overrides these functions:
virtual void doResetLog() {}
virtual void doLog(const rcLogCategory /*category*/, const char* /*format*/, va_list /*arg*/) {}
virtual void doResetBuild() {}
virtual void doStartBuild(const rcBuildTimeLabel /*label*/ ) {}
virtual void doEndBuild(const rcBuildTimeLabel /*label*/ ) {}
bool callLogFuncs;
bool callBuildFuncs;
};
Original comment by armstron...@gmail.com
on 24 Aug 2010 at 8:16
Getting better :)
That's pretty much in line with recommendations of Mr. Bloom too.
http://cbloomrants.blogspot.com/2010/07/07-26-10-virtual-functions.html
I'm against having the varargs stuff in a header, but other than that it looks
good. I might even bend over to passing it as a reference too.
Original comment by memono...@gmail.com
on 24 Aug 2010 at 8:27
>>I'm against having the varargs stuff in a header
Fair enough - I felt dirty adding varargs in to my code example...that varargs
stuff looks *nasty* :)
For performance reasons the non-virtual functions do need to be inline, but as
the logging functions are not performance critical I guess it'd be ok for the
implementation to be outside the header.
Original comment by armstron...@gmail.com
on 24 Aug 2010 at 9:02
P.S. rcBuildContext also needs a virtual destructor
Original comment by armstron...@gmail.com
on 24 Aug 2010 at 10:11
BTW: You could use a similar "bool callVirtualFunctions" technique on
dtQueryFilter. Instead of having the DT_VIRTUAL_QUERYFILTER define. Just an
idea. It would make the code a bit tidier :) Failing that, how about:
#define DT_VIRTUAL_QUERYFILTER virtual
...and use that in front of the function declarations - instead of repeating
the function twice:
DT_VIRTUAL_QUERYFILTER bool passFilter(const dtPolyRef ref,
const dtMeshTile* tile,
const dtPoly* poly) const;
Original comment by armstron...@gmail.com
on 24 Aug 2010 at 10:25
Fixed in R206.
Original comment by memono...@gmail.com
on 24 Aug 2010 at 6:00
Original comment by memono...@gmail.com
on 24 Aug 2010 at 6:01
Original issue reported on code.google.com by
armstron...@gmail.com
on 24 Aug 2010 at 8:00