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-2013 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 "Threading/OgreThreadHeaders.h"
00034 #include "OgreWorkQueue.h"
00035 
00036 
00037 namespace Ogre
00038 {
00049     class _OgrePagingExport Page : public WorkQueue::RequestHandler, 
00050         public WorkQueue::ResponseHandler, public PageAlloc
00051     {
00052     public:
00053         typedef vector<PageContentCollection*>::type ContentCollectionList;
00054     protected:
00055         PageID mID;
00056         PagedWorldSection* mParent;
00057         unsigned long mFrameLastHeld;
00058         ContentCollectionList mContentCollections;
00059         uint16 mWorkQueueChannel;
00060         bool mDeferredProcessInProgress;
00061         bool mModified;
00062 
00063         SceneNode* mDebugNode;
00064         void updateDebugDisplay();
00065 
00066         struct PageData : public PageAlloc
00067         {
00068             ContentCollectionList collectionsToAdd;
00069         };
00071         struct PageRequest
00072         {
00073             Page* srcPage;
00074             _OgrePagingExport friend std::ostream& operator<<(std::ostream& o, const PageRequest& r)
00075             { return o; }       
00076 
00077             PageRequest(Page* p): srcPage(p) {}
00078         };
00079         struct PageResponse
00080         {
00081             PageData* pageData;
00082 
00083             _OgrePagingExport friend std::ostream& operator<<(std::ostream& o, const PageResponse& r)
00084             { return o; }       
00085 
00086             PageResponse() : pageData(0) {}
00087         };
00088 
00089 
00090 
00091         virtual bool prepareImpl(PageData* dataToPopulate);
00092         virtual bool prepareImpl(StreamSerialiser& str, PageData* dataToPopulate);
00093         virtual void loadImpl();
00094 
00095         String generateFilename() const;
00096 
00097     public:
00098         static const uint32 CHUNK_ID;
00099         static const uint16 CHUNK_VERSION;
00100 
00101         static const uint32 CHUNK_CONTENTCOLLECTION_DECLARATION_ID;
00102 
00103         Page(PageID pageID, PagedWorldSection* parent);
00104         virtual ~Page();
00105 
00106         PageManager* getManager() const;
00107         SceneManager* getSceneManager() const;
00108 
00110         bool isDeferredProcessInProgress() const { return mDeferredProcessInProgress; }
00111 
00113         virtual PageID getID() const { return mID; }
00115         virtual PagedWorldSection* getParentSection() const { return mParent; }
00121         virtual unsigned long getFrameLastHeld() { return mFrameLastHeld; }
00123         virtual void touch();
00124 
00128         virtual void load(bool synchronous);
00131         virtual void unload();
00132 
00133 
00139         virtual bool isHeld() const;
00140 
00142         virtual void save();
00144         virtual void save(const String& filename);
00146         virtual void save(StreamSerialiser& stream);
00147 
00149         virtual void frameStart(Real timeSinceLastFrame);
00151         virtual void frameEnd(Real timeElapsed);
00153         virtual void notifyCamera(Camera* cam);
00154 
00160         virtual PageContentCollection* createContentCollection(const String& typeName);
00161 
00166         virtual void destroyContentCollection(PageContentCollection* coll);
00169         virtual void destroyAllContentCollections();
00171         virtual size_t getContentCollectionCount() const;
00173         virtual PageContentCollection* getContentCollection(size_t index);
00175         const ContentCollectionList& getContentCollectionList() const;
00176 
00178         bool canHandleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
00180         WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
00182         bool canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
00184         void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
00185 
00186 
00188         void _notifyModified() { mModified = true; }
00189         bool isModified() const { return mModified; }
00190 
00191         static const uint16 WORKQUEUE_PREPARE_REQUEST;
00192         static const uint16 WORKQUEUE_CHANGECOLLECTION_REQUEST;
00193 
00196         _OgrePagingExport friend std::ostream& operator <<( std::ostream& o, const Page& p );
00197 
00198 
00199 
00200     };
00201 
00204 }
00205 
00206 #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 Mon Jul 27 2020 13:40:44