paul@10 | 1 | /* |
paul@10 | 2 | * Common resource classes and functions. |
paul@10 | 3 | * |
paul@10 | 4 | * Copyright (C) 2018, 2019, 2020 Paul Boddie <paul@boddie.org.uk> |
paul@10 | 5 | * |
paul@10 | 6 | * This program is free software; you can redistribute it and/or |
paul@10 | 7 | * modify it under the terms of the GNU General Public License as |
paul@10 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@10 | 9 | * the License, or (at your option) any later version. |
paul@10 | 10 | * |
paul@10 | 11 | * This program is distributed in the hope that it will be useful, |
paul@10 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@10 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@10 | 14 | * GNU General Public License for more details. |
paul@10 | 15 | * |
paul@10 | 16 | * You should have received a copy of the GNU General Public License |
paul@10 | 17 | * along with this program; if not, write to the Free Software |
paul@10 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@10 | 19 | * Boston, MA 02110-1301, USA |
paul@10 | 20 | */ |
paul@10 | 21 | |
paul@1 | 22 | #pragma once |
paul@1 | 23 | |
paul@10 | 24 | #include <ipc/server.h> |
paul@10 | 25 | |
paul@1 | 26 | |
paul@1 | 27 | |
paul@10 | 28 | /* A generic class for an object potentially needing to be closed after use. */ |
paul@1 | 29 | |
paul@1 | 30 | class Resource |
paul@1 | 31 | { |
paul@1 | 32 | public: |
paul@10 | 33 | virtual ~Resource() |
paul@10 | 34 | { |
paul@10 | 35 | } |
paul@10 | 36 | |
paul@10 | 37 | /* Server details. */ |
paul@10 | 38 | |
paul@10 | 39 | virtual int expected_items() = 0; |
paul@10 | 40 | |
paul@10 | 41 | virtual ipc_server_handler_type handler() = 0; |
paul@10 | 42 | |
paul@10 | 43 | virtual void *interface() = 0; |
paul@1 | 44 | |
paul@10 | 45 | /* Deallocation of resources. */ |
paul@10 | 46 | |
paul@10 | 47 | virtual void close() |
paul@10 | 48 | { |
paul@10 | 49 | } |
paul@10 | 50 | |
paul@10 | 51 | /* Activation. */ |
paul@10 | 52 | |
paul@10 | 53 | virtual void activate() |
paul@10 | 54 | { |
paul@10 | 55 | } |
paul@1 | 56 | }; |