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

itkLoggerThreadWrapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkLoggerThreadWrapper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/11/10 21:07:04 $
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 __itkLoggerThreadWrapper_h
00019 #define __itkLoggerThreadWrapper_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 #if ! ( defined(_MSC_VER)  ||   (defined(__GNUC__) && (__GNUC__ <= 2) ))//NOTE: This class does not work under MSVS6, or gnu 2.95
00028 
00029 
00030 #include <string>
00031 #include <queue>
00032 
00033 #include "itkMacro.h"
00034 #include "itkMultiThreader.h"
00035 #include "itkSimpleFastMutexLock.h"
00036 
00037 namespace itk
00038 {
00039 
00049 // MSVS6 can't do this type of nested template
00050 template < class SimpleLoggerType >
00051 class LoggerThreadWrapper : public SimpleLoggerType
00052 {
00053 
00054 public:
00055 
00056   typedef LoggerThreadWrapper  Self;
00057   typedef SimpleLoggerType  Superclass;
00058   typedef SmartPointer<Self>  Pointer;
00059   typedef SmartPointer<const Self>  ConstPointer;
00060 
00062   itkTypeMacro( LoggerThreadWrapper, SimpleLoggerType );
00063 
00065   itkNewMacro( Self );
00066 
00067   typedef  typename SimpleLoggerType::OutputType   OutputType;
00068   typedef  typename SimpleLoggerType::PriorityLevelType  PriorityLevelType;
00069 
00071   typedef enum
00072   {
00073     SET_PRIORITY_LEVEL,
00074     SET_LEVEL_FOR_FLUSHING,
00075     ADD_LOG_OUTPUT,
00076     WRITE,
00077     FLUSH
00078   } OperationType;
00079 
00080 
00084   virtual void SetPriorityLevel( PriorityLevelType level );
00085 
00089   virtual PriorityLevelType GetPriorityLevel() const;
00090 
00091   virtual void SetLevelForFlushing( PriorityLevelType level );
00092   virtual PriorityLevelType GetLevelForFlushing() const;
00093 
00095   virtual void AddLogOutput( OutputType* output );
00096 
00097   virtual void Write(PriorityLevelType level, std::string const & content);
00098 
00099   virtual void Flush();
00100 
00101 protected:
00102 
00104   LoggerThreadWrapper();
00105 
00107   virtual ~LoggerThreadWrapper();
00108 
00110   virtual void PrintSelf(std::ostream &os, Indent indent) const;
00111 
00112   static ITK_THREAD_RETURN_TYPE ThreadFunction(void*);
00113 
00114 private:
00115 
00116   typedef std::queue<OperationType> OperationContainerType;
00117 
00118   typedef std::queue<std::string>  MessageContainerType;
00119 
00120   typedef std::queue<PriorityLevelType>  LevelContainerType;
00121 
00122   typedef std::queue<typename OutputType::Pointer>  OutputContainerType;
00123 
00124   MultiThreader::Pointer  m_Threader;
00125 
00126   int m_ThreadID;
00127 
00128   OperationContainerType  m_OperationQ;
00129 
00130   MessageContainerType  m_MessageQ;
00131 
00132   LevelContainerType  m_LevelQ;
00133 
00134   OutputContainerType m_OutputQ;
00135 
00136   SimpleFastMutexLock m_Mutex;
00137 
00138   SimpleFastMutexLock m_WaitMutex;
00139 
00140 };  // class LoggerThreadWrapper
00141 } // namespace itk
00142 
00143 #ifndef ITK_MANUAL_INSTANTIATION
00144 #include "itkLoggerThreadWrapper.txx"
00145 #endif
00146 
00147 
00148 
00149 #endif  // !defined (_MSC_VER)
00150 #endif  // __itkLoggerThreadWrapper_h

Generated at Wed May 24 23:37:01 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000