NAME
OTC_TraceTag -
A named trace switch.
SYNOPSIS
#include <OTC/debug/tracetag.hh>
class OTC_TraceTag : public OTC_TraceSwitch
{
public:
inline ~OTC_TraceTag();
OTC_TraceTag(char const* theName);
OTC_Boolean enabled() const;
inline int level() const;
inline char const* name() const;
static int set(char const* theName, int theLevel=0);
inline static OTC_TagInfo* switches();
OTC_TraceSwitch operator==(int theLevel) const;
OTC_TraceSwitch operator!=(int theLevel) const;
OTC_TraceSwitch operator<(int theLevel) const;
OTC_TraceSwitch operator<=(int theLevel) const;
OTC_TraceSwitch operator>(int theLevel) const;
OTC_TraceSwitch operator>=(int theLevel) const;
};
CLASS TYPE
Concrete
DESCRIPTION
The class OTC_TraceTag is a named version of a trace switch. The
name allows the status of the switch to be set through either an
environment variable, or program control. In addition, a trace
level may be associated with the named switch, when used in
conjunction with the comparison and logic operators, the trace
level allows expressions to be used to determine if trace output
should be generated for a particular statement. For example:
main()
{
OTC_TraceSwitch LIBRARY("LIBRARY");
OTC_TraceSwitch PROGRAM("PROGRAM");
OTCLIB_TRACER(LIBRARY || PROGRAM > 4) << "some text" << endl;
return 0;
}
The status of a named switch can be set using the environment
variable OTCLIB_TRACETAGS. When set, the environment variable
should contain a list of the named switches which should be
enabled. You may optionally include an assignment in the list
to set the trace level of a switch to a defined value. If you
do not set the trace level of a switch, it will default to 0.
If multiple trace tag names are listed they should be separated
by a single space.
OTCLIB_TRACETAGS="PROGRAM=5 LIBRARY" program
Macros are provided to allow you to create named switches. Code
for these macros will be compiled into your code, only
if the preprocessor symbol OTCLIB_TRACE is defined. These
macros are OTCLIB_TRACETAG, OTCLIB_STATIC_TRACETAG
and OTCLIB_SETRACETAG. The macro OTCLIB_STATIC_TRACEPATTERN
creates an instance of the class which has static extent.
OTCLIB_SETTRACETAG is provided to allow you to set the trace
level of a switch in your program. Setting the trace level of a
switch, will result in all switches of that name in your program
being updated.
OTCLIB_STATIC_TRACETAG(PROGRAM);
main()
{
OTCLIB_TRACETAG(MAIN);
OTCLIB_TRACER(PROGRAM) << "some text" << endl;
OTCLIB_SETTRACETAG(MAIN,0); // Make sure MAIN is enabled.
OTCLIB_TRACER(MAIN || PROGRAM) << "some text" << endl;
}
INITIALISATION
OTC_TraceTag(char const* theName);
Creates a named switch with tag theName.
QUERY/CHANGE
OTC_Boolean enabled() const;
Returns OTCLIB_TRUE if the switch is
enabled.
inline int level() const;
Returns the trace level of this named
switch.
inline char const* name() const;
Returns the name of this switch.
static int set(char const* theName, int theLevel=0);
Sets the trace level of all named switches
with the tag theName to theLevel.
inline static OTC_TagInfo* switches();
Returns a pointer to a list of objects for
each of the named switches.
COMPARISON OPERATORS
OTC_TraceSwitch operator==(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is the same as theLevel.
OTC_TraceSwitch operator!=(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is not the same as theLevel.
OTC_TraceSwitch operator<(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is less than theLevel.
OTC_TraceSwitch operator<=(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is less than or equal to
theLevel.
OTC_TraceSwitch operator>(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is is greater than theLevel.
OTC_TraceSwitch operator>=(int theLevel) const;
Returns an enabled switch if this switch
is enabled, and the trace level for this
switch is is greater than or equal to
theLevel.
SEE ALSO
OTC_TraceSwitch, OTC_TagInfo
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED