ESA JPIP server  0.1
request.h
Go to the documentation of this file.
1 #ifndef _JPIP_REQUEST_H_
2 #define _JPIP_REQUEST_H_
3 
4 
5 #include <vector>
6 #include <string>
7 #include <iostream>
8 #include "jpip/woi.h"
9 #include "jpip/cache_model.h"
10 #include "http/request.h"
11 #include "jpeg2000/point.h"
13 #include <string.h>
14 
15 
16 namespace jpip
17 {
18 
19  using namespace std;
20  using namespace jpeg2000;
21 
22 
31  class Request :public http::Request
32  {
33  public:
39  istream& ParseModel(istream& stream);
40 
47  istream& GetCodedChar(istream& in, char& c);
48 
53  virtual void ParseParameters(istream& stream);
54 
61  virtual void ParseParameter(istream& stream, const string& param, string& value);
62 
71  struct
72  {
73  int fsiz : 1;
74  int roff : 1;
75  int rsiz : 1;
76  int metareq : 1;
77  int len : 1;
78  int target : 1;
79  int cid : 1;
80  int cnew : 1;
81  int cclose : 1;
82  int model : 1;
83  int stream : 1;
84  int context : 1;
85  } items;
86 
90  int value;
91 
96  {
97  value = 0;
98  }
99 
105  bool HasWOI() const
106  {
107  return (value & 7);
108  }
109 
113  void Clear()
114  {
115  value = 0;
116  }
117  };
118 
126  CLOSEST
127  };
128 
137 
142 
143 
148  {
149  }
150 
157  void GetResolution(const CodingParameters::Ptr& coding_parameters, WOI *woi) const
158  {
159  Size res_image_size;
160 
161  if(round_direction == Request::CLOSEST)
162  woi->resolution = coding_parameters->GetClosestResolution(resolution_size, &res_image_size);
163 
164  else if(round_direction == Request::ROUNDUP)
165  woi->resolution = coding_parameters->GetRoundUpResolution(resolution_size, &res_image_size);
166 
167  else if(round_direction == Request::ROUNDDOWN)
168  woi->resolution = coding_parameters->GetRoundDownResolution(resolution_size, &res_image_size);
169 
170  if (resolution_size != res_image_size)
171  {
172  woi->position.x = ceil((woi->position.x * res_image_size.x) / resolution_size.x);
173  woi->position.y = ceil((woi->position.y * res_image_size.y) / resolution_size.y);
174  woi->size.x = ceil((woi->size.x * res_image_size.x) / resolution_size.x);
175  woi->size.y = ceil((woi->size.y * res_image_size.y) / resolution_size.y);
176  }
177  }
178 
179  virtual ~Request()
180  {
181  }
182  };
183 
184 }
185 
186 #endif /* _JPIP_REQUEST_H_ */
RoundDirection round_direction
Round direction.
Definition: request.h:141
virtual ~Request()
Definition: request.h:179
Class derived from the HTTP Request class that contains the required code for properly analyzing a JP...
Definition: request.h:31
Size woi_size
WOI size.
Definition: request.h:129
void GetResolution(const CodingParameters::Ptr &coding_parameters, WOI *woi) const
Obtains the resolution level and modifies the given WOI to adjust it according to that level...
Definition: request.h:157
SHARED_PTR< CodingParameters > Ptr
Pointer to an object of this class.
Definition: coding_parameters.h:97
The cache model of a JPIP client is handled using this class.
Definition: cache_model.h:38
Size resolution_size
Size of the resolution level.
Definition: request.h:135
Class that identifies a WOI (Window Of Interest).
Definition: woi.h:24
bool HasWOI() const
Returns true if the mask contains the parameters associated to the WOI (fsiz, roff and rsiz)...
Definition: request.h:105
Round-up.
Definition: request.h:124
RoundDirection
Enumeration of the possible round directions of a WOI for specifying the resolution levels...
Definition: request.h:123
STL namespace.
ParametersMask mask
Parameters mask.
Definition: request.h:134
Point woi_position
WOI position.
Definition: request.h:130
int length_response
Maximum response length.
Definition: request.h:133
int max_codestream
Maximum codestream.
Definition: request.h:132
Request()
Empty constructor.
Definition: request.h:147
Represents a couple of integer values that can be used to identify a coordinate as well as a size...
Definition: point.h:18
Size size
Size of the WOI (width and height)
Definition: woi.h:27
int y
Value Y.
Definition: point.h:22
CacheModel cache_model
Cache model.
Definition: request.h:136
Set of classes for handling (reading and indexing) image files with the format defined in the Part 1 ...
Definition: codestream_index.h:10
Closest.
Definition: request.h:126
Union used to control the presence of the different JPIP parameters in a request. ...
Definition: request.h:67
Round-down.
Definition: request.h:125
int x
Value X.
Definition: point.h:21
int resolution
Resolution level where the WOI is located (0 == the highest)
Definition: woi.h:29
int min_codestream
Minimum codestream.
Definition: request.h:131
Class used to identify a HTTP request (GET or POST).
Definition: request.h:27
Point position
Position of the upper-left corner of the WOI.
Definition: woi.h:28
ParametersMask()
Initializes the mask to zero.
Definition: request.h:95
Set of classes related to the JPIP protocol, defined in the Part 9 of the JPEG2000 standard...
Definition: cache_model.h:13
int value
Parameters mask as integer.
Definition: request.h:90
void Clear()
Sets the mask to zero.
Definition: request.h:113