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: 2005/11/08 22:06:08 $
00007   Version:   $Revision: 1.5 $
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 #if defined(_MSC_VER)
00022    //Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug)
00023    #pragma warning( disable : 4786 )
00024   // warning C4503: 'insert' : decorated name length exceeded, name was truncated
00025   #pragma warning ( disable : 4503 )
00026 #endif
00027 
00028 
00029 #include <string>
00030 #include <queue>
00031 
00032 #include "itkMacro.h"
00033 #include "itkMultiThreader.h"
00034 #include "itkLogger.h"
00035 #include "itkSimpleFastMutexLock.h"
00036 
00037 
00038 
00039 namespace itk
00040 {
00053 class ITKCommon_EXPORT ThreadLogger : public Logger
00054 {
00055 
00056 public:
00057   
00058   typedef ThreadLogger  Self;
00059   typedef Logger  Superclass;
00060   typedef SmartPointer<Self>  Pointer;
00061   typedef SmartPointer<const Self>  ConstPointer;
00062 
00064   itkTypeMacro( ThreadLogger, Logger );
00065 
00067   itkNewMacro( Self );
00068 
00069   typedef  Logger::OutputType   OutputType;
00070 
00071   typedef  Logger::PriorityLevelType  PriorityLevelType;
00072 
00074   typedef enum 
00075   { 
00076     SET_PRIORITY_LEVEL,
00077     SET_LEVEL_FOR_FLUSHING,
00078     ADD_LOG_OUTPUT,
00079     WRITE,
00080     FLUSH
00081   } OperationType;
00082 
00083 
00087   virtual void SetPriorityLevel( PriorityLevelType level );
00088 
00092   virtual PriorityLevelType GetPriorityLevel() const;
00093 
00094   virtual void SetLevelForFlushing( PriorityLevelType level );
00095 
00096   virtual PriorityLevelType GetLevelForFlushing() const;
00097 
00099   virtual void AddLogOutput( OutputType* output );
00100 
00101   virtual void Write(PriorityLevelType level, std::string const & content);
00102 
00103   virtual void Flush();
00104 
00105 protected:
00106 
00108   ThreadLogger();
00109 
00111   virtual ~ThreadLogger();
00112 
00114   virtual void PrintSelf(std::ostream &os, Indent indent) const;
00115 
00116   static ITK_THREAD_RETURN_TYPE ThreadFunction(void*);
00117 
00118 private:
00119 
00120   typedef std::queue<OperationType> OperationContainerType;
00121 
00122   typedef std::queue<std::string>  MessageContainerType;
00123 
00124   typedef std::queue<PriorityLevelType>  LevelContainerType;
00125 
00126   typedef std::queue<OutputType::Pointer>  OutputContainerType;
00127 
00128   MultiThreader::Pointer  m_Threader;
00129 
00130   int m_ThreadID;
00131 
00132   OperationContainerType  m_OperationQ;
00133 
00134   MessageContainerType  m_MessageQ;
00135 
00136   LevelContainerType  m_LevelQ;
00137 
00138   OutputContainerType m_OutputQ;
00139 
00140   SimpleFastMutexLock m_Mutex;
00141 
00142   SimpleFastMutexLock m_WaitMutex;
00143 
00144 };  // class ThreadLogger
00145 
00146 
00147 } // namespace itk
00148 
00149 
00150 #endif  // __itkThreadLogger_h

Generated at Thu May 25 00:08:26 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000