ThreadStream.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 #ifndef ICL_CORE_LOGGING_THREAD_STREAM_H_INCLUDED
29 #define ICL_CORE_LOGGING_THREAD_STREAM_H_INCLUDED
30 
31 #include <list>
32 #include <set>
33 
34 #include "icl_core/BaseTypes.h"
35 #include "icl_core/os_thread.h"
39 
40 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
41 # include "icl_core/Deprecate.h"
42 #endif
43 
44 #if defined ICL_CORE_QT_SUPPORT
45 class QString;
46 #endif
47 
48 #ifdef _IC_BUILDER_EIGEN_
49 #include <Eigen/Core>
50 #endif
51 
52 namespace icl_core {
53 namespace logging {
54 
55 class LogStream;
56 
59 {
60  friend class LogStream;
61 public:
64  void changeLevel(icl_core::logging::LogLevel level) { m_level = level; }
65 
68  icl_core::logging::LogLevel getLogLevel() const { return m_level; }
69 
74  void setClassname(const char *classname);
75 
80  void setObjectname(const char *objectname);
81 
86  void setFilename(const char *filename);
87 
92  void setFunction(const char *function);
93 
98  void setLine(size_t line);
99 
102  void setLineLogLevel(icl_core::logging::LogLevel line_log_level);
103 
113  void write(const char *buffer, size_t number_of_bytes, size_t protected_buffer_size=1);
114 
120  void printf(const char *fmt, ...);
121 
125  void flush();
126 
129  typedef ThreadStream& (*ThreadStreamFunc)(ThreadStream&);
130 
134  ThreadStream& operator << (ThreadStreamFunc func)
135  {
136  return (*func)(*this);
137  }
138 
140 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
141 
147 
154 
158  ICL_CORE_VC_DEPRECATE_STYLE void SetClassname(const char *classname)
160 
164  ICL_CORE_VC_DEPRECATE_STYLE void SetObjectname(const char *objectname)
166 
170  ICL_CORE_VC_DEPRECATE_STYLE void SetFilename(const char *filename)
172 
176  ICL_CORE_VC_DEPRECATE_STYLE void SetFunction(const char *function)
178 
182  ICL_CORE_VC_DEPRECATE_STYLE void SetLine(size_t line)
184 
188  ICL_CORE_VC_DEPRECATE_STYLE void SetLineLogLevel(icl_core::logging::LogLevel line_log_level)
190 
195  ICL_CORE_VC_DEPRECATE_STYLE void Write(const char *buffer, size_t number_of_bytes,
196  size_t protected_buffer_size=1)
198 
203  ICL_CORE_VC_DEPRECATE_STYLE void Printf(const char *fmt, ...) ICL_CORE_GCC_DEPRECATE_STYLE;
204 
210 
211 #endif
212 
214 private:
218  ThreadStream(LogStream *parent);
219 
221  { }
222 
225 
227  char m_filename[cDEFAULT_LOG_SIZE + 1];
228  size_t m_line;
229  char m_classname[cDEFAULT_LOG_SIZE + 1];
230  char m_objectname[cDEFAULT_LOG_SIZE + 1];
231  char m_function[cDEFAULT_LOG_SIZE + 1];
232  char m_data[cDEFAULT_LOG_SIZE + 1];
234  //char *m_write_pointer;
235 };
236 
242 {
243  stream.flush();
244  return stream;
245 }
246 
250 {
251  stream.write("\n", 1, 0);
252  return stream << flush;
253 }
254 
258 #if __WORDSIZE != 64
260 #endif
265 #if __WORDSIZE != 64
267 #endif
269 #ifdef _SYSTEM_DARWIN_
271 #endif
273 ICL_CORE_LOGGING_IMPORT_EXPORT ThreadStream& operator << (ThreadStream& stream, const std::string& text);
277 
278 #ifndef _SYSTEM_WIN32_
280 #endif
281 
282 #if defined ICL_CORE_QT_SUPPORT
284 #endif
285 
286 #ifdef _IC_BUILDER_EIGEN_
287 template <typename TScalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
290  const Eigen::Matrix<TScalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& matrix)
291 {
292  stream << "[";
293  for (int col = 0; col < matrix.cols(); ++col)
294  {
295  for (int row = 0; row < matrix.rows(); ++row)
296  {
297  stream << " " << matrix(row, col);
298  }
299  if (col < matrix.cols() - 1)
300  {
301  stream << " ;";
302  }
303  }
304  stream << " ]";
305  return stream;
306 }
307 #endif
308 
310 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
311 
318 {
319  stream.flush();
320  return stream;
321 }
322 
328 {
329  stream.write("\n", 1, 0);
330  return stream << flush;
331 }
332 #endif
333 
335 }
336 }
337 
338 #endif
ICL_CORE_OS_IMPL_NS::ThreadId ThreadId
Definition: os_thread.h:49
signed int int32_t
Definition: msvc_stdint.h:90
unsigned int uint32_t
Definition: msvc_stdint.h:93
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
#define ICL_CORE_GCC_DEPRECATE_STYLE_USE(arg)
Definition: Deprecate.h:67
Contains macros to deprecate classes, types, functions and variables.
signed char int8_t
Definition: msvc_stdint.h:88
Contains import/export definitions for the Win32 plattform.
void changeLevel(icl_core::logging::LogLevel level)
Definition: ThreadStream.h:64
ThreadStream & flush(ThreadStream &stream)
Definition: ThreadStream.h:241
#define ICL_CORE_VC_DEPRECATE_STYLE_USE(arg)
Definition: Deprecate.h:66
signed __int64 int64_t
Definition: msvc_stdint.h:102
unsigned __int64 uint64_t
Definition: msvc_stdint.h:103
icl_core::logging::LogLevel m_line_log_level
Definition: ThreadStream.h:226
unsigned char uint8_t
Definition: msvc_stdint.h:91
Implements a thread-safe logging framework.
Definition: LogStream.h:54
Contains global thread related functions, encapsulated into the icl_core::os namespace.
Contains constants used in icl_core::logging.
ThreadStream & endl(ThreadStream &stream)
Definition: ThreadStream.h:249
void write(const char *buffer, size_t number_of_bytes, size_t protected_buffer_size=1)
static char buffer[2000]
icl_core::logging::LogLevel m_level
Definition: ThreadStream.h:224
Contains icl_logging::LogLevel.
Implements the actual logging for an individual thread.
Definition: ThreadStream.h:58
ThreadStream & operator<<(ThreadStream &stream, const icl_core::TimeStamp &time_stamp)
Contains Interface base classes and base types.
signed short int16_t
Definition: msvc_stdint.h:89
icl_core::logging::LogLevel getLogLevel() const
Definition: ThreadStream.h:68
#define ICL_CORE_LOGGING_IMPORT_EXPORT
#define cDEFAULT_LOG_SIZE
Definition: Constants.h:36
unsigned short uint16_t
Definition: msvc_stdint.h:92
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58