1
#ifndef _JPEG2000_FILE_MANAGER_H_
2
#define _JPEG2000_FILE_MANAGER_H_
6
#include "data/serialize.h"
7
#include "image_info.h"
14
* Manages the image files of a repository, allowing read their
15
* indexing information, with a caching mechanism for efficiency.
20
string root_dir_; ///< Root directory of the repository
21
string cache_dir_; ///< Caching directory
24
* Returns <code>true</code> if the cache file exists and it is updated.
25
* @param path_image_file Path of the image file.
26
* @param path_cache_file Receives the path of the associated cache file.
28
bool ExistCacheImage(const string& path_image_file, string *path_cache_file);
31
* Reads the header information. of a JP2/JPX box.
32
* @param fim Image file.
33
* @param type_box Receives the type of the box.
34
* @param length_box Receives the length of the box.
35
* @return <code>true</code> if successful.
37
bool ReadBoxHeader(const File &fim, uint32_t *type_box, uint64_t *length_box);
40
* Reads the information of a codestream.
41
* @param file Image file.
42
* @param params Receives the coding parameters.
43
* @param index Receives the indexing information.
44
* @return <code>true</code> if successful.
46
bool ReadCodestream(const File& file, CodingParameters *params, CodestreamIndex *index);
49
* Reads the information of a SIZ marker.
50
* @param file Image file.
51
* @param params Pointer to the coding parameters to update.
52
* @return <code>true</code> if successful.
54
bool ReadSIZMarker(const File& file, CodingParameters *params);
57
* Reads the information of a COD marker.
58
* @param file Image file.
59
* @param params Pointer to the coding parameters to update.
60
* @return <code>true</code> if successful.
62
bool ReadCODMarker(const File& file, CodingParameters *params);
65
* Reads the information of a SOT marker.
66
* @param file Image file.
67
* @param index Pointer to the indexing information to update.
68
* @return <code>true</code> if successful.
70
bool ReadSOTMarker(const File& file, CodestreamIndex *index);
73
* Reads the information of a PLT marker.
74
* @param file Image file.
75
* @param index Pointer to the indexing information to update.
76
* @return <code>true</code> if successful.
78
bool ReadPLTMarker(const File& file, CodestreamIndex *index);
81
* Reads the information of a SOD marker.
82
* @param file Image file.
83
* @param index Pointer to the indexing information to update.
84
* @return <code>true</code> if successful.
86
bool ReadSODMarker(const File& file, CodestreamIndex *index);
89
* Reads the information of a JP2 image file.
90
* @param file Image file.
91
* @param image_info Receives the image information.
92
* @return <code>true</code> if successful.
94
bool ReadJP2(const File& file, ImageInfo *image_info);
97
* Reads the information of a JPX image file.
98
* @param file Image file.
99
* @param image_info Receives the image information.
100
* @return <code>true</code> if successful.
102
bool ReadJPX(const File& file, ImageInfo *image_info);
105
* Reads the information of a NLST box.
106
* @param file Image file.
107
* @param num_codestream Receives the number of codestream read.
108
* @param length_box Box length in bytes.
109
* @return <code>true</code> if successful.
111
bool ReadNlstBox(const File& file, int *num_codestream, int length_box);
114
* Reads the information of a FLST box.
115
* @param file Image file.
116
* @param length_box Box length in bytes.
117
* @param data_reference Receives the data reference.
118
* @return <code>true</code> if successful.
120
bool ReadFlstBox(const File& file, uint64_t length_box, uint16_t *data_reference);
123
* Reads the information of a URL box.
124
* @param file Image file.
125
* @param length_box Box length in bytes.
126
* @param path_file Receives the URL path read.
127
* @return <code>true</code> if successful.
129
bool ReadUrlBox(const File& file, uint64_t length_box, string *path_file);
133
* Returns the cache file name equivalent to the given
136
string GetCacheFileName(const string& path_image_file);
139
* Initializes the object.
148
* Initializes the object.
149
* @param root_dir Root directory of the image repository.
150
* @param cache_dir Directory for caching.
152
FileManager(string root_dir, string cache_dir)
154
assert(Init(root_dir, cache_dir));
158
* Initializes the object.
159
* @param root_dir Root directory of the image repository.
160
* @param cache_dir Directory for caching.
161
* @return <code>true</code> if successful
163
bool Init(string root_dir = "./", string cache_dir = "./")
165
if((root_dir.size() <= 0) || (cache_dir.size() < 0)) return false;
167
root_dir_ = root_dir;
168
cache_dir_ = cache_dir;
170
if(root_dir_.at(root_dir_.size() - 1) != '/')
173
if(cache_dir_.at(cache_dir_.size() - 1) != '/')
181
* Returns the root directory of the image repository.
183
string root_dir() const
189
* Returns the directory used for caching.
191
string cache_dir() const
197
* Reads an image file and creates the associated cache file if
198
* it does not exist yet.
199
* @param name_image_file File name of the image.
200
* @param image_info Receives the information of the image.
201
* @return <code>true</code> if successful.
203
bool ReadImage(const string& name_image_file, ImageInfo *image_info);
206
virtual ~FileManager()
214
#endif /* _JPEG2000_FILE_MANAGER_H_ */