OGRE  1.9.0
OgreResourceBackgroundQueue.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __ResourceBackgroundQueue_H__
29#define __ResourceBackgroundQueue_H__
30
31
32#include "OgrePrerequisites.h"
33#include "OgreCommon.h"
34#include "OgreSingleton.h"
35#include "OgreResource.h"
36#include "OgreWorkQueue.h"
37#include "OgreHeaderPrefix.h"
38
39namespace Ogre {
46
49
60
61
81 class _OgreExport ResourceBackgroundQueue : public Singleton<ResourceBackgroundQueue>, public ResourceAlloc,
83 {
84 public:
94 {
95 public:
104 virtual ~Listener() {}
105
106 };
107
108 protected:
109
123
140
143
146 {
148 : resource(r), request(req)
149 {}
150
153
154 _OgreExport friend std::ostream& operator<<(std::ostream& o, const ResourceResponse& r)
155 { (void)r; return o; }
156 };
157
159
160 public:
163
167 virtual void initialise(void);
168
172 virtual void shutdown(void);
173
183 const String& name, Listener* listener = 0);
184
194 Listener* listener = 0);
204 Listener* listener = 0);
205
215 Listener* listener = 0);
216
217
225 const String& resType, const String& name,
226 Listener* listener = 0);
227
235 const String& resType, ResourceHandle handle,
236 Listener* listener = 0);
237
245 Listener* listener = 0);
246
247
264 const String& resType, const String& name,
265 const String& group, bool isManual = false,
266 ManualResourceLoader* loader = 0,
267 const NameValuePairList* loadParams = 0,
268 Listener* listener = 0);
269
286 const String& resType, const String& name,
287 const String& group, bool isManual = false,
288 ManualResourceLoader* loader = 0,
289 const NameValuePairList* loadParams = 0,
290 Listener* listener = 0);
305
309
311 bool canHandleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
315 bool canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
317 void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
318
351
352 };
353
356
357}
358
359#include "OgreHeaderSuffix.h"
360
361#endif
362
#define _OgreExport
Interface describing a manual resource loader.
This abstract listener interface lets you get notifications of completed background processes instead...
virtual ~Listener()
Need virtual destructor in case subclasses use it.
virtual void operationCompleted(BackgroundProcessTicket ticket, const BackgroundProcessResult &result)=0
Called when a requested operation completes, queued into main thread.
static ResourceBackgroundQueue * getSingletonPtr(void)
Override standard Singleton retrieval.
virtual BackgroundProcessTicket initialiseResourceGroup(const String &name, Listener *listener=0)
Initialise a resource group in the background.
set< BackgroundProcessTicket >::type OutstandingRequestSet
static ResourceBackgroundQueue & getSingleton(void)
Override standard Singleton retrieval.
virtual BackgroundProcessTicket prepare(const String &resType, const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *loadParams=0, Listener *listener=0)
Prepare a single resource in the background.
void abortRequest(BackgroundProcessTicket ticket)
Aborts background process.
bool canHandleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
Implementation for WorkQueue::ResponseHandler.
WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
Implementation for WorkQueue::RequestHandler.
virtual BackgroundProcessTicket unloadResourceGroup(const String &name, Listener *listener=0)
Unloads a resource group in the background.
virtual bool isProcessComplete(BackgroundProcessTicket ticket)
Returns whether a previously queued process has completed or not.
void handleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
Implementation for WorkQueue::ResponseHandler.
virtual void initialise(void)
Initialise the background queue system.
virtual BackgroundProcessTicket loadResourceGroup(const String &name, Listener *listener=0)
Loads a resource group in the background.
virtual BackgroundProcessTicket unload(const String &resType, ResourceHandle handle, Listener *listener=0)
Unload a single resource in the background.
virtual BackgroundProcessTicket prepareResourceGroup(const String &name, Listener *listener=0)
Prepares a resource group in the background.
virtual BackgroundProcessTicket load(const String &resType, const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *loadParams=0, Listener *listener=0)
Load a single resource in the background.
virtual BackgroundProcessTicket initialiseAllResourceGroups(Listener *listener=0)
Initialise all resource groups which are yet to be initialised in the background.
bool canHandleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
Implementation for WorkQueue::RequestHandler.
virtual BackgroundProcessTicket unload(const String &resType, const String &name, Listener *listener=0)
Unload a single resource in the background.
virtual void shutdown(void)
Shut down the background queue system.
BackgroundProcessTicket addRequest(ResourceRequest &req)
RequestType
Enumerates the type of requests.
Singleton(const Singleton< ResourceBackgroundQueue > &)
Interface definition for a handler of requests.
General purpose request structure.
Interface definition for a handler of responses.
Interface to a general purpose request / response style background work queue.
unsigned long long int RequestID
Numeric identifier for a request.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition OgreCommon.h:550
WorkQueue::RequestID BackgroundProcessTicket
Identifier of a background process.
SharedPtr< Resource > ResourcePtr
Shared pointer to a Resource.
ResourceAllocatedObject ResourceAlloc
unsigned short uint16
unsigned long long int ResourceHandle
_StringBase String
Encapsulates the result of a background queue request.
String message
Any messages from the process.
bool error
Whether an error occurred.
Encapsulates a queued request for the background queue.
_OgreExport friend std::ostream & operator<<(std::ostream &o, const ResourceRequest &r)
ResourceResponse(ResourcePtr r, const ResourceRequest &req)
_OgreExport friend std::ostream & operator<<(std::ostream &o, const ResourceResponse &r)
General purpose response structure.
std::set< T, P, A > type