FunctionTrace.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_TRACING_FUNCTIONTRACE_H_
36 #define _BLAZE_UTIL_TRACING_FUNCTIONTRACE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iostream>
44 #include <new>
45 #include <sstream>
46 #include <string>
47 #include <blaze/system/Debugging.h>
48 #include <blaze/system/Signature.h>
49 #include <blaze/system/SMP.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
69 {
70  public:
71  //**Constructors********************************************************************************
74  inline FunctionTrace( const std::string& file, const std::string& function );
76  //**********************************************************************************************
77 
78  //**Destructor**********************************************************************************
81  inline ~FunctionTrace();
83  //**********************************************************************************************
84 
85  //**Forbidden operations************************************************************************
88  FunctionTrace( const FunctionTrace& ) = delete;
89  FunctionTrace( FunctionTrace&& ) = delete;
90 
91  FunctionTrace& operator=( const FunctionTrace& ) = delete;
92  FunctionTrace& operator=( FunctionTrace&& ) = delete;
93 
94  void* operator new ( std::size_t ) = delete;
95  void* operator new[]( std::size_t ) = delete;
96  void* operator new ( std::size_t, const std::nothrow_t& ) noexcept = delete;
97  void* operator new[]( std::size_t, const std::nothrow_t& ) noexcept = delete;
98 
99  void operator delete ( void* ) noexcept = delete;
100  void operator delete[]( void* ) noexcept = delete;
101  void operator delete ( void*, const std::nothrow_t& ) noexcept = delete;
102  void operator delete[]( void*, const std::nothrow_t& ) noexcept = delete;
104  //**********************************************************************************************
105 
106  private:
107  //**Member variables****************************************************************************
110  std::string file_;
111  std::string function_;
112 
113  //**********************************************************************************************
114 };
115 //*************************************************************************************************
116 
117 
118 
119 
120 //=================================================================================================
121 //
122 // CONSTRUCTORS
123 //
124 //=================================================================================================
125 
126 //*************************************************************************************************
132 inline FunctionTrace::FunctionTrace( const std::string& file, const std::string& function )
133  : file_ ( file ) // The file name the traced function is contained in
134  , function_( function ) // The name of the traced function
135 {
136  std::ostringstream oss;
137  oss << " + ";
138 
139 #if BLAZE_OPENMP_PARALLEL_MODE
140  oss << "[Thread " << omp_get_thread_num() << "]";
141 #else
142  oss << "[Thread " << std::this_thread::get_id() << "]";
143 #endif
144 
145  oss << " Entering function '" << function_ << "' in file '" << file_ << "'\n";
146  std::cerr << oss.str();
147 }
148 //*************************************************************************************************
149 
150 
151 
152 
153 //=================================================================================================
154 //
155 // DESTRUCTOR
156 //
157 //=================================================================================================
158 
159 //*************************************************************************************************
163 {
164  std::ostringstream oss;
165  oss << " - ";
166 
167 #if BLAZE_OPENMP_PARALLEL_MODE
168  oss << "[Thread " << omp_get_thread_num() << "]";
169 #else
170  oss << "[Thread " << std::this_thread::get_id() << "]";
171 #endif
172 
173  oss << " Leaving function '" << function_ << "' in file '" << file_ << "'\n";
174  std::cerr << oss.str();
175 }
176 //*************************************************************************************************
177 
178 } // namespace blaze
179 
180 #endif
Header file for a compiler independent type/function signature macro.
FunctionTrace(const std::string &file, const std::string &function)
Constructor for the FunctionTrace class.
Definition: FunctionTrace.h:132
RAII object for function tracing.The FunctionTrace class is an auxiliary helper class for the tracing...
Definition: FunctionTrace.h:68
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
System settings for the shared-memory parallelization.
std::string file_
The file name the traced function is contained in.
Definition: FunctionTrace.h:110
~FunctionTrace()
Destructor for the FunctionTrace class.
Definition: FunctionTrace.h:162
std::string function_
The name of the traced function.
Definition: FunctionTrace.h:111
System settings for the debugging policy of the Blaze library.