00001
00032 #ifndef LL_LLVFSTHREAD_H
00033 #define LL_LLVFSTHREAD_H
00034
00035 #include <queue>
00036 #include <string>
00037 #include <map>
00038 #include <set>
00039
00040 #include "llapr.h"
00041
00042 #include "llqueuedthread.h"
00043
00044 #include "llvfs.h"
00045
00046
00047
00048 class LLVFSThread : public LLQueuedThread
00049 {
00050
00051 public:
00052 enum operation_t {
00053 FILE_READ,
00054 FILE_WRITE,
00055 FILE_RENAME
00056 };
00057
00058
00059 public:
00060
00061 class Request : public QueuedRequest
00062 {
00063 protected:
00064 ~Request() {};
00065
00066 public:
00067 Request(handle_t handle, U32 priority, U32 flags,
00068 operation_t op, LLVFS* vfs,
00069 const LLUUID &file_id, const LLAssetType::EType file_type,
00070 U8* buffer, S32 offset, S32 numbytes);
00071
00072 S32 getBytesRead()
00073 {
00074 return mBytesRead;
00075 }
00076 S32 getOperation()
00077 {
00078 return mOperation;
00079 }
00080 U8* getBuffer()
00081 {
00082 return mBuffer;
00083 }
00084 LLVFS* getVFS()
00085 {
00086 return mVFS;
00087 }
00088 std::string getFilename()
00089 {
00090 char tbuf[40];
00091 mFileID.toString(tbuf);
00092 return std::string(tbuf);
00093 }
00094
00095 bool processRequest();
00096 void finishRequest(bool completed);
00097 void deleteRequest();
00098
00099 private:
00100 operation_t mOperation;
00101
00102 LLVFS* mVFS;
00103 LLUUID mFileID;
00104 LLAssetType::EType mFileType;
00105
00106 U8* mBuffer;
00107 S32 mOffset;
00108 S32 mBytes;
00109 S32 mBytesRead;
00110 };
00111
00112
00113 public:
00114 static std::string sDataPath;
00115 static LLVFSThread* sLocal;
00116
00117 public:
00118 LLVFSThread(bool threaded = TRUE);
00119 ~LLVFSThread();
00120
00121
00122 handle_t read(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
00123 U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0);
00124 handle_t write(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
00125 U8* buffer, S32 offset, S32 numbytes, U32 flags);
00126
00127
00128
00129
00130 S32 readImmediate(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
00131 U8* buffer, S32 offset, S32 numbytes);
00132 S32 writeImmediate(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
00133 U8* buffer, S32 offset, S32 numbytes);
00134
00135 bool processRequest(QueuedRequest* req);
00136
00137 public:
00138 static void initClass(bool local_is_threaded = TRUE);
00139 static S32 updateClass(U32 ms_elapsed);
00140 static void cleanupClass();
00141 static void setDataPath(const std::string& path) { sDataPath = path; }
00142 };
00143
00144
00145
00146
00147 #endif // LL_LLVFSTHREAD_H