paul@93 | 1 | /* |
paul@224 | 2 | * A registry of filesystem object resources. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@9 | 22 | #pragma once |
paul@9 | 23 | |
paul@202 | 24 | #include <fsserver/directory_provider.h> |
paul@144 | 25 | #include <fsserver/file_opening.h> |
paul@200 | 26 | #include <fsserver/file_provider.h> |
paul@94 | 27 | #include <fsserver/pager.h> |
paul@144 | 28 | #include <fsserver/pages.h> |
paul@224 | 29 | #include <fsserver/provider_registry.h> |
paul@9 | 30 | |
paul@9 | 31 | |
paul@9 | 32 | |
paul@224 | 33 | /* A registry of filesystem object resources. */ |
paul@9 | 34 | |
paul@224 | 35 | class ResourceRegistry : public ProviderRegistry |
paul@9 | 36 | { |
paul@9 | 37 | protected: |
paul@79 | 38 | Pages *_pages; |
paul@9 | 39 | |
paul@144 | 40 | map_flags_t get_flags(flags_t flags); |
paul@144 | 41 | |
paul@220 | 42 | /* Provider initialisation methods. */ |
paul@220 | 43 | |
paul@220 | 44 | long make_directory_provider(FileOpening *opening, const char *path, |
paul@220 | 45 | flags_t flags, fileid_t fileid, |
paul@220 | 46 | Provider **provider); |
paul@202 | 47 | |
paul@220 | 48 | long make_file_provider(FileOpening *opening, const char *path, |
paul@220 | 49 | flags_t flags, fileid_t fileid, |
paul@220 | 50 | Provider **provider); |
paul@220 | 51 | |
paul@220 | 52 | long make_provider(FileOpening *opening, const char *path, |
paul@220 | 53 | flags_t flags, fileid_t fileid, |
paul@220 | 54 | Provider **provider); |
paul@193 | 55 | |
paul@79 | 56 | public: |
paul@224 | 57 | explicit ResourceRegistry(Pages *pages); |
paul@79 | 58 | |
paul@232 | 59 | /* Provider discovery methods. |
paul@232 | 60 | NOTE: To be protected, potentially. */ |
paul@208 | 61 | |
paul@220 | 62 | long find_provider(fileid_t fileid, Provider **provider); |
paul@208 | 63 | |
paul@202 | 64 | /* Resource initialisation methods. */ |
paul@144 | 65 | |
paul@218 | 66 | long get_resource(FileOpening *opening, const char *path, flags_t flags, |
paul@218 | 67 | offset_t *size, object_flags_t *object_flags, |
paul@218 | 68 | Resource **resource); |
paul@232 | 69 | |
paul@232 | 70 | /* Provider manipulation methods. */ |
paul@232 | 71 | |
paul@232 | 72 | long remove_provider(FileOpening *opening, const char *path); |
paul@9 | 73 | }; |
paul@9 | 74 | |
paul@9 | 75 | // vim: tabstop=4 expandtab shiftwidth=4 |