00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkStdStreamLogOutput.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006-02-05 20:57:46 $ 00007 Version: $Revision: 1.4 $ 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 __itkStdStreamLogOutput_h 00019 #define __itkStdStreamLogOutput_h 00020 00021 #include <iostream> 00022 #include <string> 00023 00024 #include "itkMacro.h" 00025 #include "itkObject.h" 00026 #include "itkObjectFactory.h" 00027 #include "itkSimpleFastMutexLock.h" 00028 #include "itkLogOutput.h" 00029 00030 00031 namespace itk 00032 { 00033 00045 class ITKCommon_EXPORT StdStreamLogOutput : public LogOutput 00046 { 00047 00048 public: 00049 00050 typedef StdStreamLogOutput Self; 00051 typedef LogOutput Superclass; 00052 typedef SmartPointer<Self> Pointer; 00053 typedef SmartPointer<const Self> ConstPointer; 00054 00055 typedef std::ostream StreamType; 00056 typedef std::ostream* StreamPointerType; 00057 00058 itkTypeMacro(StdStreamLogOutput, LogOutput); 00059 00060 itkNewMacro(StdStreamLogOutput); 00061 00062 itkGetMacro(Stream, StreamPointerType); 00063 00065 void SetStream(StreamType &Stream); 00066 00068 virtual void Flush(); 00069 00071 virtual void Write(double timestamp); 00072 00074 virtual void Write(std::string const &content); 00075 00077 virtual void Write(std::string const &content, double timestamp); 00078 00079 protected: 00081 StdStreamLogOutput(); 00082 00084 virtual ~StdStreamLogOutput(); 00085 00086 void PrintSelf(std::ostream &os, Indent indent) const; 00087 00088 private: 00089 00090 StreamPointerType m_Stream; 00091 00092 SimpleFastMutexLock m_Mutex; 00093 }; 00094 00095 } 00096 00097 #endif //__itkStdStreamLogOutput_h 00098