Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BitmapTileReplicator : boost::noncopyable
- {
- private:
- RLEPayload::iterator _source;
- RLEPayload::append_iterator _result;
- position_t _current;
- position_t _left;
- Value _trueValue;
- Value _falseValue;
- void fill(position_t count, bool data)
- {
- if (data) {
- _result.add(_trueValue, static_cast<uint64_t>(count));
- } else {
- _result.add(_falseValue, static_cast<uint64_t>(count));
- }
- }
- public:
- BitmapTileReplicator(ConstRLEPayload const* sourceTile,
- position_t sourceStartPosition,
- position_t sourceExpectedSize,
- Value& result) :
- _source(sourceTile),
- _result(result.getTile(TID_BOOL)),
- _current(sourceStartPosition),
- _left(sourceExpectedSize)
- {
- if (sourceTile->count() !=
- static_cast<size_t>(sourceExpectedSize)) {
- std::ostringstream message;
- message << "BitmapTileReplicator::ctor expected size is " <<
- sourceExpectedSize <<
- " actual size is " <<
- sourceTile->count();
- throw USER_EXCEPTION(
- SCIDB_SE_EXECUTION,
- SCIDB_LE_OPERATION_FAILED) << message.str();
- }
- _trueValue.setBool(true);
- _falseValue.setBool(false);
- }
- virtual ~BitmapTileReplicator()
- {
- _result.flush();
- }
- position_t position() const
- {
- return _current;
- }
- position_t length() const
- {
- return _left;
- }
- void skip(position_t count)
- {
- if (_left < count) {
- std::ostringstream message;
- message << "BitmapTileReplicator::skip reqiested " <<
- count <<
- " available " <<
- _left;
- throw USER_EXCEPTION(
- SCIDB_SE_EXECUTION,
- SCIDB_LE_OPERATION_FAILED) << message.str();
- }
- _source += count;
- fill(count, false);
- _current += count;
- _left -= count;
- }
- void copy(position_t count)
- {
- if (_left < count) {
- std::ostringstream message;
- message << "BitmapTileReplicator::copy reqiested " <<
- count <<
- " available " <<
- _left;
- throw USER_EXCEPTION(
- SCIDB_SE_EXECUTION,
- SCIDB_LE_OPERATION_FAILED) << message.str();
- }
- while(count > 0) {
- SCIDB_ASSERT(!_source.end());
- uint64_t current = min(_source.getRepeatCount(),
- static_cast<uint64_t>(count));
- SCIDB_ASSERT(current > 0);
- fill(current, _source.checkBit());
- _source += current;
- _current += current;
- _left -= current;
- count -= current;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement