IGSTK
/build/buildd/igstk-4.4.0/Source/igstkMultipleOutput.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Image Guided Surgery Software Toolkit
00004   Module:    $RCSfile: igstkMultipleOutput.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-02-11 01:41:51 $
00007   Version:   $Revision: 1.10 $
00008 
00009   Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
00010   See IGSTKCopyright.txt or http://www.igstk.org/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 __igstkMultipleOutput_h
00019 #define __igstkMultipleOutput_h
00020 
00021 
00022 #include <iostream>
00023 #include <fstream>
00024 #include <set>
00025 
00026 namespace igstk
00027 {
00028 
00034 class MultipleOutput : virtual public std::streambuf
00035 {
00036 
00037 public:
00038 
00039   typedef std::ostream               StreamType;
00040 
00041   
00042 public:
00043 
00045   MultipleOutput();
00046 
00048   ~MultipleOutput();
00049 
00050 
00054   void AddOutputStream( StreamType & output );
00055 
00056 
00058   void Flush();
00059 
00062   template <class T>
00063   MultipleOutput& operator << ( T tt )
00064   {
00065     ContainerType::iterator itr = m_Output.begin();
00066     ContainerType::iterator end = m_Output.end();
00067     while( itr != end )
00068       {
00069       *(*itr) << tt;
00070       ++itr;
00071       }
00072     return *this;
00073   }
00074 
00075 
00076 private:
00077   
00078   typedef std::set< StreamType * >   ContainerType;
00079 
00080   ContainerType        m_Output;
00081 
00082 };
00083 
00084 }
00085 
00086 #endif //__igstk_MultipleOutput_h_