00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * リーダヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef READER_H_ 00026 #define READER_H_ 00027 00028 #include <Core/InputOutput/InputStream.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * リーダ 00035 * 00036 * データ読み込みのインターフェース 00037 */ 00038 class Reader{ 00039 public: 00040 /** 00041 * 終端かどうか 00042 * @return trueなら終端 00043 */ 00044 bool isEnd(){ 00045 Assert(stream_ != NULL); 00046 return stream_->isEnd(); 00047 } 00048 00049 /** 00050 * バイトデータの読み出し 00051 * @param data 読み出し先アドレス 00052 * @param size 読み出すサイズ 00053 */ 00054 void readBytes(void* data, int size){ 00055 Assert(stream_ != NULL); 00056 stream_->readBytes(data, size); 00057 } 00058 00059 /** 00060 * サイズの取得 00061 * @return 読み込めるバイト数 00062 */ 00063 int getSize(){ 00064 Assert(stream_ != NULL); 00065 return stream_->getSize(); 00066 } 00067 00068 /** 00069 * スキップ 00070 * 00071 * 指定されたバイト数読み飛ばします。 00072 * @param size 読み飛ばすバイト数 00073 */ 00074 void skip(int size){ 00075 Assert(stream_ != NULL); 00076 stream_->skip(size); 00077 } 00078 00079 /** 00080 * アライメントを取る 00081 * 00082 * 指定されたバイト数のアライメントまで読み込み位置をずらします。 00083 * @param size アライメントをとるバイト数 00084 * @return ずらしたバイト数 00085 */ 00086 int align(int size){ 00087 Assert(stream_ != NULL); 00088 return stream_->align(size); 00089 } 00090 00091 /** 00092 * 読み込み位置の取得 00093 * @return 読み込み位置 00094 */ 00095 int getPosition(){ 00096 Assert(stream_ != NULL); 00097 return stream_->getPosition(); 00098 } 00099 00100 /** 00101 * 読み込み位置の設定 00102 * 00103 * 指定された位置に読み込み位置を変更します。 00104 * @param position 読み込み位置 00105 */ 00106 void setPosition(int position){ 00107 Assert(stream_ != NULL); 00108 stream_->setPosition(position); 00109 } 00110 00111 /** 00112 * リーダの複製 00113 * @return 複製されたリーダ 00114 */ 00115 virtual Reader* cloneReader() = 0; 00116 00117 protected: 00118 /** 00119 * コンストラクタ 00120 */ 00121 Reader(){ stream_ = NULL; } 00122 00123 /** 00124 * デストラクタ 00125 */ 00126 virtual ~Reader(){ 00127 Assert(stream_ != NULL); 00128 delete stream_; 00129 stream_ = NULL; 00130 } 00131 00132 /// 入力ストリーム 00133 InputStream* stream_; 00134 00135 private: 00136 // コピーコンストラクタの隠蔽 00137 Reader(const Reader& copy); 00138 00139 // 代入コピーの隠蔽 00140 void operator =(const Reader& copy); 00141 00142 }; 00143 00144 //------------------------------------------------------------------------------ 00145 } // End of namespace Lamp 00146 #endif // End of READER_H_ 00147 //------------------------------------------------------------------------------