1// vi:set ft=cpp: -*- Mode: C++ -*-
2/**
3 * \file
4 * Meta interface for getting dynamic type information about objects behind
5 * capabilities.
6 */
7/*
8 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
9 *     economic rights: Technische Universität Dresden (Germany)
10 *
11 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU General Public License 2.
13 * Please see the COPYING-GPL-2 file for details.
14 *
15 * As a special exception, you may use this file as part of a free software
16 * library without restriction.  Specifically, if other files instantiate
17 * templates or use macros or inline functions from this file, or you compile
18 * this file and link it with other files to produce an executable, this
19 * file does not by itself cause the resulting executable to be covered by
20 * the GNU General Public License.  This exception does not however
21 * invalidate any other reasons why the executable file might be covered by
22 * the GNU General Public License.
23 */
24
25#pragma once
26
27#include "kobject"
28#include "cxx/ipc_iface"
29#include "cxx/ipc_string"
30
31namespace L4 {
32
33/**
34 * Meta interface that shall be implemented by each L4Re object
35 * and gives access to the dynamic type information for L4Re objects.
36 */
37class Meta : public Kobject_t<Meta, Kobject, L4_PROTO_META>
38{
39public:
40  /**
41   * Get the number of interfaces implemented by this object.
42   *
43   * \retval l4_msgtag_t::label() >= 0  The number of supported interfaces.
44   * \retval l4_msgtag_t::label() < 0   Error code of the occurred error.
45   */
46  L4_INLINE_RPC(l4_msgtag_t, num_interfaces, ());
47
48  /**
49   * Get the protocol number that must be used for the interface with
50   * the number `idx`.
51   *
52   * \param      idx    The index of the interface to get the protocol
53   *                    number for. `idx` must be >= 0 and < the return
54   *                    value of num_interfaces().
55   * \param[out] proto  The protocol number for interface `idx`.
56   * \param[out] name   The protocol name for interface `idx`.
57   *
58   * \retval l4_msgtag_t::label() == 0  Successful; see `proto` and `name`.
59   * \retval l4_msgtag_t::label() < 0   Error code.
60   */
61  L4_INLINE_RPC(l4_msgtag_t, interface, (l4_umword_t idx, long *proto,
62                                         L4::Ipc::String<char> *name));
63
64  /**
65   * Figure out if the object supports the given protocol (number).
66   *
67   * \param protocol  The protocol number to check for.
68   *
69   * \retval l4_msgtag_t::label() == 1  protocol is supported.
70   * \retval l4_msgtag_t::label() == 0  protocol is not supported.
71   *
72   * This method is intended to be used for statically assigned protocol
73   * numbers.
74   */
75  L4_INLINE_RPC(l4_msgtag_t, supports, (l4_mword_t protocol));
76
77  typedef L4::Typeid::Rpcs<num_interfaces_t, interface_t, supports_t> Rpcs;
78};
79
80}
81