paul@9 | 1 | #pragma once |
paul@9 | 2 | |
paul@10 | 3 | #include <l4/sys/ipc.h> |
paul@10 | 4 | |
paul@9 | 5 | #include "file_pager.h" |
paul@10 | 6 | #include "opener_context_resource.h" |
paul@10 | 7 | #include "opener_interface.h" |
paul@9 | 8 | #include "pager.h" |
paul@9 | 9 | #include "paging.h" |
paul@9 | 10 | #include "pages.h" |
paul@10 | 11 | #include "resource.h" |
paul@9 | 12 | |
paul@9 | 13 | /* Support for providing access to files. */ |
paul@9 | 14 | |
paul@10 | 15 | class OpenerResource : public Resource, public Opener |
paul@9 | 16 | { |
paul@9 | 17 | protected: |
paul@9 | 18 | Paging *_paging; |
paul@9 | 19 | Pages *_pages; |
paul@9 | 20 | |
paul@9 | 21 | /* Convenience methods. */ |
paul@9 | 22 | |
paul@78 | 23 | PageMapper *get_mapper(fileid_t fileid); |
paul@9 | 24 | |
paul@9 | 25 | /* Configurable methods. */ |
paul@9 | 26 | |
paul@9 | 27 | virtual fileid_t get_fileid(const char *path) = 0; |
paul@9 | 28 | |
paul@9 | 29 | virtual Accessor *make_accessor(fileid_t fileid) = 0; |
paul@9 | 30 | |
paul@9 | 31 | public: |
paul@78 | 32 | explicit OpenerResource(Paging *paging, Pages *pages); |
paul@10 | 33 | |
paul@10 | 34 | /* Server details. */ |
paul@10 | 35 | |
paul@10 | 36 | int expected_items(); |
paul@9 | 37 | |
paul@10 | 38 | ipc_server_handler_type handler(); |
paul@10 | 39 | |
paul@10 | 40 | void *interface() |
paul@10 | 41 | { return static_cast<Opener *>(this); } |
paul@10 | 42 | |
paul@10 | 43 | /* Direct access methods. */ |
paul@9 | 44 | |
paul@51 | 45 | FilePager *open(const char *path, flags_t flags); |
paul@10 | 46 | |
paul@10 | 47 | /* Opener interface methods. */ |
paul@10 | 48 | |
paul@10 | 49 | long context(l4_cap_idx_t *context); |
paul@9 | 50 | }; |
paul@9 | 51 | |
paul@9 | 52 | // vim: tabstop=4 expandtab shiftwidth=4 |