ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkLoggerThreadWrapper.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkLoggerThreadWrapper_h
19 #define __itkLoggerThreadWrapper_h
20 
21 #include <string>
22 #include <queue>
23 
24 #include "itkMultiThreader.h"
25 #include "itkSimpleFastMutexLock.h"
26 
27 namespace itk
28 {
39 template< class SimpleLoggerType >
40 class LoggerThreadWrapper:public SimpleLoggerType
41 {
42 public:
43 
45  typedef SimpleLoggerType Superclass;
48 
50  itkTypeMacro(LoggerThreadWrapper, SimpleLoggerType);
51 
53  itkNewMacro(Self);
54 
55  typedef typename SimpleLoggerType::OutputType OutputType;
56  typedef typename SimpleLoggerType::PriorityLevelType PriorityLevelType;
57  typedef unsigned int DelayType;
58 
60  typedef enum {
66  } OperationType;
67 
71  virtual void SetPriorityLevel(PriorityLevelType level);
72 
76  virtual PriorityLevelType GetPriorityLevel() const;
77 
78  virtual void SetLevelForFlushing(PriorityLevelType level);
79 
80  virtual PriorityLevelType GetLevelForFlushing() const;
81 
85  virtual void SetDelay(DelayType delay);
86 
90  virtual DelayType GetDelay() const;
91 
93  virtual void AddLogOutput(OutputType *output);
94 
95  virtual void Write(PriorityLevelType level, std::string const & content);
96 
97  virtual void Flush();
98 
99 protected:
100 
103 
105  virtual ~LoggerThreadWrapper();
106 
108  virtual void PrintSelf(std::ostream & os, Indent indent) const;
109 
110  static ITK_THREAD_RETURN_TYPE ThreadFunction(void *);
111 
112 private:
113 
114  typedef std::queue< OperationType > OperationContainerType;
115 
116  typedef std::queue< std::string > MessageContainerType;
117 
118  typedef std::queue< PriorityLevelType > LevelContainerType;
119 
120  typedef std::queue< typename OutputType::Pointer > OutputContainerType;
121 
122  MultiThreader::Pointer m_Threader;
123 
125 
127 
129 
131 
133 
135 
137 
138 }; // class LoggerThreadWrapper
139 } // namespace itk
140 
141 #ifndef ITK_MANUAL_INSTANTIATION
142 #include "itkLoggerThreadWrapper.hxx"
143 #endif
144 
145 #endif // __itkLoggerThreadWrapper_h
146