KWStyle - itkThreadLogger.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkThreadLogger.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17
18 #ifndef __itkThreadLogger_h
19 #define __itkThreadLogger_h
20
21 #if defined(_MSC_VER)
22 LEN,IND ***//Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug)
23 IND ***#pragma warning( disable : 4786 )
24 LEN,IND **// warning C4503: 'insert' : decorated name length exceeded, name was truncated
25 IND **#pragma warning ( disable : 4503 )
26 #endif
27
28
29 #include <string>
30 #include <queue>
31
32 #include "itkMacro.h"
33 #include "itkMultiThreader.h"
34 #include "itkLogger.h"
35 #include "itkSimpleFastMutexLock.h"
36
37
38 EML
39 namespace itk
40 {
41 /** \class ThreadLogger
42 LEN  *  \brief Class ThreadLogger is meant for providing logging service as a separate thread.
43  *
44  *
45  *
46  * \author Hee-Su Kim, Compute Science Dept. Kyungpook National University,
47  *                     ISIS Center, Georgetown University.
48  *
49  *
50  *  \ingroup OSSystemObjects LoggingObjects                    
51  */
52
53 class ITKCommon_EXPORT ThreadLogger : public Logger
54 {
55
56 public:
57   
58   typedef ThreadLogger  Self;
59 TDA   typedef Logger  Superclass;
60 TDA   typedef SmartPointer<Self>  Pointer;
61 TDA   typedef SmartPointer<const Self>  ConstPointer;
62
63   /** Run-time type information (and related methods). */
64   itkTypeMacro( ThreadLogger, Logger );
65
66   /** New macro for creation of through a Smart Pointer */
67   itkNewMacro( Self );
68
69   typedef  Logger::OutputType   OutputType;
70
71   typedef  Logger::PriorityLevelType  PriorityLevelType;
72
73   /** Definition of types of operations for ThreadLogger. */
74   typedef enum 
75 IND **{ 
76     SET_PRIORITY_LEVEL,
77     SET_LEVEL_FOR_FLUSHING,
78     ADD_LOG_OUTPUT,
79     WRITE,
80     FLUSH
81 IND **} OperationType;
82
83
84   /** Set the priority level for the current logger. Only messages that have
85    * priorities equal or greater than the one set here will be posted to the
86    * current outputs */
87   virtual void SetPriorityLevel( PriorityLevelType level );
88
89   /** Get the priority level for the current logger. Only messages that have
90    * priorities equal or greater than the one set here will be posted to the
91    * current outputs */
92   virtual PriorityLevelType GetPriorityLevel() const;
93
94   virtual void SetLevelForFlushing( PriorityLevelType level );
95
96   virtual PriorityLevelType GetLevelForFlushing() const;
97
98   /** Registers another output stream with the multiple output. */
99   virtual void AddLogOutput( OutputType* output );
100
101   virtual void Write(PriorityLevelType level, std::string const & content);
102
103   virtual void Flush();
104
105 protected:
106
107   /** Constructor */
108   ThreadLogger();
109
110   /** Destructor */
111   virtual ~ThreadLogger();
112
113   /** Print contents of a ThreadLogger */
114   virtual void PrintSelf(std::ostream &os, Indent indent) const;
115
116   static ITK_THREAD_RETURN_TYPE ThreadFunction(void*);
117
118 private:
119
120   typedef std::queue<OperationType> OperationContainerType;
121
122   typedef std::queue<std::string>  MessageContainerType;
123
124   typedef std::queue<PriorityLevelType>  LevelContainerType;
125
126   typedef std::queue<OutputType::Pointer>  OutputContainerType;
127
128   MultiThreader::Pointer  m_Threader;
129
130   int m_ThreadID;
131
132   OperationContainerType  m_OperationQ;
133
134   MessageContainerType  m_MessageQ;
135
136   LevelContainerType  m_LevelQ;
137
138   OutputContainerType m_OutputQ;
139
140   SimpleFastMutexLock m_Mutex;
141
142   SimpleFastMutexLock m_WaitMutex;
143
144 };  // class ThreadLogger
145
146
147 // namespace itk
148
149
150 #endif  // __itkThreadLogger_h
151

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:50PM
© Kitware Inc.