All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LogSection.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_UTIL_LOGGING_LOGSECTION_H_
23 #define _BLAZE_UTIL_LOGGING_LOGSECTION_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <new>
31 #include <sstream>
32 #include <blaze/system/Logging.h>
34 
35 
36 namespace blaze {
37 
38 namespace logging {
39 
40 //=================================================================================================
41 //
42 // CLASS DEFINITION
43 //
44 //=================================================================================================
45 
46 //*************************************************************************************************
55 {
56  public:
57  //**Constructors********************************************************************************
60  LogSection( LogLevel level );
61  inline LogSection( const LogSection& ls );
63  //**********************************************************************************************
64 
65  //**Destructor**********************************************************************************
68  ~LogSection();
70  //**********************************************************************************************
71 
72  //**Conversion operators************************************************************************
75  inline operator bool() const;
77  //**********************************************************************************************
78 
79  //**Logging functions***************************************************************************
82  template< typename Type > inline void log ( const Type& message );
83  void commit();
85  //**********************************************************************************************
86 
87  private:
88  //**Member variables****************************************************************************
92  std::stringstream message_;
93 
94  //**********************************************************************************************
95 
96  //**Forbidden operations************************************************************************
99  LogSection& operator=( const LogSection& );
100 
101  void* operator new ( std::size_t ) /*throw( std::bad_alloc )*/;
102  void* operator new[]( std::size_t ) /*throw( std::bad_alloc )*/;
103  void* operator new ( std::size_t, const std::nothrow_t& ) /*throw()*/;
104  void* operator new[]( std::size_t, const std::nothrow_t& ) /*throw()*/;
105 
106  void operator delete ( void* ) /*throw()*/;
107  void operator delete[]( void* ) /*throw()*/;
108  void operator delete ( void*, const std::nothrow_t& ) /*throw()*/;
109  void operator delete[]( void*, const std::nothrow_t& ) /*throw()*/;
111  //**********************************************************************************************
112 };
113 //*************************************************************************************************
114 
115 
116 
117 
118 //=================================================================================================
119 //
120 // CONSTRUCTORS
121 //
122 //=================================================================================================
123 
124 //*************************************************************************************************
133  : level_( ls.level_ ) // The logging level of the log section
134 {}
135 //*************************************************************************************************
136 
137 
138 
139 
140 //=================================================================================================
141 //
142 // CONVERSION OPERATOR
143 //
144 //=================================================================================================
145 
146 //*************************************************************************************************
151 inline LogSection::operator bool() const
152 {
153  return true;
154 }
155 //*************************************************************************************************
156 
157 
158 
159 
160 //=================================================================================================
161 //
162 // LOGGING FUNCTIONS
163 //
164 //=================================================================================================
165 
166 //*************************************************************************************************
172 template< typename Type > // Type of the log message
173 inline void LogSection::log( const Type& message )
174 {
175  message_ << message;
176 }
177 //*************************************************************************************************
178 
179 
180 
181 
182 //=================================================================================================
183 //
184 // GLOBAL OPERATORS
185 //
186 //=================================================================================================
187 
188 //*************************************************************************************************
191 template< typename Type >
192 inline LogSection& operator<<( LogSection& logsection, const Type& message );
194 //*************************************************************************************************
195 
196 
197 //*************************************************************************************************
205 template< typename Type > // Type of the log message
206 inline LogSection& operator<<( LogSection& logsection, const Type& message )
207 {
208  logsection.log( message );
209  return logsection;
210 }
211 //*************************************************************************************************
212 
213 } // namespace logging
214 
215 } // namespace blaze
216 
217 #endif