iipsrv  1.0
Task.h
1 /*
2  IIP Generic Task Class
3 
4  Copyright (C) 2006-2016 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 3 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 Foundation,
18  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 #ifdef HAVE_PNG
39 #include "PNGCompressor.h"
40 #endif
41 
42 
43 // Define our http header cache max age (24 hours)
44 #define MAX_AGE 86400
45 
46 
47 
48 #ifdef HAVE_EXT_POOL_ALLOCATOR
49 #include <ext/pool_allocator.h>
50 typedef HASHMAP < std::string, IIPImage,
51  __gnu_cxx::hash< const std::string >,
52  std::equal_to< const std::string >,
53  __gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
54  > imageCacheMapType;
55 #else
56 typedef HASHMAP <std::string,IIPImage> imageCacheMapType;
57 #endif
58 
59 
60 
61 
62 
63 
65 struct Session {
66  IIPImage **image;
67  JPEGCompressor* jpeg;
68 #ifdef HAVE_PNG
69  PNGCompressor* png;
70 #endif
71  View* view;
72  IIPResponse* response;
73  Watermark* watermark;
74  int loglevel;
75  std::ofstream* logfile;
76  std::map <const std::string, std::string> headers;
77 
78  imageCacheMapType *imageCache;
79  Cache* tileCache;
80 
81 #ifdef DEBUG
82  FileWriter* out;
83 #else
84  FCGIWriter* out;
85 #endif
86 
87 };
88 
89 
90 
91 
93 class Task {
94 
95  protected:
96 
99 
102 
104  std::string argument;
105 
106 
107  public:
108 
110  virtual ~Task() {;};
111 
113  virtual void run( Session* session, const std::string& argument ) {;};
114 
116 
117  static Task* factory( const std::string& type );
118 
120  void checkImage();
121 
122 };
123 
124 
125 
126 
128 class OBJ : public Task {
129 
130  public:
131 
132  void run( Session* session, const std::string& argument );
133 
134  void iip();
135  void iip_server();
136  void max_size();
137  void resolution_number();
138  void colorspace( std::string arg );
139  void tile_size();
140  void bits_per_channel();
141  void horizontal_views();
142  void vertical_views();
143  void min_max_values();
144  void metadata( std::string field );
145 
146 };
147 
148 
150 class QLT : public Task {
151  public:
152  void run( Session* session, const std::string& argument );
153 };
154 
155 
157 class SDS : public Task {
158  public:
159  void run( Session* session, const std::string& argument );
160 };
161 
162 
164 class MINMAX : public Task {
165  public:
166  void run( Session* session, const std::string& argument );
167 };
168 
169 
171 class CNT : public Task {
172  public:
173  void run( Session* session, const std::string& argument );
174 };
175 
176 
178 class GAM : 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 ROT : public Task {
207  public:
208  void run( Session* session, const std::string& argument );
209 };
210 
211 
213 class FIF : public Task {
214  public:
215  void run( Session* session, const std::string& argument );
216 };
217 
218 
220 /*class PTL : public Task {
221  public:
222  void run( Session* session, const std::string& argument );
223 };*/
224 
225 
227 class JTL : public Task {
228  public:
229  void run( Session* session, const std::string& argument );
230 
232 
236  void send( Session* session, int resolution, int tile );
237 };
238 
239 
241 class JTLS : public Task {
242  public:
243  void run( Session* session, const std::string& argument );
244 };
245 
246 
248 class TIL : public Task {
249  public:
250  void run( Session* session, const std::string& argument );
251 };
252 
253 
255 class CVT : public Task {
256  public:
257  void run( Session* session, const std::string& argument );
258 
260 
261  void send( Session* session );
262 };
263 
264 
266 class ICC : public Task {
267  public:
268  void run( Session* session, const std::string& argument );
269 };
270 
271 
273 class SHD : public Task {
274  public:
275  void run( Session* session, const std::string& argument );
276 };
277 
279 class CMP : public Task {
280  public:
281  void run( Session* session, const std::string& argument );
282 };
283 
285 class INV : public Task {
286  public:
287  void run( Session* session, const std::string& argument );
288 };
289 
291 class Zoomify : public Task {
292  public:
293  void run( Session* session, const std::string& argument );
294 };
295 
296 
298 class SPECTRA : public Task {
299  public:
300  void run( Session* session, const std::string& argument );
301 };
302 
303 
305 class PFL : public Task {
306  public:
307  void run( Session* session, const std::string& argument );
308 };
309 
310 
312 class LYR : public Task {
313  public:
314  void run( Session* session, const std::string& argument );
315 };
316 
317 
319 class DeepZoom : public Task {
320  public:
321  void run( Session* session, const std::string& argument );
322 };
323 
324 
326 class IIIF : public Task {
327  public:
328  void run( Session* session, const std::string& argument );
329 };
330 
331 
333 class CTW : public Task {
334  public:
335  void run( Session* session, const std::string& argument );
336 };
337 
338 
339 
340 #endif
JPEG Tile Sequence Command.
Definition: Task.h:241
DeepZoom Request Command.
Definition: Task.h:319
Class to handle non-image IIP responses including errors.
Definition: IIPResponse.h:40
Quality Layers Command.
Definition: Task.h:312
Colormap Command.
Definition: Task.h:279
Wrapper class to the IJG JPEG library.
Definition: JPEGCompressor.h:60
virtual ~Task()
Virtual destructor.
Definition: Task.h:110
FIF Command.
Definition: Task.h:213
ICC Profile Command.
Definition: Task.h:266
virtual void run(Session *session, const std::string &argument)
Main public function.
Definition: Task.h:113
PNG Tile Command.
Definition: Task.h:227
Inversion Command.
Definition: Task.h:285
ROT Rotation Command.
Definition: Task.h:206
Gamma Command.
Definition: Task.h:178
Zoomify Request Command.
Definition: Task.h:291
Cache to store raw tile data.
Definition: Cache.h:91
CVT Height Command.
Definition: Task.h:192
File Writer Class.
Definition: Writer.h:113
CVT Region Export Command.
Definition: Task.h:255
CVT Width Command.
Definition: Task.h:185
SDS Command.
Definition: Task.h:157
MINMAX Command.
Definition: Task.h:164
std::string argument
Argument supplied to the task.
Definition: Task.h:104
Watermark class.
Definition: Watermark.h:41
Structure to hold our session data.
Definition: Task.h:65
FCGI Writer Class.
Definition: Writer.h:59
Main class to handle the pyramidal image source.
Definition: IIPImage.h:61
SPECTRA Request Command.
Definition: Task.h:298
JPEG Quality Command.
Definition: Task.h:150
Class to intelligently handle Image Transforms.
Definition: View.h:41
Session * session
Pointer to our session data.
Definition: Task.h:101
Tile Command.
Definition: Task.h:248
OBJ commands.
Definition: Task.h:128
Simple Timer class to allow us to time our responses.
Definition: Timer.h:39
Timer command_timer
Timer for each task.
Definition: Task.h:98
Contrast Command.
Definition: Task.h:171
Generic class to encapsulate various commands.
Definition: Task.h:93
IIIF Command.
Definition: Task.h:326
CVT Region Command.
Definition: Task.h:199
SPECTRA Request Command.
Definition: Task.h:305
Shading Command.
Definition: Task.h:273
Color Twist Command.
Definition: Task.h:333