Sources/Tracer.cp

/*
    File:       Tracer.cp
 
    Contains:   TTracer is an example of a stack/heap based tracing class, which could be
                used for tracing memory leaks and keeping track of created objects
                TTracer.cp contains the class body information for the initial class construction.
 
    Written by: Kent Sandvik    
 
    Copyright:  Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
// Include files
#ifndef _TRACER_
#include "Tracer.h"
#endif
 
 
// _________________________________________________________________________________________________________ //
// TTracer class member function implementations
 
//  CONSTRUCTORS & DESTRUCTORS
#pragma segment Tracer                       
TTracer::TTracer(const char* label,
                 const char* file,
                 int line) :
    fLabel(label),
    fFile(file),
    fLine(line)
// Default constructor.
{
    fReferenceCount++;
 
    cout << "File " << fFile << " ; Line " << fLine << "  #+++ constructor event in " << fLabel << " (reference count = " << fReferenceCount << ")\n";
}
 
 
#pragma segment Tracer
TTracer::~TTracer()
// Default destructor.
{
    fReferenceCount--;
    cout << "File " << fFile << " ; Line " << fLine << "  #--- destructor  event in " << fLabel << " (reference count = " << fReferenceCount << ")\n";
}
 
 
// GLOBAL FUNCTIONS
int TTracer::fReferenceCount = 0;               // initialize with zero value
 
// this will construct a global/universal tracer
TTracer gGlobalTracer("gGlobalTracer",
                      TRACEPOINT);
 
 
// _________________________________________________________________________________________________________ //
 
/*  Change History (most recent last):
  No        Init.   Date        Comment
  1         khs     7/10/92     New file
*/