@@ -197,16 +197,16 @@ GalleySetBase::extract_internal(std::shared_ptr<Blob> blob)
197
197
int variated_count = 0 ;
198
198
199
199
/* Loop throight stamps calculating total sizes and seeing what kind of stamps do we have*/
200
- for (StampBase & s : stamps)
200
+ for (std::shared_ptr< StampBase> s : stamps)
201
201
{
202
- fixed_total_size += s. minSize ();
203
- if (s. isVariated ())
202
+ fixed_total_size += s-> minSize ();
203
+ if (s-> isVariated ())
204
204
{
205
- max_varited_total_size += s. maxSize () - s. minSize ();
205
+ max_varited_total_size += s-> maxSize () - s-> minSize ();
206
206
has_variated_stamps = true ;
207
207
variated_count++;
208
208
}
209
- if (s. isUnbounded ())
209
+ if (s-> isUnbounded ())
210
210
{
211
211
has_unbounded_stamps = true ;
212
212
unbounded_count++;
@@ -254,26 +254,26 @@ GalleySetBase::extract_internal(std::shared_ptr<Blob> blob)
254
254
double total_unbounded_modifiers = 0 ;
255
255
256
256
std::vector<double > size_modifiers;
257
- for (StampBase & s : stamps)
257
+ for (std::shared_ptr< StampBase> s : stamps)
258
258
{
259
259
ORACLE_TYPE o_value = 0 ;
260
260
double modifier = 0 ;
261
- if (!s. isFixedSize ())
261
+ if (!s-> isFixedSize ())
262
262
{
263
- if (s. isUnbounded () && unbounded_count <=1 )
263
+ if (s-> isUnbounded () && unbounded_count <=1 )
264
264
{
265
265
modifier = 1 ; // Nothing to predict, it will use all space
266
266
} else
267
267
{
268
268
o_value = oracle_stamp.ExtractValue (blob);
269
269
modifier = (double ) o_value / (double ) ORACLE_MAX;
270
270
}
271
- if (s. isUnbounded ())
271
+ if (s-> isUnbounded ())
272
272
{
273
273
total_unbounded_modifiers += modifier;
274
274
} else
275
275
{
276
- predicted_variated_total_size += (s. maxSize () - s. minSize ()) * modifier;
276
+ predicted_variated_total_size += (s-> maxSize () - s-> minSize ()) * modifier;
277
277
}
278
278
}
279
279
size_modifiers.push_back (modifier);
@@ -283,8 +283,8 @@ GalleySetBase::extract_internal(std::shared_ptr<Blob> blob)
283
283
total_unbounded_modifiers = 0 ;
284
284
for (int i=0 ; i<stamps.size ();i++)
285
285
{
286
- StampBase & s = stamps[i];
287
- if (s. isUnbounded ())
286
+ std::shared_ptr< StampBase> s = stamps[i];
287
+ if (s-> isUnbounded ())
288
288
{
289
289
size_modifiers[i] = 1 ;
290
290
total_unbounded_modifiers += 1 ;
@@ -321,26 +321,26 @@ GalleySetBase::extract_internal(std::shared_ptr<Blob> blob)
321
321
/* chopping this sizes out of the blob and saving them a result vector*/
322
322
for (int i=0 ; i<stamps.size ();i++)
323
323
{
324
- StampBase & s = stamps[i];
324
+ std::shared_ptr< StampBase> s = stamps[i];
325
325
double modifier = size_modifiers[i];
326
326
int el_size;
327
- if (s. isFixedSize ())
327
+ if (s-> isFixedSize ())
328
328
{
329
- el_size = s. minSize ();
329
+ el_size = s-> minSize ();
330
330
}
331
- if (s. isVariated ())
331
+ if (s-> isVariated ())
332
332
{
333
- double len = (s. maxSize () - s. minSize ()) * modifier * k_variated + variated_remainder;
333
+ double len = (s-> maxSize () - s-> minSize ()) * modifier * k_variated + variated_remainder;
334
334
el_size = round (len);
335
335
variated_remainder = len - el_size;
336
- el_size += s. minSize ();
336
+ el_size += s-> minSize ();
337
337
}
338
- if (s. isUnbounded ())
338
+ if (s-> isUnbounded ())
339
339
{
340
340
double len = modifier * k_unbounded + unbounded_remainder;
341
341
el_size = round (len);
342
342
unbounded_remainder = len - el_size;
343
- el_size +=s. minSize ();
343
+ el_size +=s-> minSize ();
344
344
}
345
345
std::shared_ptr<Blob> blob2 = blob->Chop (el_size);
346
346
res.push_back (blob2);
@@ -355,8 +355,8 @@ GalleySetBase::LoadAll(std::shared_ptr<Blob> blob)
355
355
for (int i=0 ; i<blobs.size (); i++)
356
356
{
357
357
std::shared_ptr<Blob> blob = blobs[i];
358
- StampBase & stamp = stamps[i];
359
- stamp. Load (blob);
358
+ std::shared_ptr< StampBase> s = stamps[i];
359
+ s-> Load (blob);
360
360
}
361
361
}
362
362
@@ -369,8 +369,8 @@ GalleySetStr::ExtractStrSet(std::shared_ptr<Blob> blob)
369
369
for (int i=0 ; i<blobs.size (); i++)
370
370
{
371
371
std::shared_ptr<Blob> blob = blobs[i];
372
- StampBaseStr & stamp = s_stamps [i];
373
- std::string str = stamp. ExtractStr (blob);
372
+ auto stamp = std::dynamic_pointer_cast<StampBaseStr>(stamps [i]) ;
373
+ std::string str = stamp-> ExtractStr (blob);
374
374
res.push_back (str);
375
375
}
376
376
return res;
@@ -384,8 +384,8 @@ GalleySetBin::ExtractBinSet(std::shared_ptr<Blob> blob)
384
384
for (int i=0 ; i<blobs.size (); i++)
385
385
{
386
386
std::shared_ptr<Blob> blob = blobs[i];
387
- StampBaseBin & stamp = b_stamps [i];
388
- std::vector<char > v = stamp. ExtractBin (blob);
387
+ auto stamp = std::dynamic_pointer_cast<StampBaseBin>(stamps [i]) ;
388
+ std::vector<char > v = stamp-> ExtractBin (blob);
389
389
res.push_back (v);
390
390
}
391
391
return res;
@@ -403,15 +403,15 @@ GalleySetBase::minSize()
403
403
int res = 0 ;
404
404
405
405
/* Loop throight stamps calculating total sizes and seeing what kind of stamps do we have*/
406
- for (StampBase & s : stamps)
406
+ for (std::shared_ptr< StampBase> s : stamps)
407
407
{
408
- res += s. minSize ();
409
- if (s. isVariated ())
408
+ res += s-> minSize ();
409
+ if (s-> isVariated ())
410
410
{
411
411
has_variated_stamps = true ;
412
412
variated_count++;
413
413
}
414
- if (s. isUnbounded ())
414
+ if (s-> isUnbounded ())
415
415
{
416
416
has_unbounded_stamps = true ;
417
417
unbounded_count++;
@@ -434,14 +434,14 @@ GalleySetBase::maxSize()
434
434
int res = 0 ;
435
435
436
436
/* Loop throight stamps calculating total sizes and seeing what kind of stamps do we have*/
437
- for (StampBase & s : stamps)
437
+ for (std::shared_ptr< StampBase> s : stamps)
438
438
{
439
- res += s. maxSize ();
440
- if (s. isVariated ())
439
+ res += s-> maxSize ();
440
+ if (s-> isVariated ())
441
441
{
442
442
res += ORACLE_SIZE; // Each variated stamp needs an oracle to predict it's size. It also affects max size
443
443
}
444
- if (s. isUnbounded ())
444
+ if (s-> isUnbounded ())
445
445
{
446
446
return -1 ; // Junst one unbounded stamp makes all thing unbounded
447
447
}
0 commit comments