OgrePage.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef __Ogre_Page_H__
00030 #define __Ogre_Page_H__
00031 
00032 #include "OgrePagingPrerequisites.h"
00033 #include "OgreWorkQueue.h"
00034 
00035 
00036 namespace Ogre
00037 {
00048     class _OgrePagingExport Page : public WorkQueue::RequestHandler, 
00049         public WorkQueue::ResponseHandler, public PageAlloc
00050     {
00051     public:
00052         typedef vector<PageContentCollection*>::type ContentCollectionList;
00053     protected:
00054         PageID mID;
00055         PagedWorldSection* mParent;
00056         unsigned long mFrameLastHeld;
00057         ContentCollectionList mContentCollections;
00058         uint16 mWorkQueueChannel;
00059         bool mDeferredProcessInProgress;
00060         bool mModified;
00061 
00062         SceneNode* mDebugNode;
00063         void updateDebugDisplay();
00064 
00065         struct PageData : public PageAlloc
00066         {
00067             ContentCollectionList collectionsToAdd;
00068         };
00070         struct PageRequest
00071         {
00072             Page* srcPage;
00073             _OgrePagingExport friend std::ostream& operator<<(std::ostream& o, const PageRequest& r)
00074             { return o; }       
00075 
00076             PageRequest(Page* p): srcPage(p) {}
00077         };
00078         struct PageResponse
00079         {
00080             PageData* pageData;
00081 
00082             _OgrePagingExport friend std::ostream& operator<<(std::ostream& o, const PageResponse& r)
00083             { return o; }       
00084 
00085             PageResponse() : pageData(0) {}
00086         };
00087 
00088 
00089 
00090         virtual bool prepareImpl(PageData* dataToPopulate);
00091         virtual bool prepareImpl(StreamSerialiser& str, PageData* dataToPopulate);
00092         virtual void loadImpl();
00093 
00094         String generateFilename() const;
00095 
00096     public:
00097         static const uint32 CHUNK_ID;
00098         static const uint16 CHUNK_VERSION;
00099 
00100         static const uint32 CHUNK_CONTENTCOLLECTION_DECLARATION_ID;
00101 
00102         Page(PageID pageID, PagedWorldSection* parent);
00103         virtual ~Page();
00104 
00105         PageManager* getManager() const;
00106         SceneManager* getSceneManager() const;
00107 
00109         bool isDeferredProcessInProgress() const { return mDeferredProcessInProgress; }
00110 
00112         virtual PageID getID() const { return mID; }
00114         virtual PagedWorldSection* getParentSection() const { return mParent; }
00120         virtual unsigned long getFrameLastHeld() { return mFrameLastHeld; }
00122         virtual void touch();
00123 
00127         virtual void load(bool synchronous);
00130         virtual void unload();
00131 
00132 
00138         virtual bool isHeld() const;
00139 
00141         virtual void save();
00143         virtual void save(const String& filename);
00145         virtual void save(StreamSerialiser& stream);
00146 
00148         virtual void frameStart(Real timeSinceLastFrame);
00150         virtual void frameEnd(Real timeElapsed);
00152         virtual void notifyCamera(Camera* cam);
00153 
00159         virtual PageContentCollection* createContentCollection(const String& typeName);
00160 
00165         virtual void destroyContentCollection(PageContentCollection* coll);
00168         virtual void destroyAllContentCollections();
00170         virtual size_t getContentCollectionCount() const;
00172         virtual PageContentCollection* getContentCollection(size_t index);
00174         const ContentCollectionList& getContentCollectionList() const;
00175 
00177         bool canHandleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
00179         WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
00181         bool canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
00183         void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
00184 
00185 
00187         void _notifyModified() { mModified = true; }
00188         bool isModified() const { return mModified; }
00189 
00190         static const uint16 WORKQUEUE_PREPARE_REQUEST;
00191         static const uint16 WORKQUEUE_CHANGECOLLECTION_REQUEST;
00192 
00195         _OgrePagingExport friend std::ostream& operator <<( std::ostream& o, const Page& p );
00196 
00197 
00198 
00199     };
00200 
00203 }
00204 
00205 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:25 2012