00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TIL_PROXYMANAGER_H
00021 #define TIL_PROXYMANAGER_H
00022
00023 #include "TIL_API.h"
00024 #include <UT/UT_LinkList.h>
00025 #include <UT/UT_String.h>
00026 #include "TIL_Defines.h"
00027
00028 class UT_Thread;
00029 class UT_LinkList;
00030 class UT_HashTable;
00031 class TIL_Tile;
00032 class til_ProxyCommand;
00033 class TIL_ProxyState;
00034
00035 class TIL_API TIL_ProxyManager
00036 {
00037 public:
00038
00039 TIL_ProxyManager();
00040 ~TIL_ProxyManager();
00041
00042
00043 int readProxy (const char *cop_path, TIL_Tile *into_tile,
00044 int xres, int yres);
00045 void writeProxy(const char *cop_path, TIL_Tile *from_tile,
00046 int xres, int yres);
00047
00048 void clearCopProxies(const char *cop_path);
00049 void clearAllProxies();
00050
00051 void init();
00052
00053
00054 void setProxyGeneration(int on);
00055 void setProxyDir(const char *dir);
00056 void setProxyLimit(int on);
00057 void setProxyDiskLimit(int size);
00058 void setProxyCrossPlatform(int enable);
00059
00060 int getProxyGeneration() const;
00061 int getProxyLimit() const;
00062 int getProxyDiskLimit() const;
00063 const char *getProxyDir() const;
00064 int getProxyCrossPlatform() const;
00065
00066 private:
00067 void launchManagerProcess();
00068 static void * threadProcess(void *data);
00069
00070
00071 void proxyManagerLoop();
00072
00073
00074 int executeNextCommand();
00075
00076
00077 void garbageCollect(int limit);
00078
00079
00080 void determineProxyState(const char *proxy_dir);
00081
00082
00083 void doWriteTile(const char *path, TIL_Tile *tile,
00084 int xres, int yres);
00085 void doClearCopProxies(const char *path);
00086 void doClearAllProxies();
00087
00088
00089
00090 int ensurePathExists(const char *path);
00091
00092 void addProxyState(TIL_ProxyState *);
00093 TIL_ProxyState * usedProxyState(TIL_ProxyState *);
00094 void removeProxyState(TIL_ProxyState *);
00095
00096 private:
00097 UT_LinkList myCommandList;
00098
00099
00100 int myProxyEnable;
00101 int myProxyLimit;
00102 int myProxyDiskLimit;
00103 UT_String myProxyUserDir;
00104 UT_String myProxyDir;
00105 int myProxyCrossPlatform;
00106
00107
00108 UT_String myProxyIndexFile;
00109 UT_String myProxyDataFile;
00110
00111 UT_LinkList *myProxyStateQueue;
00112 TIL_ProxyState *myProxyStateTable[PROXY_TABLE_SIZE];
00113 int myTotalProxySize;
00114
00115
00116 UT_Thread *myThread;
00117 UT_Lock myCommandLock;
00118 UT_Lock myCurrentPathLock;
00119 UT_Lock myIndexFileLock;
00120 UT_Lock myReadLock;
00121 const char *myCurrentReadPath;
00122 const char *myCurrentWritePath;
00123
00124 TIL_ProxyManager *myThis;
00125 };
00126
00127 #endif