[r81]: iipsrv / trunk / src / Environment.h Maximize Restore History

Download this file

Environment.h    183 lines (135 with data), 4.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
IIP Environment Variable Class
Copyright (C) 2006-2009 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 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _ENVIRONMENT_H
#define _ENVIRONMENT_H
/* Define some default values
*/
#define VERBOSITY 1
#define LOGFILE "/tmp/iipsrv.log"
#define MAX_IMAGE_CACHE_SIZE 10.0
#define FILENAME_PATTERN "_pyr_"
#define JPEG_QUALITY 75
#define MAX_CVT 5000
#define MAX_LAYERS 0
#define FILESYSTEM_PREFIX ""
#define WATERMARK ""
#define WATERMARK_PROBABILITY 1.0
#define WATERMARK_OPACITY 1.0
#include <string>
/// Class to obtain environment variables
class Environment {
public:
static int getVerbosity(){
int loglevel = VERBOSITY;
char *envpara = getenv( "VERBOSITY" );
if( envpara ){
loglevel = atoi( envpara );
// If not a realistic level, set to zero
if( loglevel < 0 ) loglevel = 0;
}
return loglevel;
}
static std::string getLogFile(){
char* envpara = getenv( "LOGFILE" );
if( envpara ) return std::string( envpara );
else return LOGFILE;
}
static float getMaxImageCacheSize(){
float max_image_cache_size = MAX_IMAGE_CACHE_SIZE;
char* envpara = getenv( "MAX_IMAGE_CACHE_SIZE" );
if( envpara ){
max_image_cache_size = atof( envpara );
}
return max_image_cache_size;
}
static std::string getFileNamePattern(){
char* envpara = getenv( "FILENAME_PATTERN" );
std::string filename_pattern;
if( envpara ){
filename_pattern = std::string( envpara );
}
else filename_pattern = FILENAME_PATTERN;
return filename_pattern;
}
static int getJPEGQuality(){
char* envpara = getenv( "JPEG_QUALITY" );
int jpeg_quality;
if( envpara ){
jpeg_quality = atoi( envpara );
if( jpeg_quality > 100 ) jpeg_quality = 100;
if( jpeg_quality < 1 ) jpeg_quality = 1;
}
else jpeg_quality = JPEG_QUALITY;
return jpeg_quality;
}
static int getMaxCVT(){
char* envpara = getenv( "MAX_CVT" );
int max_CVT;
if( envpara ){
max_CVT = atoi( envpara );
if( max_CVT < 64 ) max_CVT = 64;
if( max_CVT == -1 ) max_CVT = -1;
}
else max_CVT = MAX_CVT;
return max_CVT;
}
static int getMaxLayers(){
char* envpara = getenv( "MAX_LAYERS" );
int layers;
if( envpara ) layers = atoi( envpara );
else layers = MAX_LAYERS;
return layers;
}
static std::string getFileSystemPrefix(){
char* envpara = getenv( "FILESYSTEM_PREFIX" );
std::string filesystem_prefix;
if( envpara ){
filesystem_prefix = std::string( envpara );
}
else filesystem_prefix = FILESYSTEM_PREFIX;
return filesystem_prefix;
}
static std::string getWatermark(){
char* envpara = getenv( "WATERMARK" );
std::string watermark;
if( envpara ){
watermark = std::string( envpara );
}
else watermark = WATERMARK;
return watermark;
}
static float getWatermarkProbability(){
float watermark_probability = WATERMARK_PROBABILITY;
char* envpara = getenv( "WATERMARK_PROBABILITY" );
if( envpara ){
watermark_probability = atof( envpara );
if( watermark_probability > 1.0 ) watermark_probability = 1.0;
if( watermark_probability < 0 ) watermark_probability = 0.0;
}
return watermark_probability;
}
static float getWatermarkOpacity(){
float watermark_opacity = WATERMARK_OPACITY;
char* envpara = getenv( "WATERMARK_OPACITY" );
if( envpara ){
watermark_opacity = atof( envpara );
if( watermark_opacity > 1.0 ) watermark_opacity = 1.0;
if( watermark_opacity < 0 ) watermark_opacity = 0.0;
}
return watermark_opacity;
}
};
#endif