00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Trace.h 00006 * 00007 * $Id: Trace.h 80826 2008-03-04 14:51:23Z wotte $ 00008 * 00009 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_TRACE_H 00014 #define ACE_TRACE_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "ace/ACE_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00025 00026 /** 00027 * @class ACE_Trace 00028 * 00029 * @brief A C++ trace facility that keeps track of which methods are 00030 * entered and exited. 00031 * 00032 * This class uses C++ constructors and destructors to automate 00033 * the ACE_Trace nesting. In addition, thread-specific storage 00034 * is used to enable multiple threads to work correctly. 00035 */ 00036 class ACE_Export ACE_Trace 00037 { 00038 public: 00039 // = Initialization and termination methods. 00040 00041 /// Perform the first part of the trace, which prints out the string 00042 /// N, the LINE, and the ACE_FILE as the function is entered. 00043 ACE_Trace (const ACE_TCHAR *n, 00044 int line = 0, 00045 const ACE_TCHAR *file = ACE_TEXT ("")); 00046 00047 /// Perform the second part of the trace, which prints out the NAME 00048 /// as the function is exited. 00049 ~ACE_Trace (void); 00050 00051 // = Control the tracing level. 00052 /// Determine if tracing is enabled (return == 1) or not (== 0) 00053 static int is_tracing(void); 00054 00055 /// Enable the tracing facility. 00056 static void start_tracing (void); 00057 00058 /// Disable the tracing facility. 00059 static void stop_tracing (void); 00060 00061 /// Change the nesting indentation level. 00062 static void set_nesting_indent (int indent); 00063 00064 /// Get the nesting indentation level. 00065 static int get_nesting_indent (void); 00066 00067 /// Dump the state of an object. 00068 void dump (void) const; 00069 00070 private: 00071 // Keeps track of how deeply the call stack is nested (this is 00072 // maintained in thread-specific storage to ensure correctness in 00073 // multiple threads of control. 00074 00075 /// Name of the method we are in. 00076 const ACE_TCHAR *name_; 00077 00078 /// Keeps track of how far to indent per trace call. 00079 static int nesting_indent_; 00080 00081 /// Is tracing enabled? 00082 static int enable_tracing_; 00083 00084 /// Default values. 00085 enum 00086 { 00087 DEFAULT_INDENT = 3, 00088 DEFAULT_TRACING = 1 00089 }; 00090 }; 00091 00092 ACE_END_VERSIONED_NAMESPACE_DECL 00093 00094 #include /**/ "ace/post.h" 00095 00096 #endif /* ACE_TRACE_H */