Advertisement
zamotivator

Untitled

Aug 8th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. /*
  2. It should be used just for dense chunks.
  3. For iterate over materialized chunk (sparse algorithm) please use
  4. DelegateChunkIteator.
  5. */
  6. template< typename Walker,
  7. typename Reader >
  8. class DenseChunkIteratorTile :
  9. public ConstChunkIterator
  10. {
  11. private:
  12. typedef DenseChunkIteratorTile<Walker, Reader> User;
  13. typedef TileWriter Writer;
  14. typedef WalkerError<User> WE;
  15. typedef TileError<User> TE;
  16. friend class MessageBuilder;
  17. private:
  18. RepartChunk const& _repartChunk;
  19.  
  20. RepartArraySettings const& _sourceArray;
  21. RepartChunkSettings _sourceChunk;
  22.  
  23. RepartChunkSettings const _resultChunk;
  24.  
  25. Coordinates _source;
  26. position_t _sourceSkip;
  27. position_t _sourceLeft;
  28.  
  29. Coordinates _result;
  30. position_t _resultSkip;
  31. position_t _resultLeft;
  32.  
  33. Coordinates _sourceChunkPosition;
  34. bool _sourceChunkEmpty;
  35.  
  36. int const _mode;
  37. bool _has;
  38. bool _next;
  39.  
  40. Walker _walker;
  41. WE _walkerError;
  42. Reader _reader;
  43. TE _readerError;
  44. Writer _writer;
  45. TE _writerError;
  46.  
  47.  
  48. public:
  49. DenseChunkIteratorTile(RepartChunk const& chunk,
  50. boost::shared_ptr<ConstArrayIterator> data,
  51. const int mode) :
  52. _repartChunk(chunk),
  53. _sourceArray(_repartChunk.source),
  54. _sourceChunk(_sourceArray, _repartChunk.sourceOverlap),
  55. _resultChunk(_repartChunk.result,
  56. !(mode & ConstChunkIterator::IGNORE_OVERLAPS),
  57. _repartChunk),
  58. _source(_sourceArray.n),
  59. _result(_resultChunk.n),
  60. _mode(_resultChunk.mode(mode)),
  61. _has(false),
  62. _next(false),
  63. _walker(&_walkerError, data, _sourceChunk.mode(mode)),
  64. _walkerError(*this),
  65. _reader(&_readerError),
  66. _readerError(*this, _reader),
  67. _writer(&_writerError),
  68. _writerError(*this, _writer)
  69. {
  70. _reset();
  71. }
  72.  
  73. DenseChunkIteratorTile(RepartChunk const& chunk,
  74. boost::shared_ptr<ConstArrayIterator> bitmap,
  75. boost::shared_ptr<ConstArrayIterator> data,
  76. TypeId const& dataType,
  77. const int mode) :
  78. _repartChunk(chunk),
  79. _sourceArray(_repartChunk.source),
  80. _sourceChunk(_sourceArray, _repartChunk.sourceOverlap),
  81. _resultChunk(_repartChunk.result,
  82. !(mode & ConstChunkIterator::IGNORE_OVERLAPS),
  83. _repartChunk),
  84. _source(_sourceArray.n),
  85. _result(_resultChunk.n),
  86. _mode(_resultChunk.mode(mode)),
  87. _has(false),
  88. _next(false),
  89. _walker(&_walkerError, bitmap, data, _sourceChunk.mode(mode)),
  90. _walkerError(*this),
  91. _reader(&_readerError, dataType),
  92. _readerError(*this, _reader),
  93. _writer(&_writerError, dataType),
  94. _writerError(*this, _writer)
  95. {
  96. _reset();
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement