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