iipsrv 1.2
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-2023 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#ifdef HAVE_WEBP
43#include "WebPCompressor.h"
44#endif
45
46
47// Define our http header cache max age (24 hours)
48#define MAX_AGE 86400
49
50
51
52#ifdef HAVE_EXT_POOL_ALLOCATOR
53#include <ext/pool_allocator.h>
54typedef HASHMAP < std::string, IIPImage,
55 __gnu_cxx::hash< const std::string >,
56 std::equal_to< const std::string >,
57 __gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
58 > imageCacheMapType;
59#else
60typedef HASHMAP <std::string,IIPImage> imageCacheMapType;
61#endif
62
63
64
65
66
67
69struct Session {
70 IIPImage **image;
71 JPEGCompressor* jpeg;
72#ifdef HAVE_PNG
73 PNGCompressor* png;
74#endif
75#ifdef HAVE_WEBP
76 WebPCompressor* webp;
77#endif
78 View* view;
79 IIPResponse* response;
80 Watermark* watermark;
81 Transform* processor;
82 int loglevel;
83 Logger* logfile;
84 std::map <const std::string, std::string> headers;
85 std::map <const std::string, unsigned int> codecOptions;
86
87 imageCacheMapType *imageCache;
88 Cache* tileCache;
89
90#ifdef DEBUG
91 FileWriter* out;
92#else
93 FCGIWriter* out;
94#endif
95
96};
97
98
99
100
102class Task {
103
104 protected:
105
108
111
113 std::string argument;
114
115
116 public:
117
119 virtual ~Task() {};
120
122 virtual void run( Session* session, const std::string& argument ) {};
123
125
126 static Task* factory( const std::string& type );
127
130
131};
132
133
134
135
137class OBJ : public Task {
138
139 public:
140
141 void run( Session* session, const std::string& argument );
142
143 void iip();
144 void iip_server();
145 void max_size();
146 void resolution_number();
147 void colorspace( std::string arg );
148 void tile_size();
149 void bits_per_channel();
150 void horizontal_views();
151 void vertical_views();
152 void min_max_values();
153 void resolutions();
154 void dpi();
155 void metadata( std::string field );
156 void stack();
157
158};
159
160
162class QLT : public Task {
163 public:
164 void run( Session* session, const std::string& argument );
165};
166
167
169class SDS : public Task {
170 public:
171 void run( Session* session, const std::string& argument );
172};
173
174
176class MINMAX : public Task {
177 public:
178 void run( Session* session, const std::string& argument );
179};
180
181
183class CNT : public Task {
184 public:
185 void run( Session* session, const std::string& argument );
186};
187
188
190class GAM : public Task {
191 public:
192 void run( Session* session, const std::string& argument );
193};
194
195
197class WID : public Task {
198 public:
199 void run( Session* session, const std::string& argument );
200};
201
202
204class HEI : public Task {
205 public:
206 void run( Session* session, const std::string& argument );
207};
208
209
211class RGN : public Task {
212 public:
213 void run( Session* session, const std::string& argument );
214};
215
216
218class ROT : public Task {
219 public:
220 void run( Session* session, const std::string& argument );
221};
222
223
225class FIF : public Task {
226 public:
227 void run( Session* session, const std::string& argument );
228};
229
230
232class JTL : public Task {
233 public:
234 void run( Session* session, const std::string& argument );
235
237
241 void send( Session* session, int resolution, int tile );
242};
243
244
246class PTL : public JTL {
247 public:
248 void run( Session* session, const std::string& argument ){
249 // Set our encoding format and call JTL::run
250 session->view->output_format = PNG;
252 };
253};
254
255
257class WTL : public JTL {
258public:
259 void run( Session* session, const std::string& argument ){
260 // Set our encoding format and call JTL::run
261 session->view->output_format = WEBP;
263 };
264};
265
266
268class JTLS : public Task {
269 public:
270 void run( Session* session, const std::string& argument );
271};
272
273
275class TIL : public Task {
276 public:
277 void run( Session* session, const std::string& argument );
278};
279
280
282class CVT : public Task {
283 public:
284 void run( Session* session, const std::string& argument );
285
287
289};
290
291
293class ICC : public Task {
294 public:
295 void run( Session* session, const std::string& argument );
296};
297
298
300class SHD : public Task {
301 public:
302 void run( Session* session, const std::string& argument );
303};
304
305
307class CMP : public Task {
308 public:
309 void run( Session* session, const std::string& argument );
310};
311
312
314class INV : public Task {
315 public:
316 void run( Session* session, const std::string& argument );
317};
318
319
321class Zoomify : public Task {
322 public:
323 void run( Session* session, const std::string& argument );
324};
325
326
328class SPECTRA : public Task {
329 public:
330 void run( Session* session, const std::string& argument );
331};
332
333
335class PFL : public Task {
336 public:
337 void run( Session* session, const std::string& argument );
338};
339
340
342class LYR : public Task {
343 public:
344 void run( Session* session, const std::string& argument );
345};
346
347
349class DeepZoom : public Task {
350 public:
351 void run( Session* session, const std::string& argument );
352};
353
354
356class IIIF : public Task {
357 public:
358 void run( Session* session, const std::string& argument );
359};
360
361
363class CTW : public Task {
364 public:
365 void run( Session* session, const std::string& argument );
366};
367
368
370class COL : public Task {
371 public:
372 void run( Session* session, const std::string& argument );
373};
374
375
377class CNV : public Task {
378 public:
379 void run( Session* session, const std::string& argument );
380};
381
382
383#endif
Colormap Command.
Definition: Task.h:307
void run(Session *session, const std::string &argument)
Main public function.
Contrast Command.
Definition: Task.h:183
void run(Session *session, const std::string &argument)
Main public function.
CNV Convolution Filter Command.
Definition: Task.h:377
void run(Session *session, const std::string &argument)
Main public function.
Color Conversion Command.
Definition: Task.h:370
void run(Session *session, const std::string &argument)
Main public function.
Color Twist Command.
Definition: Task.h:363
void run(Session *session, const std::string &argument)
Main public function.
CVT Region Export Command.
Definition: Task.h:282
void run(Session *session, const std::string &argument)
Main public function.
void send(Session *session)
Send out our requested region.
Cache to store raw tile data.
Definition: Cache.h:90
DeepZoom Request Command.
Definition: Task.h:349
void run(Session *session, const std::string &argument)
Main public function.
FCGI Writer Class.
Definition: Writer.h:65
FIF Command.
Definition: Task.h:225
void run(Session *session, const std::string &argument)
Main public function.
File Writer Class.
Definition: Writer.h:121
Gamma Command.
Definition: Task.h:190
void run(Session *session, const std::string &argument)
Main public function.
CVT Height Command.
Definition: Task.h:204
void run(Session *session, const std::string &argument)
Main public function.
ICC Profile Command.
Definition: Task.h:293
void run(Session *session, const std::string &argument)
Main public function.
IIIF Command.
Definition: Task.h:356
void run(Session *session, const std::string &argument)
Main public function.
Main class to handle the pyramidal image source.
Definition: IIPImage.h:76
Class to handle non-image IIP responses including errors.
Definition: IIPResponse.h:40
Inversion Command.
Definition: Task.h:314
void run(Session *session, const std::string &argument)
Main public function.
Wrapper class to the IJG JPEG library.
Definition: JPEGCompressor.h:60
JPEG Tile Sequence Command.
Definition: Task.h:268
void run(Session *session, const std::string &argument)
Main public function.
JPEG Tile Export Command.
Definition: Task.h:232
void send(Session *session, int resolution, int tile)
Send out a single tile.
void run(Session *session, const std::string &argument)
Main public function.
Quality Layers Command.
Definition: Task.h:342
void run(Session *session, const std::string &argument)
Main public function.
Logger class - handles ofstreams and syslog.
Definition: Logger.h:79
MINMAX Command.
Definition: Task.h:176
void run(Session *session, const std::string &argument)
Main public function.
OBJ commands.
Definition: Task.h:137
void run(Session *session, const std::string &argument)
Main public function.
SPECTRA Request Command.
Definition: Task.h:335
void run(Session *session, const std::string &argument)
Main public function.
Wrapper class to PNG library: Handles 8 and 16 bit PNG as well as alpha transparency.
Definition: PNGCompressor.h:57
PNG Tile Command.
Definition: Task.h:246
void run(Session *session, const std::string &argument)
Main public function.
Definition: Task.h:248
JPEG Quality Command.
Definition: Task.h:162
void run(Session *session, const std::string &argument)
Main public function.
CVT Region Command.
Definition: Task.h:211
void run(Session *session, const std::string &argument)
Main public function.
ROT Rotation Command.
Definition: Task.h:218
void run(Session *session, const std::string &argument)
Main public function.
SDS Command.
Definition: Task.h:169
void run(Session *session, const std::string &argument)
Main public function.
Shading Command.
Definition: Task.h:300
void run(Session *session, const std::string &argument)
Main public function.
SPECTRA Request Command.
Definition: Task.h:328
void run(Session *session, const std::string &argument)
Main public function.
Tile Command.
Definition: Task.h:275
void run(Session *session, const std::string &argument)
Main public function.
Generic class to encapsulate various commands.
Definition: Task.h:102
std::string argument
Argument supplied to the task.
Definition: Task.h:113
virtual ~Task()
Virtual destructor.
Definition: Task.h:119
Session * session
Pointer to our session data.
Definition: Task.h:110
Timer command_timer
Timer for each task.
Definition: Task.h:107
void checkImage()
Check image.
virtual void run(Session *session, const std::string &argument)
Main public function.
Definition: Task.h:122
static Task * factory(const std::string &type)
Factory function.
Simple Timer class to allow us to time our responses.
Definition: Timer.h:40
Class to intelligently handle Image Transforms.
Definition: View.h:36
CompressionType output_format
Indicate whether we should embed ICC profiles.
Definition: View.h:80
CVT Width Command.
Definition: Task.h:197
void run(Session *session, const std::string &argument)
Main public function.
WebP Tile Command.
Definition: Task.h:257
void run(Session *session, const std::string &argument)
Main public function.
Definition: Task.h:259
Watermark class.
Definition: Watermark.h:41
Wrapper class to WebP library: Handles 8 and 16 bit PNG as well as alpha transparency.
Definition: WebPCompressor.h:34
Zoomify Request Command.
Definition: Task.h:321
void run(Session *session, const std::string &argument)
Main public function.
Structure to hold our session data.
Definition: Task.h:69
Image Processing Transforms.
Definition: Transforms.h:40