fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / BackgroundLoader / OSGRequest.h
blob9d25492e62b434ba96a01f9ad91f2221c249a08a
1 #ifndef _OSG_REQUEST_H_
2 #define _OSG_REQUEST_H_
4 #include "OSGConfig.h"
5 #include "OSGContribBackgroundLoaderDef.h"
7 #include <boost/shared_ptr.hpp>
8 #include <boost/weak_ptr.hpp>
9 #include <boost/enable_shared_from_this.hpp>
10 #include <string>
11 #include <iostream>
14 OSG_BEGIN_NAMESPACE
16 class Request;
17 typedef boost::shared_ptr<Request> RequestPtr;
18 typedef boost::weak_ptr<Request> RequestWeakPtr;
20 /** A request to be processed by the background loader.
22 class OSG_CONTRIBBACKGROUNDLOADER_DLLMAPPING Request
24 protected:
25 Request();
27 public:
28 virtual ~Request();
30 /** Return a text description of the request.
31 * This could be used in a user interface or debug output to provide
32 * a user understandable description.
34 virtual std::string getDescription()
35 { return std::string("Base Request"); }
37 /** Called when it is time to execute the request and "do" something.
38 * Ex: load a file.
40 virtual void execute() = 0;
42 /** Called in the main thread when it is time to sync up
43 * and finish the processing. ex: add child node.
45 virtual void sync() = 0;
47 /** Return true if the request has been completed. */
48 bool isCompleted();
50 float getPriority();
52 void setPriority(float val);
54 static bool comparePriority(RequestPtr lhs, RequestPtr rhs);
56 friend class BackgroundLoaderBase;
57 protected:
58 bool mCompleted; /**< True once the request has been completed and synced. */
59 float mPriority; /**< Priority for this request. lower numbers are higher priority. */
62 OSG_END_NAMESPACE
64 #endif /*_REQUEST_H_*/