iipsrv  1.1
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
Task.h
1 /*
2  IIP Generic Task Class
3 
4  Copyright (C) 2006-2019 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 #include <string>
27 
28 #include "IIPImage.h"
29 #include "IIPResponse.h"
30 #include "JPEGCompressor.h"
31 #include "View.h"
32 #include "TileManager.h"
33 #include "Timer.h"
34 #include "Writer.h"
35 #include "Cache.h"
36 #include "Watermark.h"
37 #include "Transforms.h"
38 #include "Logger.h"
39 #ifdef HAVE_PNG
40 #include "PNGCompressor.h"
41 #endif
42 
43 
44 // Define our http header cache max age (24 hours)
45 #define MAX_AGE 86400
46 
47 
48 
49 #ifdef HAVE_EXT_POOL_ALLOCATOR
50 #include <ext/pool_allocator.h>
51 typedef HASHMAP < std::string, IIPImage,
52  __gnu_cxx::hash< const std::string >,
53  std::equal_to< const std::string >,
54  __gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
55  > imageCacheMapType;
56 #else
57 typedef HASHMAP <std::string,IIPImage> imageCacheMapType;
58 #endif
59 
60 
61 
62 
63 
64 
66 struct Session {
67  IIPImage **image;
68  JPEGCompressor* jpeg;
69 #ifdef HAVE_PNG
70  PNGCompressor* png;
71 #endif
72  View* view;
73  IIPResponse* response;
74  Watermark* watermark;
75  Transform* processor;
76  int loglevel;
77  Logger* logfile;
78  std::map <const std::string, std::string> headers;
79  std::map <const std::string, unsigned int> codecOptions;
80 
81  imageCacheMapType *imageCache;
82  Cache* tileCache;
83 
84 #ifdef DEBUG
85  FileWriter* out;
86 #else
87  FCGIWriter* out;
88 #endif
89 
90 };
91 
92 
93 
94 
96 class Task {
97 
98  protected:
99 
102 
105 
107  std::string argument;
108 
109 
110  public:
111 
113  virtual ~Task() {;};
114 
116  virtual void run( Session* session, const std::string& argument ) {;};
117 
119 
120  static Task* factory( const std::string& type );
121 
123  void checkImage();
124 
125 };
126 
127 
128 
129 
131 class OBJ : public Task {
132 
133  public:
134 
135  void run( Session* session, const std::string& argument );
136 
137  void iip();
138  void iip_server();
139  void max_size();
140  void resolution_number();
141  void colorspace( std::string arg );
142  void tile_size();
143  void bits_per_channel();
144  void horizontal_views();
145  void vertical_views();
146  void min_max_values();
147  void resolutions();
148  void metadata( std::string field );
149 
150 };
151 
152 
154 class QLT : public Task {
155  public:
156  void run( Session* session, const std::string& argument );
157 };
158 
159 
161 class SDS : public Task {
162  public:
163  void run( Session* session, const std::string& argument );
164 };
165 
166 
168 class MINMAX : public Task {
169  public:
170  void run( Session* session, const std::string& argument );
171 };
172 
173 
175 class CNT : public Task {
176  public:
177  void run( Session* session, const std::string& argument );
178 };
179 
180 
182 class GAM : public Task {
183  public:
184  void run( Session* session, const std::string& argument );
185 };
186 
187 
189 class WID : public Task {
190  public:
191  void run( Session* session, const std::string& argument );
192 };
193 
194 
196 class HEI : public Task {
197  public:
198  void run( Session* session, const std::string& argument );
199 };
200 
201 
203 class RGN : public Task {
204  public:
205  void run( Session* session, const std::string& argument );
206 };
207 
208 
210 class ROT : public Task {
211  public:
212  void run( Session* session, const std::string& argument );
213 };
214 
215 
217 class FIF : public Task {
218  public:
219  void run( Session* session, const std::string& argument );
220 };
221 
222 
224 /*class PTL : public Task {
225  public:
226  void run( Session* session, const std::string& argument );
227 };*/
228 
229 
231 class JTL : public Task {
232  public:
233  void run( Session* session, const std::string& argument );
234 
236 
240  void send( Session* session, int resolution, int tile );
241 };
242 
243 
245 class JTLS : public Task {
246  public:
247  void run( Session* session, const std::string& argument );
248 };
249 
250 
252 class TIL : public Task {
253  public:
254  void run( Session* session, const std::string& argument );
255 };
256 
257 
259 class CVT : public Task {
260  public:
261  void run( Session* session, const std::string& argument );
262 
264 
265  void send( Session* session );
266 };
267 
268 
270 class ICC : public Task {
271  public:
272  void run( Session* session, const std::string& argument );
273 };
274 
275 
277 class SHD : public Task {
278  public:
279  void run( Session* session, const std::string& argument );
280 };
281 
282 
284 class CMP : public Task {
285  public:
286  void run( Session* session, const std::string& argument );
287 };
288 
289 
291 class INV : public Task {
292  public:
293  void run( Session* session, const std::string& argument );
294 };
295 
296 
298 class Zoomify : public Task {
299  public:
300  void run( Session* session, const std::string& argument );
301 };
302 
303 
305 class SPECTRA : public Task {
306  public:
307  void run( Session* session, const std::string& argument );
308 };
309 
310 
312 class PFL : public Task {
313  public:
314  void run( Session* session, const std::string& argument );
315 };
316 
317 
319 class LYR : public Task {
320  public:
321  void run( Session* session, const std::string& argument );
322 };
323 
324 
326 class DeepZoom : public Task {
327  public:
328  void run( Session* session, const std::string& argument );
329 };
330 
331 
333 class IIIF : public Task {
334  public:
335  void run( Session* session, const std::string& argument );
336 };
337 
338 
340 class CTW : public Task {
341  public:
342  void run( Session* session, const std::string& argument );
343 };
344 
345 
347 class COL : public Task {
348  public:
349  void run( Session* session, const std::string& argument );
350 };
351 
352 
353 #endif
Logger class - handles ofstreams and syslog.
Definition: Logger.h:79
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
JPEG Tile Sequence Command.
Definition: Task.h:245
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
DeepZoom Request Command.
Definition: Task.h:326
Color Conversion Command.
Definition: Task.h:347
Class to handle non-image IIP responses including errors.
Definition: IIPResponse.h:40
Quality Layers Command.
Definition: Task.h:319
Colormap Command.
Definition: Task.h:284
Wrapper class to the IJG JPEG library.
Definition: JPEGCompressor.h:63
virtual ~Task()
Virtual destructor.
Definition: Task.h:113
FIF Command.
Definition: Task.h:217
void run(Session *session, const std::string &argument)
Main public function.
ICC Profile Command.
Definition: Task.h:270
void run(Session *session, const std::string &argument)
Main public function.
virtual void run(Session *session, const std::string &argument)
Main public function.
Definition: Task.h:116
void run(Session *session, const std::string &argument)
Main public function.
PNG Tile Command.
Definition: Task.h:231
Inversion Command.
Definition: Task.h:291
ROT Rotation Command.
Definition: Task.h:210
Gamma Command.
Definition: Task.h:182
Zoomify Request Command.
Definition: Task.h:298
void run(Session *session, const std::string &argument)
Main public function.
Cache to store raw tile data.
Definition: Cache.h:91
CVT Height Command.
Definition: Task.h:196
void checkImage()
Check image.
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
void send(Session *session, int resolution, int tile)
Send out a single tile.
void run(Session *session, const std::string &argument)
Main public function.
File Writer Class.
Definition: Writer.h:113
void run(Session *session, const std::string &argument)
Main public function.
CVT Region Export Command.
Definition: Task.h:259
CVT Width Command.
Definition: Task.h:189
SDS Command.
Definition: Task.h:161
MINMAX Command.
Definition: Task.h:168
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
std::string argument
Argument supplied to the task.
Definition: Task.h:107
Watermark class.
Definition: Watermark.h:41
Structure to hold our session data.
Definition: Task.h:66
void run(Session *session, const std::string &argument)
Main public function.
FCGI Writer Class.
Definition: Writer.h:59
Main class to handle the pyramidal image source.
Definition: IIPImage.h:62
SPECTRA Request Command.
Definition: Task.h:305
void send(Session *session)
Send out our requested region.
JPEG Quality Command.
Definition: Task.h:154
Class to intelligently handle Image Transforms.
Definition: View.h:36
Image Processing Transforms.
Definition: Transforms.h:40
Session * session
Pointer to our session data.
Definition: Task.h:104
void run(Session *session, const std::string &argument)
Main public function.
static Task * factory(const std::string &type)
Factory function.
Tile Command.
Definition: Task.h:252
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
OBJ commands.
Definition: Task.h:131
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
Simple Timer class to allow us to time our responses.
Definition: Timer.h:39
Timer command_timer
Timer for each task.
Definition: Task.h:101
Contrast Command.
Definition: Task.h:175
Generic class to encapsulate various commands.
Definition: Task.h:96
void run(Session *session, const std::string &argument)
Main public function.
void run(Session *session, const std::string &argument)
Main public function.
IIIF Command.
Definition: Task.h:333
CVT Region Command.
Definition: Task.h:203
SPECTRA Request Command.
Definition: Task.h:312
void run(Session *session, const std::string &argument)
Main public function.
Shading Command.
Definition: Task.h:277
void run(Session *session, const std::string &argument)
Main public function.
Color Twist Command.
Definition: Task.h:340
void run(Session *session, const std::string &argument)
Main public function.