Document return values
[ACE_TAO.git] / ACE / ace / Trace.h
blobeb49cf2fdb0795c1dafa884c7153495f59ca4400
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Trace.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_TRACE_H
12 #define ACE_TRACE_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 /**
25 * @class ACE_Trace
27 * @brief A C++ trace facility that keeps track of which methods are
28 * entered and exited.
30 * This class uses C++ constructors and destructors to automate
31 * the ACE_Trace nesting. In addition, thread-specific storage
32 * is used to enable multiple threads to work correctly.
34 class ACE_Export ACE_Trace
36 public:
37 /// Perform the first part of the trace, which prints out the string
38 /// N, the LINE, and the ACE_FILE as the function is entered.
39 ACE_Trace (const ACE_TCHAR *n,
40 int line = 0,
41 const ACE_TCHAR *file = ACE_TEXT (""));
43 /// Perform the second part of the trace, which prints out the NAME
44 /// as the function is exited.
45 ~ACE_Trace ();
47 /// Declare the dynamic allocation hooks.
48 ACE_ALLOC_HOOK_DECLARE;
50 // = Control the tracing level.
51 /// Determine if tracing is enabled or not
52 static bool is_tracing();
54 /// Enable the tracing facility.
55 static void start_tracing ();
57 /// Disable the tracing facility.
58 static void stop_tracing ();
60 /// Change the nesting indentation level.
61 static void set_nesting_indent (int indent);
63 /// Get the nesting indentation level.
64 static int get_nesting_indent ();
66 /// Dump the state of an object.
67 void dump () const;
69 private:
70 // Keeps track of how deeply the call stack is nested (this is
71 // maintained in thread-specific storage to ensure correctness in
72 // multiple threads of control.
74 /// Name of the method we are in.
75 const ACE_TCHAR *name_;
77 /// Keeps track of how far to indent per trace call.
78 static int nesting_indent_;
80 /// Is tracing enabled?
81 static bool enable_tracing_;
83 /// Default values.
84 enum
86 DEFAULT_INDENT = 3,
87 DEFAULT_TRACING = 1
91 ACE_END_VERSIONED_NAMESPACE_DECL
93 #include /**/ "ace/post.h"
95 #endif /* ACE_TRACE_H */