00001 /* 00002 00003 ************************************************************************* 00004 00005 ArmageTron -- Just another Tron Lightcycle Game in 3D. 00006 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) 00007 00008 ************************************************************************** 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 00024 *************************************************************************** 00025 00026 */ 00027 00028 #ifndef TRECORDERINTERNAL_H_INCLUDED 00029 #define TRECORDERINTERNAL_H_INCLUDED 00030 00031 // self include 00032 #ifndef TRECORDINGINTERNAL_H_INCLUDED 00033 #include "tRecorderInternal.h" 00034 #endif 00035 00036 #include "tString.h" 00037 00038 #include <iostream> 00039 #include <string> 00040 00042 class tRecording 00043 { 00044 friend class tRecordingBlockBase; 00045 00046 public: 00047 tRecording () ; 00048 00049 typedef std::ostream STREAM ; 00050 protected: 00051 virtual ~tRecording () ; 00052 private: 00053 // forbid copying 00054 tRecording ( tRecording const & other ) ; 00055 tRecording& operator = ( tRecording const & other ) ; 00056 00057 void BeginSection( char const * name ) ; 00058 virtual std::ostream& DoGetStream () =0 ; 00059 00060 static tRecording * currentRecording_; 00061 }; 00062 00064 class tPlayback 00065 { 00066 friend class tPlaybackBlockBase; 00067 00068 public: 00069 tPlayback () ; 00070 00071 typedef std::istream STREAM ; 00072 protected: 00073 virtual ~tPlayback () ; 00074 00075 void AdvanceSection () ; 00076 private: 00077 // forbid copying 00078 tPlayback ( tPlayback const & other ) ; 00079 tPlayback& operator = ( tPlayback const & other ) ; 00080 00081 std::string const & GetNextSection() const ; 00082 virtual std::istream& DoGetStream () = 0 ; 00083 00084 std::string nextSection_; 00085 static tPlayback * currentPlayback_; 00086 }; 00087 00088 00090 template< class BASE, class STREAM_IMP > class tRecorderImp: public BASE 00091 { 00092 public: 00093 template< class A > tRecorderImp( A a ): stream_( a ){ stream_.precision( 10 ); } 00094 template< class A, class B > tRecorderImp( A a, B b ): stream_( a, b ){ stream_.precision( 10 ); } 00095 ~tRecorderImp(){} 00096 00098 void InitPlayback() 00099 { 00100 BASE::AdvanceSection(); 00101 } 00102 private: 00104 virtual typename BASE::STREAM & DoGetStream() 00105 { 00106 return stream_; 00107 } 00108 00109 STREAM_IMP stream_; 00110 }; 00111 00112 #endif // TRECORDING_H_INCLUDED