home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 415_02 / rtti / src / trace.c < prev   
Encoding:
C/C++ Source or Header  |  1993-11-04  |  2.0 KB  |  101 lines

  1. #ifndef lint
  2. static const char sccsid[] = "%Z%%I%  %G% %U% %W%";
  3. #endif
  4. /*
  5.  * COMPONENT_NAME: (RTTI) Run-Time Type System for C++
  6.  *
  7.  * FUNCTIONS:
  8.  *
  9.  * ORIGINS: 27
  10.  *
  11.  * (C) COPYRIGHT International Business Machines Corp. 1992
  12.  * This work was supported by a grant from International Business
  13.  * Machines, Inc. These procedures are contributed to the public domain
  14.  * by International Business Machines Inc. "AS IS" without any warranty
  15.  * of any kind including the warranty of merchantability or fitness
  16.  * for a particular purpose.
  17.  *
  18.  *
  19.  * This is free software. Feel free to redistribute and/or modify it.
  20.  * Please send us e-mail and let us know if you have any problems
  21.  * or suggestions.
  22.  *
  23.  * Arindam Banerji
  24.  * axb@cse.nd.edu
  25.  *
  26.  */
  27.  
  28.  
  29. #ifdef   _KERNEL
  30. #include     <stdio.h>
  31. #else
  32. #include    <iostream.h>
  33. #endif   // _KERNEL
  34.  
  35.  
  36.  
  37. #include        "String.h"
  38. #include         "trace.h"
  39.  
  40. // trace.cc
  41. // A simple trace utility for the back-end
  42.  
  43. Trace::Trace(string name) : funcname(name) , type(FUNCTIONTYPE)
  44. {
  45. #ifdef    TRACE
  46.  
  47. #ifdef   _KERNEL
  48.        printf("Entering function %s\n", (char *) funcname ) ;
  49. #else
  50.        cerr << " Entering function " << funcname << endl ;
  51. #endif   // _KERNEL
  52.  
  53. #endif   // TRACE
  54.  }
  55.  
  56. Trace::Trace(string nm,string cls) :
  57.      funcname(nm),type(CLASSTYPE),classname(cls)
  58. {
  59. #ifdef    TRACE
  60.  
  61. #ifdef   _KERNEL
  62.   printf("Entering member %s in %s\n",(char *) funcname,
  63.                          (char *) classname) ;
  64. #else
  65.   cerr << "Entering member " << funcname << "in " << classname << endl ;
  66. #endif   // _KERNEL
  67.  
  68. #endif   // TRACE
  69.  }
  70.  
  71.  
  72. Trace::~Trace ()
  73.  {
  74.       if (type == CLASSTYPE)
  75.        {
  76. #ifdef    TRACE
  77.  
  78. #ifdef   _KERNEL
  79.        printf("Exiting member %s in %s\n", (char *) funcname,
  80.                     (char *) classname ) ;
  81. #else
  82.     cerr << "Exiting member " << funcname << "in " << classname << endl;
  83. #endif   // _KERNEL
  84.  
  85. #endif   // TRACE
  86.     }
  87.       else if ( type == FUNCTIONTYPE)
  88.     {
  89. #ifdef    TRACE
  90.  
  91. #ifdef   _KERNEL
  92.      printf("Exiting  %s\n", (char *) funcname) ;
  93. #else
  94.      cerr << "Exiting " << funcname <<  endl;
  95. #endif   // _KERNEL
  96.  
  97. #endif   // TRACE
  98.     }
  99.   } // destructor
  100.  
  101.