ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkStdStreamLogOutput.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkStdStreamLogOutput_h
00019 #define __itkStdStreamLogOutput_h
00020 
00021 #include <iostream>
00022 #include <string>
00023 
00024 #include "itkSimpleFastMutexLock.h"
00025 #include "itkLogOutput.h"
00026 
00027 namespace itk
00028 {
00042 class ITKCommon_EXPORT StdStreamLogOutput:public LogOutput
00043 {
00044 public:
00045 
00046   typedef StdStreamLogOutput         Self;
00047   typedef LogOutput                  Superclass;
00048   typedef SmartPointer< Self >       Pointer;
00049   typedef SmartPointer< const Self > ConstPointer;
00050 
00051   typedef std::ostream StreamType;
00052 
00053   typedef std::ostream *StreamPointerType;
00054 
00055   itkTypeMacro(StdStreamLogOutput, LogOutput);
00056 
00057   itkNewMacro(StdStreamLogOutput);
00058 
00059   itkGetConstMacro(Stream, StreamPointerType);
00060 
00062   void SetStream(StreamType & Stream);
00063 
00065   virtual void Flush();
00066 
00068   virtual void Write(double timestamp);
00069 
00071   virtual void Write(std::string const & content);
00072 
00074   virtual void Write(std::string const & content, double timestamp);
00075 
00076 protected:
00078   StdStreamLogOutput();
00079 
00081   virtual ~StdStreamLogOutput();
00082 
00083   void PrintSelf(std::ostream & os, Indent indent) const;
00084 
00085 private:
00086 
00087   StreamPointerType m_Stream;
00088 
00089   SimpleFastMutexLock m_Mutex;
00090 };
00091 }
00092 
00093 #endif //__itkStdStreamLogOutput_h
00094