L4Re/OLD/libfsserver

include/fsserver/server.h

149:038b9f65e02a
2020-04-04 Paul Boddie Removed superfluous includes.
     1 /*     2  * Common server classes and loops.     3  *     4  * Copyright (C) 2018, 2019, 2020 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software; you can redistribute it and/or     7  * modify it under the terms of the GNU General Public License as     8  * published by the Free Software Foundation; either version 2 of     9  * the License, or (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21     22 #pragma once    23     24 #include <l4/sys/types.h>    25 #include <ipc/message.h>    26     27     28     29 /* A server object handling incoming messages. */    30     31 class Server    32 {    33 protected:    34   l4_cap_idx_t _cap = L4_INVALID_CAP;    35   int _expected_items;    36     37 public:    38   explicit Server(int expected_items=0)    39   : _expected_items(expected_items)    40   {    41   }    42     43   virtual ~Server()    44   {    45   }    46     47   /* Capability associated with this object. */    48     49   l4_cap_idx_t cap() { return _cap; }    50     51   /* Number of expected items (capabilities) in incoming messages. */    52     53   int expected_items() { return _expected_items; }    54     55   /* Server binding/registration. */    56     57   virtual long bind(const char *name);    58     59   /* Main loop. */    60     61   virtual long start();    62     63   /* IPC message handling and dispatch methods. */    64     65   virtual void handle(ipc_message_t *msg) = 0;    66     67   virtual void dispatch(ipc_message_t *msg) { (void) msg; }    68 };    69     70     71     72 /* Server binding/registration. */    73     74 long server_bind(const char *name, Server *obj);    75     76 /* Message processing for servers. */    77     78 void server_handle(ipc_message_t *msg, Server *obj);    79     80 /* Server main loop. */    81     82 long server_loop(int expected_items);