Task.h
/*
IIP Generic Task Class
Copyright (C) 2006-2019 Ruven Pillay
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _TASK_H
#define _TASK_H
#include <string>
#include "IIPImage.h"
#include "IIPResponse.h"
#include "JPEGCompressor.h"
#include "View.h"
#include "TileManager.h"
#include "Timer.h"
#include "Writer.h"
#include "Cache.h"
#include "Watermark.h"
#include "Transforms.h"
#include "Logger.h"
#ifdef HAVE_PNG
#include "PNGCompressor.h"
#endif
// Define our http header cache max age (24 hours)
#define MAX_AGE 86400
#ifdef HAVE_EXT_POOL_ALLOCATOR
#include <ext/pool_allocator.h>
typedef HASHMAP < std::string, IIPImage,
__gnu_cxx::hash< const std::string >,
std::equal_to< const std::string >,
__gnu_cxx::__pool_alloc< std::pair<const std::string,IIPImage> >
> imageCacheMapType;
#else
typedef HASHMAP <std::string,IIPImage> imageCacheMapType;
#endif
struct Session {
IIPImage **image;
JPEGCompressor* jpeg;
#ifdef HAVE_PNG
PNGCompressor* png;
#endif
View* view;
IIPResponse* response;
Watermark* watermark;
Transform* processor;
int loglevel;
Logger* logfile;
std::map <const std::string, std::string> headers;
std::map <const std::string, unsigned int> codecOptions;
imageCacheMapType *imageCache;
Cache* tileCache;
#ifdef DEBUG
FileWriter* out;
#else
FCGIWriter* out;
#endif
};
class Task {
protected:
Timer command_timer;
Session* session;
std::string argument;
public:
virtual ~Task() {;};
virtual void run( Session* session, const std::string& argument ) {;};
static Task* factory( const std::string& type );
void checkImage();
};
class OBJ : public Task {
public:
void run( Session* session, const std::string& argument );
void iip();
void iip_server();
void max_size();
void resolution_number();
void colorspace( std::string arg );
void tile_size();
void bits_per_channel();
void horizontal_views();
void vertical_views();
void min_max_values();
void resolutions();
void metadata( std::string field );
};
class QLT : public Task {
public:
void run( Session* session, const std::string& argument );
};
class SDS : public Task {
public:
void run( Session* session, const std::string& argument );
};
class MINMAX : public Task {
public:
void run( Session* session, const std::string& argument );
};
class CNT : public Task {
public:
void run( Session* session, const std::string& argument );
};
class GAM : public Task {
public:
void run( Session* session, const std::string& argument );
};
class WID : public Task {
public:
void run( Session* session, const std::string& argument );
};
class HEI : public Task {
public:
void run( Session* session, const std::string& argument );
};
class RGN : public Task {
public:
void run( Session* session, const std::string& argument );
};
class ROT : public Task {
public:
void run( Session* session, const std::string& argument );
};
class FIF : public Task {
public:
void run( Session* session, const std::string& argument );
};
/*class PTL : public Task {
public:
void run( Session* session, const std::string& argument );
};*/
class JTL : public Task {
public:
void run( Session* session, const std::string& argument );
void send( Session* session, int resolution, int tile );
};
class JTLS : public Task {
public:
void run( Session* session, const std::string& argument );
};
class TIL : public Task {
public:
void run( Session* session, const std::string& argument );
};
class CVT : public Task {
public:
void run( Session* session, const std::string& argument );
void send( Session* session );
};
class ICC : public Task {
public:
void run( Session* session, const std::string& argument );
};
class SHD : public Task {
public:
void run( Session* session, const std::string& argument );
};
class CMP : public Task {
public:
void run( Session* session, const std::string& argument );
};
class INV : public Task {
public:
void run( Session* session, const std::string& argument );
};
class Zoomify : public Task {
public:
void run( Session* session, const std::string& argument );
};
class SPECTRA : public Task {
public:
void run( Session* session, const std::string& argument );
};
class PFL : public Task {
public:
void run( Session* session, const std::string& argument );
};
class LYR : public Task {
public:
void run( Session* session, const std::string& argument );
};
class DeepZoom : public Task {
public:
void run( Session* session, const std::string& argument );
};
class IIIF : public Task {
public:
void run( Session* session, const std::string& argument );
};
class CTW : public Task {
public:
void run( Session* session, const std::string& argument );
};
class COL : public Task {
public:
void run( Session* session, const std::string& argument );
};
#endif
CMP
Colormap Command.
Definition Task.h:284
CMP::run
void run(Session *session, const std::string &argument)
Main public function.
CNT
Contrast Command.
Definition Task.h:175
CNT::run
void run(Session *session, const std::string &argument)
Main public function.
COL
Color Conversion Command.
Definition Task.h:347
COL::run
void run(Session *session, const std::string &argument)
Main public function.
CTW
Color Twist Command.
Definition Task.h:340
CTW::run
void run(Session *session, const std::string &argument)
Main public function.
CVT
CVT Region Export Command.
Definition Task.h:259
CVT::run
void run(Session *session, const std::string &argument)
Main public function.
CVT::send
void send(Session *session)
Send out our requested region.
Cache
Cache to store raw tile data.
Definition Cache.h:91
DeepZoom
DeepZoom Request Command.
Definition Task.h:326
DeepZoom::run
void run(Session *session, const std::string &argument)
Main public function.
FCGIWriter
FCGI Writer Class.
Definition Writer.h:59
FIF
FIF Command.
Definition Task.h:217
FIF::run
void run(Session *session, const std::string &argument)
Main public function.
FileWriter
File Writer Class.
Definition Writer.h:113
GAM
Gamma Command.
Definition Task.h:182
GAM::run
void run(Session *session, const std::string &argument)
Main public function.
HEI
CVT Height Command.
Definition Task.h:196
HEI::run
void run(Session *session, const std::string &argument)
Main public function.
ICC
ICC Profile Command.
Definition Task.h:270
ICC::run
void run(Session *session, const std::string &argument)
Main public function.
IIIF
IIIF Command.
Definition Task.h:333
IIIF::run
void run(Session *session, const std::string &argument)
Main public function.
IIPImage
Main class to handle the pyramidal image source.
Definition IIPImage.h:62
IIPResponse
Class to handle non-image IIP responses including errors.
Definition IIPResponse.h:40
INV
Inversion Command.
Definition Task.h:291
INV::run
void run(Session *session, const std::string &argument)
Main public function.
JPEGCompressor
Wrapper class to the IJG JPEG library.
Definition JPEGCompressor.h:63
JTLS
JPEG Tile Sequence Command.
Definition Task.h:245
JTLS::run
void run(Session *session, const std::string &argument)
Main public function.
JTL
PNG Tile Command.
Definition Task.h:231
JTL::send
void send(Session *session, int resolution, int tile)
Send out a single tile.
JTL::run
void run(Session *session, const std::string &argument)
Main public function.
LYR
Quality Layers Command.
Definition Task.h:319
LYR::run
void run(Session *session, const std::string &argument)
Main public function.
Logger
Logger class - handles ofstreams and syslog.
Definition Logger.h:79
MINMAX
MINMAX Command.
Definition Task.h:168
MINMAX::run
void run(Session *session, const std::string &argument)
Main public function.
OBJ
OBJ commands.
Definition Task.h:131
OBJ::run
void run(Session *session, const std::string &argument)
Main public function.
PFL
SPECTRA Request Command.
Definition Task.h:312
PFL::run
void run(Session *session, const std::string &argument)
Main public function.
QLT
JPEG Quality Command.
Definition Task.h:154
QLT::run
void run(Session *session, const std::string &argument)
Main public function.
RGN
CVT Region Command.
Definition Task.h:203
RGN::run
void run(Session *session, const std::string &argument)
Main public function.
ROT
ROT Rotation Command.
Definition Task.h:210
ROT::run
void run(Session *session, const std::string &argument)
Main public function.
SDS
SDS Command.
Definition Task.h:161
SDS::run
void run(Session *session, const std::string &argument)
Main public function.
SHD
Shading Command.
Definition Task.h:277
SHD::run
void run(Session *session, const std::string &argument)
Main public function.
SPECTRA
SPECTRA Request Command.
Definition Task.h:305
SPECTRA::run
void run(Session *session, const std::string &argument)
Main public function.
TIL
Tile Command.
Definition Task.h:252
TIL::run
void run(Session *session, const std::string &argument)
Main public function.
Task
Generic class to encapsulate various commands.
Definition Task.h:96
Task::argument
std::string argument
Argument supplied to the task.
Definition Task.h:107
Task::~Task
virtual ~Task()
Virtual destructor.
Definition Task.h:113
Task::session
Session * session
Pointer to our session data.
Definition Task.h:104
Task::command_timer
Timer command_timer
Timer for each task.
Definition Task.h:101
Task::checkImage
void checkImage()
Check image.
Task::run
virtual void run(Session *session, const std::string &argument)
Main public function.
Definition Task.h:116
Task::factory
static Task * factory(const std::string &type)
Factory function.
Timer
Simple Timer class to allow us to time our responses.
Definition Timer.h:39
View
Class to intelligently handle Image Transforms.
Definition View.h:36
WID
CVT Width Command.
Definition Task.h:189
WID::run
void run(Session *session, const std::string &argument)
Main public function.
Watermark
Watermark class.
Definition Watermark.h:41
Zoomify
Zoomify Request Command.
Definition Task.h:298
Zoomify::run
void run(Session *session, const std::string &argument)
Main public function.
Session
Structure to hold our session data.
Definition Task.h:66
Transform
Image Processing Transforms.
Definition Transforms.h:40