ESA JPIP server  0.1
file_manager.h
Go to the documentation of this file.
1 #ifndef _JPEG2000_FILE_MANAGER_H_
2 #define _JPEG2000_FILE_MANAGER_H_
3 
4 
5 #include <sys/stat.h>
6 #include "data/serialize.h"
7 #include "image_info.h"
8 
9 
10 namespace jpeg2000
11 {
12 
18  {
19  private:
20  string root_dir_;
21  string cache_dir_;
22 
28  bool ExistCacheImage(const string& path_image_file, string *path_cache_file);
29 
37  bool ReadBoxHeader(const File &fim, uint32_t *type_box, uint64_t *length_box);
38 
46  bool ReadCodestream(const File& file, CodingParameters *params, CodestreamIndex *index);
47 
54  bool ReadSIZMarker(const File& file, CodingParameters *params);
55 
62  bool ReadCODMarker(const File& file, CodingParameters *params);
63 
70  bool ReadSOTMarker(const File& file, CodestreamIndex *index);
71 
78  bool ReadPLTMarker(const File& file, CodestreamIndex *index);
79 
86  bool ReadSODMarker(const File& file, CodestreamIndex *index);
87 
94  bool ReadJP2(const File& file, ImageInfo *image_info);
95 
102  bool ReadJPX(const File& file, ImageInfo *image_info);
103 
111  bool ReadNlstBox(const File& file, int *num_codestream, int length_box);
112 
120  bool ReadFlstBox(const File& file, uint64_t length_box, uint16_t *data_reference);
121 
129  bool ReadUrlBox(const File& file, uint64_t length_box, string *path_file);
130 
131  public:
136  string GetCacheFileName(const string& path_image_file);
137 
142  {
143  root_dir_ = "./";
144  cache_dir_ = "./";
145  }
146 
153  {
154  assert(Init(root_dir, cache_dir));
155  }
156 
163  bool Init(string root_dir = "./", string cache_dir = "./")
164  {
165  if((root_dir.size() == 0) || (cache_dir.size() == 0)) return false;
166  else {
167  root_dir_ = root_dir;
168  cache_dir_ = cache_dir;
169 
170  if(root_dir_.at(root_dir_.size() - 1) != '/')
171  root_dir_ += '/';
172 
173  if(cache_dir_.at(cache_dir_.size() - 1) != '/')
174  cache_dir_ += '/';
175 
176  return true;
177  }
178  }
179 
183  string root_dir() const
184  {
185  return root_dir_;
186  }
187 
191  string cache_dir() const
192  {
193  return cache_dir_;
194  }
195 
203  bool ReadImage(const string& name_image_file, ImageInfo *image_info);
204 
205 
206  virtual ~FileManager()
207  {
208  }
209 
210 
211  };
212 }
213 
214 #endif /* _JPEG2000_FILE_MANAGER_H_ */
215 
FileManager(string root_dir, string cache_dir)
Initializes the object.
Definition: file_manager.h:152
bool ReadImage(const string &name_image_file, ImageInfo *image_info)
Reads an image file and creates the associated cache file if it does not exist yet.
Definition: file_manager.cc:77
bool ReadUrlBox(const File &file, uint64_t length_box, string *path_file)
Reads the information of a URL box.
Definition: file_manager.cc:529
string root_dir() const
Returns the root directory of the image repository.
Definition: file_manager.h:183
bool ReadPLTMarker(const File &file, CodestreamIndex *index)
Reads the information of a PLT marker.
Definition: file_manager.cc:297
bool ReadNlstBox(const File &file, int *num_codestream, int length_box)
Reads the information of a NLST box.
Definition: file_manager.cc:502
Contains the indexing information of a JPEG2000 image.
Definition: image_info.h:24
bool ReadFlstBox(const File &file, uint64_t length_box, uint16_t *data_reference)
Reads the information of a FLST box.
Definition: file_manager.cc:519
Contains the coding parameters of a JPEG2000 image codestream.
Definition: coding_parameters.h:23
string cache_dir() const
Returns the directory used for caching.
Definition: file_manager.h:191
bool ReadSOTMarker(const File &file, CodestreamIndex *index)
Reads the information of a SOT marker.
Definition: file_manager.cc:284
bool Init(string root_dir="./", string cache_dir="./")
Initializes the object.
Definition: file_manager.h:163
string GetCacheFileName(const string &path_image_file)
Returns the cache file name equivalent to the given image file name.
Definition: file_manager.cc:31
bool ExistCacheImage(const string &path_image_file, string *path_cache_file)
Returns true if the cache file exists and it is updated.
Definition: file_manager.cc:55
Set of classes for handling (reading and indexing) image files with the format defined in the Part 1 ...
Definition: codestream_index.h:10
string cache_dir_
Caching directory.
Definition: file_manager.h:21
bool ReadCodestream(const File &file, CodingParameters *params, CodestreamIndex *index)
Reads the information of a codestream.
Definition: file_manager.cc:149
bool ReadJP2(const File &file, ImageInfo *image_info)
Reads the information of a JP2 image file.
Definition: file_manager.cc:348
bool ReadSIZMarker(const File &file, CodingParameters *params)
Reads the information of a SIZ marker.
Definition: file_manager.cc:215
FileManager()
Initializes the object.
Definition: file_manager.h:141
bool ReadJPX(const File &file, ImageInfo *image_info)
Reads the information of a JPX image file.
Definition: file_manager.cc:393
bool ReadCODMarker(const File &file, CodingParameters *params)
Reads the information of a COD marker.
Definition: file_manager.cc:241
bool ReadSODMarker(const File &file, CodestreamIndex *index)
Reads the information of a SOD marker.
Definition: file_manager.cc:311
Manages the image files of a repository, allowing read their indexing information, with a caching mechanism for efficiency.
Definition: file_manager.h:17
bool ReadBoxHeader(const File &fim, uint32_t *type_box, uint64_t *length_box)
Reads the header information.
Definition: file_manager.cc:322
Class used for indexing the information of a JPEG2000 codestream.
Definition: codestream_index.h:25
virtual ~FileManager()
Definition: file_manager.h:206
string root_dir_
Root directory of the repository.
Definition: file_manager.h:20