メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ | 関連ページ

SGEngine.h

00001 #ifndef SGENGINE_H
00002 #define SGENGINE_H
00003 
00004 #include "SGFrame.h"
00005 
00006 namespace Spr {;
00007 
00008 /// 動作エンジンの基本クラス.
00009 class SGEngine:public SGObject{
00010     SGOBJECTDEF(SGEngine);
00011 public:
00012     /// シーンをクリアするときの処理
00013     virtual void Clear(SGScene* s){}
00014     /// プライオリティ  小さいほど優先順位が高い
00015     virtual int GetPriority() const { return 0; }
00016     /// オブジェクトをセットする
00017     virtual void Set(SGObject* obj){}
00018 };
00019 inline bool operator < (const SGEngine& e1, const SGEngine& e2){
00020     return e1.GetPriority() < e2.GetPriority();
00021 }
00022 
00023 class FISaveScene;
00024 
00025 /// SGEngineの配列
00026 class SGEngines: std DOUBLECOLON vector< UTRef<SGEngine> >{
00027 protected:
00028     SGObjects objs;
00029     iterator begin2() { return base::begin(); }
00030     iterator end2() { return base::end(); }
00031 public:
00032     typedef std::vector< UTRef<SGEngine> > base;
00033     typedef base::iterator iterator;
00034     typedef base::const_iterator const_iterator;
00035     const_iterator begin() const { return base::begin(); }
00036     const_iterator end() const { return base::end(); }
00037     size_t size(){ return base::size(); }
00038     UTRef<SGEngine>& operator [] (int id){ return base::begin()[id]; }
00039     const UTRef<SGEngine>& operator [] (int id) const { return base::begin()[id]; }
00040     virtual void Add(SGEngine* e);
00041     virtual bool Del(SGEngine* e);
00042     ///
00043     SGEngines();
00044     /// セットされたオブジェクトたち
00045     SGObjects& GetObjects(){ return objs; }
00046     /// オブジェクトをセットする
00047     virtual void Set(SGObject* obj){
00048         for(const_iterator it = begin(); it != end(); ++it){
00049             (*it)->Set(obj);
00050         }
00051         objs.push_back(obj);
00052     }
00053     /// ロード後の処理
00054     virtual void Loaded(SGScene* scene);
00055     /// シーンをクリアするときの処理
00056     virtual void Clear(SGScene* s);
00057     /// 指定した型を継承したエンジンを見つける (最初に見つかったものを返す)
00058     SGEngine* FindInherit(const UTTypeInfo& tinfo, UTString name) const;
00059     SGEngine* FindInherit(const UTTypeInfo& tinfo) const;
00060     /// 指定した型かその派生クラスのエンジンを見つける (最初に見つかったものを返す)
00061     template <class T> bool Find(T*& t) const{
00062         t = (T*)FindInherit(*T::GetTypeInfoStatic());
00063         return t != NULL;
00064     }
00065     template <class T> bool Find(UTRef<T>& t) const{
00066         t = UTRef<T>((T*)FindInherit(*T::GetTypeInfoStatic()));
00067         return t != NULL;
00068     }
00069     /// 指定した型かその派生クラスのエンジンで名前が一致するものを見つける (最初に見つかったものを返す)
00070     template <class T> bool Find(T*& t, UTString name) const{
00071         t = (T*)FindInherit(*T::GetTypeInfoStatic(), name);
00072         return t != NULL;
00073     }
00074     template <class T> bool Find(UTRef<T>& t, UTString name) const{
00075         t = UTRef<T>((T*)FindInherit(*T::GetTypeInfoStatic(), name));
00076         return t != NULL;
00077     }
00078     void Save(FISaveScene* ctx);
00079 };
00080 
00081 }
00082 #endif

Springheadに対してSun Apr 16 01:57:55 2006に生成されました。  doxygen 1.4.1