paul@193 | 1 | /* |
paul@219 | 2 | * Filesystem object provider support. |
paul@193 | 3 | * |
paul@330 | 4 | * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk> |
paul@193 | 5 | * |
paul@193 | 6 | * This program is free software; you can redistribute it and/or |
paul@193 | 7 | * modify it under the terms of the GNU General Public License as |
paul@193 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@193 | 9 | * the License, or (at your option) any later version. |
paul@193 | 10 | * |
paul@193 | 11 | * This program is distributed in the hope that it will be useful, |
paul@193 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@193 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@193 | 14 | * GNU General Public License for more details. |
paul@193 | 15 | * |
paul@193 | 16 | * You should have received a copy of the GNU General Public License |
paul@193 | 17 | * along with this program; if not, write to the Free Software |
paul@193 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@193 | 19 | * Boston, MA 02110-1301, USA |
paul@193 | 20 | */ |
paul@193 | 21 | |
paul@193 | 22 | #pragma once |
paul@193 | 23 | |
paul@198 | 24 | #include <fsserver/accountable.h> |
paul@193 | 25 | #include <fsserver/notification.h> |
paul@224 | 26 | #include <fsserver/provider_registry.h> |
paul@535 | 27 | #include <resource/resource.h> |
paul@193 | 28 | |
paul@193 | 29 | |
paul@193 | 30 | |
paul@219 | 31 | /* A provider offering notification support and accounting capabilities. */ |
paul@193 | 32 | |
paul@219 | 33 | class Provider : public NotificationSupport, public Accountable |
paul@193 | 34 | { |
paul@221 | 35 | protected: |
paul@221 | 36 | fileid_t _fileid; |
paul@224 | 37 | ProviderRegistry *_registry; |
paul@232 | 38 | bool _remove = false; |
paul@221 | 39 | |
paul@193 | 40 | public: |
paul@224 | 41 | explicit Provider(fileid_t fileid, ProviderRegistry *registry); |
paul@221 | 42 | |
paul@221 | 43 | virtual ~Provider(); |
paul@221 | 44 | |
paul@224 | 45 | virtual ProviderRegistry *registry(); |
paul@222 | 46 | |
paul@330 | 47 | virtual long make_resource(flags_t flags, offset_t *size, |
paul@330 | 48 | object_flags_t *object_flags, |
paul@221 | 49 | Resource **resource) = 0; |
paul@232 | 50 | |
paul@232 | 51 | /* Lifecycle methods. */ |
paul@232 | 52 | |
paul@232 | 53 | virtual bool removal_pending(); |
paul@232 | 54 | |
paul@232 | 55 | virtual void remove_pending(bool remove); |
paul@193 | 56 | }; |
paul@193 | 57 | |
paul@193 | 58 | // vim: tabstop=4 expandtab shiftwidth=4 |