1 /* 2 * Generic accessor functionality. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "accessor.h" 23 24 #include <string.h> 25 26 27 28 Accessor::Accessor(fileid_t fileid) 29 : fileid(fileid) 30 { 31 } 32 33 Accessor::~Accessor() 34 { 35 } 36 37 /* Perform any closing operation on the file. */ 38 39 void Accessor::close() 40 { 41 } 42 43 /* Perform any opening operation on the file. */ 44 45 void Accessor::open() 46 { 47 } 48 49 /* Data transfer methods. */ 50 51 void Accessor::fill(Flexpage *flexpage) 52 { 53 /* Filling completely beyond the end of file should produce an empty 54 flexpage. This could potentially be a shared read-only flexpage that 55 would be replaced by an independent writable flexpage if ever written. */ 56 57 if (flexpage->base_offset < get_size()) 58 fill_populated(flexpage); 59 else 60 memset((void *) flexpage->base_addr, 0, flexpage->size); 61 } 62 63 void Accessor::flush(Flexpage *flexpage) 64 { 65 /* Flushing completely beyond the end of file should discard the 66 flexpage. */ 67 68 if (flexpage->base_offset < get_size()) 69 flush_populated(flexpage); 70 } 71 72 /* Data transfer helper methods. */ 73 74 void Accessor::fill_populated(Flexpage *flexpage) 75 { 76 (void) flexpage; 77 } 78 79 void Accessor::flush_populated(Flexpage *flexpage) 80 { 81 (void) flexpage; 82 } 83 84 // vim: tabstop=4 expandtab shiftwidth=4