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

SynchronizedObject.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 SYNCHRONIZED_OBJECT_H_
00026 #define SYNCHRONIZED_OBJECT_H_
00027 
00028 namespace LampUnit{
00029 
00030 //------------------------------------------------------------------------------
00031 /**
00032  * シンクロナイズドオブジェクト
00033  */
00034 class SynchronizedObject{
00035 public:
00036     /**
00037      * シンクロナイゼーションオブジェクト
00038      */
00039     class SynchronizationObject{
00040     public:
00041         /// コンストラクタ
00042         SynchronizationObject(){}
00043 
00044         /// デストラクタ
00045         virtual ~SynchronizationObject(){}
00046 
00047         /// ロック
00048         virtual void lock(){}
00049 
00050         /// アンロック
00051         virtual void unlock(){}
00052 
00053     };
00054 
00055     /**
00056      * コンストラクタ
00057      * @param synchronizationObject シンクロ用オブジェクト
00058      */
00059     SynchronizedObject(SynchronizationObject* synchronizationObject = NULL);
00060 
00061     /**
00062      * デストラクタ
00063      */
00064     virtual ~SynchronizedObject();
00065 
00066 protected:
00067     /**
00068      * シンクロナイズドブロック
00069      */
00070     class SynchronizedBlock{
00071     public:
00072         /// コンストラクタ
00073         SynchronizedBlock(SynchronizationObject* synchronizationObject) :
00074             synchronizationObject_(synchronizationObject){
00075             synchronizationObject_->lock();
00076         }
00077 
00078         /// デストラクタ
00079         virtual ~SynchronizedBlock(){
00080             synchronizationObject_->unlock();
00081         }
00082 
00083     private:
00084         // シンクロナイゼーションオブジェクト
00085         SynchronizationObject* synchronizationObject_;
00086     };
00087 
00088     /**
00089      * シンクロナイゼーションオブジェクトの設定
00090      * @param synchronizationObject シンクロナイゼーションオブジェクト
00091      */
00092     virtual void setSynchronizationObject(
00093         SynchronizationObject* synchronizationObject);
00094 
00095     /// シンクロナイゼーションオブジェクト
00096     SynchronizationObject* synchronizationObject_;
00097 
00098 private:
00099     // コピーコンストラクタの隠蔽
00100     SynchronizedObject(const SynchronizedObject& copy);
00101 
00102     // 代入コピーの隠蔽
00103     void operator =(const SynchronizedObject& copy);
00104 
00105 };
00106 
00107 //------------------------------------------------------------------------------
00108 } // End of namespace LampUnit
00109 #endif // End of SYNCHRONIZED_OBJECT_H_
00110 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:54 2005 for LampUnit by doxygen 1.3.2