2006-12-24 06:25:21 +00:00
|
|
|
#ifndef _D_FIXED_NUMBER_RANDOMIZER_H_
|
|
|
|
#define _D_FIXED_NUMBER_RANDOMIZER_H_
|
|
|
|
|
|
|
|
#include "Randomizer.h"
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2006-12-24 06:25:21 +00:00
|
|
|
class FixedNumberRandomizer : public Randomizer {
|
|
|
|
private:
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t fixedNumber;
|
2006-12-24 06:25:21 +00:00
|
|
|
public:
|
|
|
|
FixedNumberRandomizer():fixedNumber(0) {}
|
|
|
|
|
|
|
|
virtual ~FixedNumberRandomizer() {}
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
virtual long int getRandomNumber() {
|
2006-12-24 06:25:21 +00:00
|
|
|
return fixedNumber;
|
|
|
|
}
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
virtual long int getMaxRandomNumber() {
|
2006-12-24 06:25:21 +00:00
|
|
|
return RAND_MAX;
|
|
|
|
}
|
|
|
|
|
2007-07-23 13:04:48 +00:00
|
|
|
virtual long int getRandomNumber(long int to)
|
|
|
|
{
|
|
|
|
return getRandomNumber();
|
|
|
|
}
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
void setFixedNumber(int32_t num) {
|
2006-12-24 06:25:21 +00:00
|
|
|
this->fixedNumber = num;
|
|
|
|
}
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t getFixedNumber() const {
|
2006-12-24 06:25:21 +00:00
|
|
|
return fixedNumber;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2006-12-24 06:25:21 +00:00
|
|
|
#endif // _D_FIXED_NUMBER_RANDOMIZER_H_
|