1 #include "pipe_paging.h" 2 3 PipePaging::PipePaging(offset_t size) 4 : _size(size) 5 { 6 } 7 8 /* Add a region to the sequence. */ 9 10 void PipePaging::add_region(PageMapper *mapper) 11 { 12 _regions.push_back(mapper); 13 } 14 15 /* Return the first region in the sequence. */ 16 17 PageMapper *PipePaging::first_region() 18 { 19 return _regions.front(); 20 } 21 22 /* Return the next region for the reader. If only a single region remains, with 23 the reader wishing to move to the next, return NULL. */ 24 25 PageMapper *PipePaging::next_region() 26 { 27 if (_regions.size() > 1) 28 { 29 /* Discard the accessor from the current region. */ 30 31 if (_accessors.size() > _regions.size()) 32 _accessors.pop_front(); 33 34 _regions.pop_front(); 35 return _regions.front(); 36 } 37 else 38 return NULL; 39 } 40 41 /* Initialise an accessor for a region. */ 42 43 PipeAccessor *PipePaging::accessor() 44 { 45 PipeAccessor accessor; 46 47 _accessors.push_back(accessor); 48 return &_accessors.back(); 49 } 50 51 // vim: tabstop=4 expandtab shiftwidth=4