Task.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TASK_H
00023 #define _TASK_H
00024
00025
00026
00027 #include <string>
00028 #include <fstream>
00029 #include "IIPImage.h"
00030 #include "IIPResponse.h"
00031 #include "JPEGCompressor.h"
00032 #include "View.h"
00033 #include "TileManager.h"
00034 #include "Timer.h"
00035 #include "Writer.h"
00036 #include "Cache.h"
00037 #include "Watermark.h"
00038
00039
00040
00041 #define MAX_AGE 86400
00042
00043
00044
00045 #ifdef __GNUC__
00046
00047 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ >= 4)
00048 #define USE_HASHMAP 1
00049 #endif
00050
00051
00052 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)
00053 #define USE_POOL_ALLOCATOR 1
00054 #endif
00055
00056 #endif
00057
00058
00059
00060 #ifdef USE_HASHMAP
00061 #include <ext/hash_map>
00062
00063 #ifdef USE_POOL_ALLOCATOR
00064 #include <ext/pool_allocator.h>
00065 typedef __gnu_cxx::hash_map < const std::string, IIPImage,
00066 __gnu_cxx::hash< const std::string >,
00067 std::equal_to< const std::string >,
00068 __gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
00069 > imageCacheMapType;
00070 #else
00071 typedef __gnu_cxx::hash_map <const std::string,IIPImage> imageCacheMapType;
00072 #endif
00073
00074 #else
00075 typedef std::map<const std::string,IIPImage> imageCacheMapType;
00076 #endif
00077
00078
00079
00080
00082 struct Session {
00083 IIPImage **image;
00084 JPEGCompressor* jpeg;
00085 View* view;
00086 IIPResponse* response;
00087 Watermark* watermark;
00088 int loglevel;
00089 std::ofstream* logfile;
00090 std::map <const std::string, std::string> headers;
00091
00092 imageCacheMapType *imageCache;
00093 Cache* tileCache;
00094
00095 #ifdef DEBUG
00096 FileWriter* out;
00097 #else
00098 FCGIWriter* out;
00099 #endif
00100
00101 };
00102
00103
00104
00105
00107 class Task {
00108
00109 protected:
00110
00112 Timer command_timer;
00113
00115 Session* session;
00116
00118 std::string argument;
00119
00120
00121 public:
00122
00124 virtual ~Task() {;};
00125
00127 virtual void run( Session* session, const std::string& argument ) {;};
00128
00130
00131 static Task* factory( const std::string& type );
00132
00133
00135 void checkImage();
00136
00137 };
00138
00139
00140
00141
00143 class OBJ : public Task {
00144
00145 public:
00146
00147 void run( Session* session, const std::string& argument );
00148
00149 void iip();
00150 void iip_server();
00151 void max_size();
00152 void resolution_number();
00153 void colorspace( std::string arg );
00154 void tile_size();
00155 void bits_per_channel();
00156 void horizontal_views();
00157 void vertical_views();
00158 void metadata( std::string field );
00159
00160 };
00161
00162
00164 class QLT : public Task {
00165 public:
00166 void run( Session* session, const std::string& argument );
00167 };
00168
00169
00171 class SDS : public Task {
00172 public:
00173 void run( Session* session, const std::string& argument );
00174 };
00175
00176
00178 class CNT : public Task {
00179 public:
00180 void run( Session* session, const std::string& argument );
00181 };
00182
00183
00185 class WID : public Task {
00186 public:
00187 void run( Session* session, const std::string& argument );
00188 };
00189
00190
00192 class HEI : public Task {
00193 public:
00194 void run( Session* session, const std::string& argument );
00195 };
00196
00197
00199 class RGN : public Task {
00200 public:
00201 void run( Session* session, const std::string& argument );
00202 };
00203
00204
00206 class FIF : public Task {
00207 public:
00208 void run( Session* session, const std::string& argument );
00209 };
00210
00211
00213 class JTL : public Task {
00214 public:
00215 void run( Session* session, const std::string& argument );
00216 };
00217
00218
00220 class JTLS : public Task {
00221 public:
00222 void run( Session* session, const std::string& argument );
00223 };
00224
00225
00227 class TIL : public Task {
00228 public:
00229 void run( Session* session, const std::string& argument );
00230 };
00231
00232
00234 class CVT : public Task {
00235 public:
00236 void run( Session* session, const std::string& argument );
00237 };
00238
00239
00241 class ICC : public Task {
00242 public:
00243 void run( Session* session, const std::string& argument );
00244 };
00245
00246
00248 class SHD : public Task {
00249 public:
00250 void run( Session* session, const std::string& argument );
00251 };
00252
00253
00255 class Zoomify : public Task {
00256 public:
00257 void run( Session* session, const std::string& argument );
00258 };
00259
00260
00262 class SPECTRA : public Task {
00263 public:
00264 void run( Session* session, const std::string& argument );
00265 };
00266
00267
00269 class LYR : public Task {
00270 public:
00271 void run( Session* session, const std::string& argument );
00272 };
00273
00274
00276 class DeepZoom : public Task {
00277 public:
00278 void run( Session* session, const std::string& argument );
00279 };
00280
00281
00282 #endif