#include <OTC/debug/trcswtch.hh> class OTC_TraceSwitch {
public:
inline ~OTC_TraceSwitch();
inline OTC_TraceSwitch(OTC_Boolean theState=OTCLIB_FALSE);
inline OTC_TraceSwitch(OTC_TraceSwitch const& theSwitch);
inline OTC_TraceSwitch& operator=(OTC_Boolean theState);
inline OTC_TraceSwitch& operator=( OTC_TraceSwitch const& theSwitch );
virtual OTC_Boolean enabled() const;
operator int() const;
OTC_TraceSwitch operator||( OTC_TraceSwitch const& theSwitch ) const;
OTC_TraceSwitch operator&&( OTC_TraceSwitch const& theSwitch ) const;
OTC_TraceSwitch operator!() const;
};
OTC_TraceSwitch
class provides a basis for creating ways of
being selective about what trace information is displayed. By
overriding the enabled()
member function in a derived class,
trace output can be dynamically enabled based on some aspect of
the operating environment. If the enabled()
function returns
OTCLIB_TRUE
, trace output is enabled for the statement using the
switch. The OTC_TraceSwitch
class and its derived classes should
be used in conjunction with the OTCLIB_TRACER
macro.
OTC_TraceSwitch LIBRARY(OTCLIB_TRUE);
OTCLIB_TRACER(LIBRARY) << "some text" << endl;
The macro OTCLIB_TRACESWITCH
can be used to create an instance
of the class. When the macro is used, the code will be
compiled into your code, only when the preprocessor symbol
OTCLIB_TRACE
is defined. The macro OTCLIB_SETTRACESWITCH
can
be used set the value of an instance of the OTC_TraceSwitch
class created using the OTCLIB_TRACESWITCH
macro.
OTCLIB_TRACESWITCH(LIBRARY,OTCLIB_TRUE);
OTCLIB_TRACESWITCH(PROGRAM,OTCLIB_TRUE);
OTCLIB_LOGGER(LIBRARY) << "some text" << endl;
OTCLIB_SETTRACESWITCH(PROGRAM,OTCLIB_FALSE);
OTCLIB_LOGGER(LIBRARY || PROGRAM) << "some text" << endl;
inline OTC_TraceSwitch(OTC_Boolean theState=OTCLIB_FALSE);
theState
. A value of OTCLIB_TRUE
enables the switch, otherwise the
switch is disabled.
inline OTC_TraceSwitch(OTC_TraceSwitch const& theSwitch);
theSwitch
.
inline OTC_TraceSwitch& operator=(OTC_Boolean theState);
theState
. A value of OTCLIB_TRUE
enables the switch, otherwise the switch
is disabled.
inline OTC_TraceSwitch& operator=(OTC_TraceSwitch const& theSwitch);
theSwitch
.
virtual OTC_Boolean enabled() const;
OTCLIB_TRUE
if the switch is
enabled, otherwise returns OTCLIB_FALSE
.
operator int() const;
0
if the switch is enabled and
-1
if the switch is disabled. Note that
this is the inverse of what you would
typically expect. This operator is to
satisfy the requirement that the macro
OTCLIB_TRACER
be passed an int
.
OTC_TraceSwitch operator||(OTC_TraceSwitch const& theSwitch) const;
theSwitch
are enabled.
OTC_TraceSwitch operator&&(OTC_TraceSwitch const& theSwitch) const;
theSwitch
are enabled.
OTC_TraceSwitch operator!() const;
OTC_Tracer