NAME
OTC_TraceSwitch -
Switch class for customising trace output.
SYNOPSIS
#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;
};
CLASS TYPE
Concrete
DESCRIPTION
The 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;
INITIALISATION
inline OTC_TraceSwitch(OTC_Boolean theState=OTCLIB_FALSE);
Sets the state of the switch to
theState. A value of OTCLIB_TRUE
enables the switch, otherwise the
switch is disabled.
inline OTC_TraceSwitch(OTC_TraceSwitch const& theSwitch);
Sets the state of this switch to the same
state as theSwitch.
inline OTC_TraceSwitch& operator=(OTC_Boolean theState);
Sets the state of this switch to
theState. A value of OTCLIB_TRUE
enables the switch, otherwise the switch
is disabled.
inline OTC_TraceSwitch& operator=(OTC_TraceSwitch const& theSwitch);
Sets the state of this switch to the same
value as theSwitch.
QUERY
virtual OTC_Boolean enabled() const;
Returns OTCLIB_TRUE if the switch is
enabled, otherwise returns OTCLIB_FALSE.
operator int() const;
Returns 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.
LOGIC OPERATIONS
OTC_TraceSwitch operator||(OTC_TraceSwitch const& theSwitch) const;
Returns an enabled switch if either
this switch or theSwitch are enabled.
OTC_TraceSwitch operator&&(OTC_TraceSwitch const& theSwitch) const;
Returns an enabled switch if both this
switch and theSwitch are enabled.
OTC_TraceSwitch operator!() const;
Returns an enabled switch if this switch
is not enabled.
SEE ALSO
OTC_Tracer
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED