Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

BufferedInput.h

Go to the documentation of this file.
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 BUFFERED_INPUT_H_
00026 #define BUFFERED_INPUT_H_
00027 
00028 #include <Core/Thread/Thread.h>
00029 #include <Core/Utility/FPSController.h>
00030 #include <Core/Container/Deque.h>
00031 #include <Core/Container/ArrayList.h>
00032 #include <Input/Keyboard/KeyboardState.h>
00033 #include <Input/Mouse/MouseState.h>
00034 #include <Input/Joystick/JoystickState.h>
00035 
00036 namespace Lamp{
00037 
00038 class Keyboard;
00039 class KeyboardDevice;
00040 class Mouse;
00041 class MouseDevice;
00042 class Joystick;
00043 class JoystickDevice;
00044 class BinaryWriter;
00045 class BinaryReader;
00046 
00047 //------------------------------------------------------------------------------
00048 /**
00049  * バッファ入力
00050  */
00051 class BufferedInput : public Thread{
00052 friend class LampInput;
00053 public:
00054     /// 60FPS
00055     static const float interval60FPS;
00056     /// 30FPS
00057     static const float interval30FPS;
00058 
00059     //--------------------------------------------------------------------------
00060     /**
00061      * 目標時間間隔の設定
00062      * @param targetInterval 目標時間間隔をミリ秒で指定
00063      */
00064     virtual void setTargetInterval(float targetInterval);
00065 
00066     /**
00067      * 目標時間間隔の取得
00068      * @return 目標時間間隔をミリ秒で取得
00069      */
00070     virtual float getTargetInterval();
00071 
00072     //--------------------------------------------------------------------------
00073     /**
00074      * 実行
00075      * @param thread 実行しているスレッド
00076      *
00077      * ユーザは呼び出さないで下さい
00078      */
00079     virtual void run(Thread* thread);
00080 
00081 private:
00082     //--------------------------------------------------------------------------
00083     /**
00084      * コンストラクタ
00085      */
00086     BufferedInput();
00087 
00088     /**
00089      * デストラクタ
00090      */
00091     virtual ~BufferedInput();
00092 
00093     //--------------------------------------------------------------------------
00094     /**
00095      * キーボードの設定
00096      * @param keyboard キーボード
00097      * @param keyboardDevice キーボードデバイス
00098      */
00099     virtual void setKeyboard(
00100         Keyboard* keyboard, KeyboardDevice* keyboardDevice){
00101         keyboard_ = keyboard;
00102         keyboardDevice_ = keyboardDevice;
00103         Assert((keyboard_ != NULL) && (keyboardDevice_ != NULL));
00104     }
00105 
00106     /**
00107      * マウスの設定
00108      * @param mouse マウス
00109      * @param mouseDevice マウスデバイス
00110      */
00111     virtual void setMouse(Mouse* mouse, MouseDevice* mouseDevice){
00112         mouse_ = mouse;
00113         mouseDevice_ = mouseDevice;
00114         Assert((mouse_ != NULL) && (mouseDevice_ != NULL));
00115     }
00116 
00117     /**
00118      * ジョイスティックの追加
00119      * @param joystick ジョイスティック
00120      * @param joystickDevice ジョイスティックデバイス
00121      */
00122     virtual void addJoystick(
00123         Joystick* joystick, JoystickDevice* joystickDevice){
00124         Assert((joystick != NULL) && (joystickDevice != NULL));
00125         joysticks_.add(joystick);
00126         joystickDevices_.add(joystickDevice);
00127     }
00128 
00129     //--------------------------------------------------------------------------
00130     /**
00131      * 入力があるか
00132      * @return 入力があればtrue
00133      */
00134     virtual bool hasMoreInput();
00135 
00136     /**
00137      * 次の入力
00138      */
00139     virtual void nextInput();
00140 
00141     /**
00142      * 入力数の取得
00143      * @return 入力数
00144      */
00145     virtual int getInputCount();
00146 
00147     //--------------------------------------------------------------------------
00148     // ログ取得
00149     //--------------------------------------------------------------------------
00150     /**
00151      * ログ取得の開始
00152      * @param binaryWriter バイナリライタ
00153      */
00154     virtual void startLogging(BinaryWriter* binaryWriter);
00155 
00156     /**
00157      * ログ取得の終了
00158      */
00159     virtual void endLogging();
00160 
00161     //--------------------------------------------------------------------------
00162     // ログ再生
00163     //--------------------------------------------------------------------------
00164     /**
00165      * ログ再生の開始
00166      * @param binaryReader バイナリリーダ
00167      */
00168     virtual void playLog(BinaryReader* binaryReader);
00169 
00170     /**
00171      * ログ再生の停止
00172      */
00173     virtual void stopLog();
00174 
00175     //--------------------------------------------------------------------------
00176     // デバイスポーリング
00177     virtual void devicePolling();
00178 
00179     // デバイスアップデート
00180     virtual void deviceUpdate();
00181 
00182     // ログアップデート
00183     virtual void logUpdate();
00184 
00185     // ログの書き出し
00186     virtual void writeLog();
00187 
00188     //--------------------------------------------------------------------------
00189     // コピーコンストラクタの隠蔽
00190     BufferedInput(const BufferedInput& copy);
00191 
00192     // 代入コピーの隠蔽
00193     void operator =(const BufferedInput& copy);
00194 
00195     // FPSコントローラ
00196     FPSController fpsController_;
00197     // ログライタ
00198     BinaryWriter* logWriter_;
00199     // ログリーダ
00200     BinaryReader* logReader_;
00201 
00202     // キーボード
00203     Keyboard* keyboard_;
00204     // キーボードデバイス
00205     KeyboardDevice* keyboardDevice_;
00206     // キーボードステート
00207     Deque<KeyboardState> keyboardStates_;
00208 
00209     // マウス
00210     Mouse* mouse_;
00211     // マウスデバイス
00212     MouseDevice* mouseDevice_;
00213     // マウスステート
00214     Deque<MouseState> mouseStates_;
00215 
00216     // ジョイスティック
00217     ArrayList<Joystick*> joysticks_;
00218     // ジョイスティックデバイス
00219     ArrayList<JoystickDevice*> joystickDevices_;
00220     // ジョイスティックステート
00221     Deque<JoystickState> joystickStates_;
00222 
00223 };
00224 
00225 //------------------------------------------------------------------------------
00226 } // End of namespace Lamp
00227 #endif // End of BUFFERED_INPUT_H_
00228 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:28 2005 for Lamp by doxygen 1.3.2