1 #ifndef _JPIP_CACHE_MODEL_H_
2 #define _JPIP_CACHE_MODEL_H_
99 AddToMainHeader(model.
header);
102 for(
int i = 0; i < (int)model.
precincts.size(); i++)
110 return (stream & header & tile_header & min_precinct & precincts);
138 if (header != INT_MAX)
140 if (complete || (amount == INT_MAX)) header = INT_MAX;
141 else header += amount;
156 if (tile_header != INT_MAX)
158 if (complete || (amount == INT_MAX)) tile_header = INT_MAX;
159 else tile_header += amount;
171 if (num_precinct < min_precinct)
return INT_MAX;
174 int n = num_precinct - min_precinct;
176 if (n >= (
int) precincts.size()) precincts.resize(n + 1, 0);
192 if (num_precinct < min_precinct)
return INT_MAX;
195 int n = num_precinct - min_precinct;
197 if (n >= (
int) precincts.size()) precincts.resize(n + 1, 0);
199 int& p = precincts[n];
203 if (complete || (amount == INT_MAX)) p = INT_MAX;
223 for (
int i = 0; i < (int) precincts.size(); i++)
225 if (precincts[i] == INT_MAX) sum++;
231 precincts.erase(precincts.begin(), precincts.begin() + sum);
288 for(
int i = 0; i < (int)model.
meta_data.size(); i++)
292 for(
int i = 0; i < (int)model.
codestreams.size(); i++)
300 return (stream & full_meta & meta_data & codestreams);
309 if (num_codestream >= (
int) codestreams.size()) codestreams.resize(num_codestream + 1);
311 return codestreams[num_codestream];
320 if(full_meta)
return INT_MAX;
322 if(
id >= (
int)meta_data.size()) meta_data.resize(
id + 1, 0);
323 return meta_data[id];
337 if(full_meta)
return INT_MAX;
339 if (GetMetadata(
id) != INT_MAX)
341 if (complete || (amount == INT_MAX)) meta_data[id] = INT_MAX;
342 else meta_data[id] += amount;
345 return meta_data[id];
355 template<
int BIN_CLASS>
int GetDataBin(
int num_codestream,
int id)
370 template<
int BIN_CLASS>
int AddToDataBin(
int num_codestream,
int id,
int amount,
bool complete =
false)
397 for (vector<Codestream>::iterator i = codestreams.begin(); i != codestreams.end(); i++)
423 static int AddTo(
CacheModel& model,
int num_codestream,
int id,
int amount,
bool complete)
436 static int AddTo(
CacheModel& model,
int num_codestream,
int id,
int amount,
bool complete)
449 static int AddTo(
CacheModel& model,
int num_codestream,
int id,
int amount,
bool complete)
462 static int AddTo(
CacheModel& model,
int num_codestream,
int id,
int amount,
bool complete)
static void copy(std::vector< T > &dest, const std::vector< T > &src)
Copies a vector.
Definition: base.h:30
static int AddTo(CacheModel &model, int num_codestream, int id, int amount, bool complete)
Definition: cache_model.h:462
vector< Codestream > codestreams
Amounts for the codestreams.
Definition: cache_model.h:251
static int Get(CacheModel &model, int num_codestream, int id)
Definition: cache_model.h:431
The cache model of a JPIP client is handled using this class.
Definition: cache_model.h:38
Contains a set of classes to easy the handling of data and files, as well as the serialization.
Definition: data.h:9
vector< int > meta_data
Amounts for the meta-datas.
Definition: cache_model.h:246
static int Get(CacheModel &model, int num_codestream, int id)
Definition: cache_model.h:457
Codestream & operator+=(const Codestream &model)
Add the content of the given codestream cache model.
Definition: cache_model.h:97
Codestream(const Codestream &model)
Copy constructor.
Definition: cache_model.h:76
Codestream()
Initializes all the members to zero.
Definition: cache_model.h:66
bool full_meta
Says if the meta-data has been totally sent.
Definition: cache_model.h:241
CacheModel(const CacheModel &model)
Copy constructor.
Definition: cache_model.h:265
T & SerializeWith(T &stream)
Definition: cache_model.h:298
int GetTileHeader() const
Returns the amount of the tile header.
Definition: cache_model.h:124
int header
Amount for the header.
Definition: cache_model.h:48
void Clear()
Clear all the amounts.
Definition: cache_model.h:404
static int AddTo(CacheModel &model, int num_codestream, int id, int amount, bool complete)
Definition: cache_model.h:436
int AddToMainHeader(int amount, bool complete=false)
Increases the amount of the main header.
Definition: cache_model.h:136
int AddToPrecinct(int num_precinct, int amount, bool complete=false)
Increases the amount of a precinct.
Definition: cache_model.h:190
CacheModel & operator+=(const CacheModel &model)
Add the content of the given cache model.
Definition: cache_model.h:285
int GetDataBin(int num_codestream, int id)
Returns the amount of a data-bin item using the class DataBinSelector.
Definition: cache_model.h:355
Codestream & operator=(const Codestream &model)
Copy assignment.
Definition: cache_model.h:84
virtual ~CacheModel()
Definition: cache_model.h:411
void Pack(int min_sum=1)
Packs the information stored regarding the precincts, removing those initial elements that are consec...
Definition: cache_model.h:219
bool IsFullMetadata() const
Returns the full flag of the meta-datas.
Definition: cache_model.h:378
Template class that is specialized for allowing basic operations (add and get) with cache models depe...
Definition: cache_model.h:24
void Pack(int min_sum=1)
Calls the Pack method of all the codestreams.
Definition: cache_model.h:395
int tile_header
Amount for the tile-header.
Definition: cache_model.h:49
T & SerializeWith(T &stream)
Definition: cache_model.h:108
void SetFullMetadata()
Sets the full flag for the meta-datas to true.
Definition: cache_model.h:386
vector< int > precincts
Amount for the precincts.
Definition: cache_model.h:50
CacheModel()
Empty constructor.
Definition: cache_model.h:257
int GetMetadata(int id)
Returns the amount of a meta-data.
Definition: cache_model.h:318
Class that contains the definitions of all the data-bin classes defined for the JPIP protocol...
Definition: jpip.h:18
int min_precinct
Minimum identifier of the non-consecutive precinct completely sent.
Definition: cache_model.h:60
int AddToDataBin(int num_codestream, int id, int amount, bool complete=false)
Increases the amount of a data-bin item using the class DataBinSelector.
Definition: cache_model.h:370
int AddToMetadata(int id, int amount, bool complete=false)
Increases the amount of a meta-data.
Definition: cache_model.h:335
int GetMainHeader() const
Returns the amount of the main header.
Definition: cache_model.h:116
Codestream & GetCodestream(int num_codestream)
Returns the reference of a codestream.
Definition: cache_model.h:307
Sub-class of the cache model class used to identify a codestream.
Definition: cache_model.h:45
Set of classes related to the JPIP protocol, defined in the Part 9 of the JPEG2000 standard...
Definition: cache_model.h:13
CacheModel & operator=(const CacheModel &model)
Copy assignment.
Definition: cache_model.h:273
int GetPrecinct(int num_precinct)
Returns the amount of a precinct.
Definition: cache_model.h:169
int AddToTileHeader(int amount, bool complete=false)
Increases the amount of the tile header.
Definition: cache_model.h:154