iipsrv  0.9.9
Task.h
1 /*
2  IIP Generic Task Class
3 
4  Copyright (C) 2006-2007 Ruven Pillay.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 
21 
22 #ifndef _TASK_H
23 #define _TASK_H
24 
25 
26 
27 #include <string>
28 #include <fstream>
29 #include "IIPImage.h"
30 #include "IIPResponse.h"
31 #include "JPEGCompressor.h"
32 #include "View.h"
33 #include "TileManager.h"
34 #include "Timer.h"
35 #include "Writer.h"
36 #include "Cache.h"
37 #include "Watermark.h"
38 
39 
40 // Define our http header cache max age
41 #define MAX_AGE 86400
42 
43 
44 // Use the hashmap extensions if we are using >= gcc 3.1
45 #ifdef __GNUC__
46 
47 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ >= 4)
48 #define USE_HASHMAP 1
49 #endif
50 
51 // And the high performance memory pool allocator if >= gcc 3.4
52 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)
53 #define USE_POOL_ALLOCATOR 1
54 #endif
55 
56 #endif
57 
58 
59 
60 #ifdef USE_HASHMAP
61 #include <ext/hash_map>
62 
63 #ifdef USE_POOL_ALLOCATOR
64 #include <ext/pool_allocator.h>
65 typedef __gnu_cxx::hash_map < const std::string, IIPImage,
66  __gnu_cxx::hash< const std::string >,
67  std::equal_to< const std::string >,
68  __gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
69  > imageCacheMapType;
70 #else
71 typedef __gnu_cxx::hash_map <const std::string,IIPImage> imageCacheMapType;
72 #endif
73 
74 #else
75 typedef std::map<const std::string,IIPImage> imageCacheMapType;
76 #endif
77 
78 
79 
80 
82 struct Session {
83  IIPImage **image;
84  JPEGCompressor* jpeg;
85  View* view;
86  IIPResponse* response;
87  Watermark* watermark;
88  int loglevel;
89  std::ofstream* logfile;
90  std::map <const std::string, std::string> headers;
91 
92  imageCacheMapType *imageCache;
93  Cache* tileCache;
94 
95 #ifdef DEBUG
96  FileWriter* out;
97 #else
98  FCGIWriter* out;
99 #endif
100 
101 };
102 
103 
104 
105 
107 class Task {
108 
109  protected:
110 
113 
116 
118  std::string argument;
119 
120 
121  public:
122 
124  virtual ~Task() {;};
125 
127  virtual void run( Session* session, const std::string& argument ) {;};
128 
130 
131  static Task* factory( const std::string& type );
132 
133 
135  void checkImage();
136 
137 };
138 
139 
140 
141 
143 class OBJ : public Task {
144 
145  public:
146 
147  void run( Session* session, const std::string& argument );
148 
149  void iip();
150  void iip_server();
151  void max_size();
152  void resolution_number();
153  void colorspace( std::string arg );
154  void tile_size();
155  void bits_per_channel();
156  void horizontal_views();
157  void vertical_views();
158  void metadata( std::string field );
159 
160 };
161 
162 
164 class QLT : public Task {
165  public:
166  void run( Session* session, const std::string& argument );
167 };
168 
169 
171 class SDS : public Task {
172  public:
173  void run( Session* session, const std::string& argument );
174 };
175 
176 
178 class CNT : public Task {
179  public:
180  void run( Session* session, const std::string& argument );
181 };
182 
183 
185 class WID : public Task {
186  public:
187  void run( Session* session, const std::string& argument );
188 };
189 
190 
192 class HEI : public Task {
193  public:
194  void run( Session* session, const std::string& argument );
195 };
196 
197 
199 class RGN : public Task {
200  public:
201  void run( Session* session, const std::string& argument );
202 };
203 
204 
206 class FIF : public Task {
207  public:
208  void run( Session* session, const std::string& argument );
209 };
210 
211 
213 class JTL : public Task {
214  public:
215  void run( Session* session, const std::string& argument );
216 };
217 
218 
220 class JTLS : public Task {
221  public:
222  void run( Session* session, const std::string& argument );
223 };
224 
225 
227 class TIL : public Task {
228  public:
229  void run( Session* session, const std::string& argument );
230 };
231 
232 
234 class CVT : public Task {
235  public:
236  void run( Session* session, const std::string& argument );
237 };
238 
239 
241 class ICC : public Task {
242  public:
243  void run( Session* session, const std::string& argument );
244 };
245 
246 
248 class SHD : public Task {
249  public:
250  void run( Session* session, const std::string& argument );
251 };
252 
253 
255 class Zoomify : public Task {
256  public:
257  void run( Session* session, const std::string& argument );
258 };
259 
260 
262 class SPECTRA : public Task {
263  public:
264  void run( Session* session, const std::string& argument );
265 };
266 
267 
269 class LYR : public Task {
270  public:
271  void run( Session* session, const std::string& argument );
272 };
273 
274 
276 class DeepZoom : public Task {
277  public:
278  void run( Session* session, const std::string& argument );
279 };
280 
281 
282 #endif