00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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_