Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkThreadLogger.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkThreadLogger.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-03 15:09:52 $
00007   Version:   $Revision: 1.7 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkThreadLogger_h
00019 #define __itkThreadLogger_h
00020 
00021 #include "itkMacro.h"
00022 #include "itkMultiThreader.h"
00023 #include "itkLogger.h"
00024 #include "itkSimpleFastMutexLock.h"
00025 
00026 #include <string>
00027 #include <queue>
00028 
00029 namespace itk
00030 {
00043 class ITKCommon_EXPORT ThreadLogger : public Logger
00044 {
00045 
00046 public:
00047   
00048   typedef ThreadLogger              Self;
00049   typedef Logger                    Superclass;
00050   typedef SmartPointer<Self>        Pointer;
00051   typedef SmartPointer<const Self>  ConstPointer;
00052 
00054   itkTypeMacro( ThreadLogger, Logger );
00055 
00057   itkNewMacro( Self );
00058 
00059   typedef  Logger::OutputType   OutputType;
00060 
00061   typedef  Logger::PriorityLevelType  PriorityLevelType;
00062 
00064   typedef enum
00065     {
00066     SET_PRIORITY_LEVEL,
00067     SET_LEVEL_FOR_FLUSHING,
00068     ADD_LOG_OUTPUT,
00069     WRITE,
00070     FLUSH
00071     } OperationType;
00072 
00076   virtual void SetPriorityLevel( PriorityLevelType level );
00077 
00081   virtual PriorityLevelType GetPriorityLevel() const;
00082 
00083   virtual void SetLevelForFlushing( PriorityLevelType level );
00084 
00085   virtual PriorityLevelType GetLevelForFlushing() const;
00086 
00088   virtual void AddLogOutput( OutputType* output );
00089 
00090   virtual void Write(PriorityLevelType level, std::string const & content);
00091 
00092   virtual void Flush();
00093 
00094 protected:
00095 
00097   ThreadLogger();
00098 
00100   virtual ~ThreadLogger();
00101 
00103   virtual void PrintSelf(std::ostream &os, Indent indent) const;
00104 
00105   static ITK_THREAD_RETURN_TYPE ThreadFunction(void*);
00106 
00107 private:
00108 
00109   typedef std::queue<OperationType> OperationContainerType;
00110 
00111   typedef std::queue<std::string>  MessageContainerType;
00112 
00113   typedef std::queue<PriorityLevelType>  LevelContainerType;
00114 
00115   typedef std::queue<OutputType::Pointer>  OutputContainerType;
00116 
00117   MultiThreader::Pointer  m_Threader;
00118 
00119   int m_ThreadID;
00120 
00121   OperationContainerType  m_OperationQ;
00122 
00123   MessageContainerType  m_MessageQ;
00124 
00125   LevelContainerType  m_LevelQ;
00126 
00127   OutputContainerType m_OutputQ;
00128 
00129   SimpleFastMutexLock m_Mutex;
00130 
00131   SimpleFastMutexLock m_WaitMutex;
00132 
00133 };  // class ThreadLogger
00134 
00135 
00136 } // namespace itk
00137 
00138 
00139 #endif  // __itkThreadLogger_h
00140 

Generated at Thu May 28 11:46:38 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000