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: 2006/02/05 20:57:46 $
00007   Version:   $Revision: 1.6 $
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 
00073 
00077   virtual void SetPriorityLevel( PriorityLevelType level );
00078 
00082   virtual PriorityLevelType GetPriorityLevel() const;
00083 
00084   virtual void SetLevelForFlushing( PriorityLevelType level );
00085 
00086   virtual PriorityLevelType GetLevelForFlushing() const;
00087 
00089   virtual void AddLogOutput( OutputType* output );
00090 
00091   virtual void Write(PriorityLevelType level, std::string const & content);
00092 
00093   virtual void Flush();
00094 
00095 protected:
00096 
00098   ThreadLogger();
00099 
00101   virtual ~ThreadLogger();
00102 
00104   virtual void PrintSelf(std::ostream &os, Indent indent) const;
00105 
00106   static ITK_THREAD_RETURN_TYPE ThreadFunction(void*);
00107 
00108 private:
00109 
00110   typedef std::queue<OperationType> OperationContainerType;
00111 
00112   typedef std::queue<std::string>  MessageContainerType;
00113 
00114   typedef std::queue<PriorityLevelType>  LevelContainerType;
00115 
00116   typedef std::queue<OutputType::Pointer>  OutputContainerType;
00117 
00118   MultiThreader::Pointer  m_Threader;
00119 
00120   int m_ThreadID;
00121 
00122   OperationContainerType  m_OperationQ;
00123 
00124   MessageContainerType  m_MessageQ;
00125 
00126   LevelContainerType  m_LevelQ;
00127 
00128   OutputContainerType m_OutputQ;
00129 
00130   SimpleFastMutexLock m_Mutex;
00131 
00132   SimpleFastMutexLock m_WaitMutex;
00133 
00134 };  // class ThreadLogger
00135 
00136 
00137 } // namespace itk
00138 
00139 
00140 #endif  // __itkThreadLogger_h
00141 

Generated at Tue Jul 29 22:50:55 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000