gam-resource-manager: adjust to updated proxied call callback signature.
[profile/ivi/murphy.git] / src / core / domain.h
1 /*
2  * Copyright (c) 2012-2014, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *  * Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *  * Neither the name of Intel Corporation nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MURPHY_CORE_DOMAIN__
31 #define __MURPHY_CORE_DOMAIN__
32
33 #include <murphy/common/macros.h>
34 #include <murphy/common/msg.h>
35
36 #include <murphy/core/context.h>
37 #include <murphy/core/domain-types.h>
38
39 MRP_CDECL_BEGIN
40
41 /* Type for a proxied invocation handler. */
42 typedef int (*mrp_domain_invoke_cb_t)(uint32_t narg, mrp_domctl_arg_t *args,
43                                       uint32_t *nout, mrp_domctl_arg_t *outs,
44                                       void *user_data);
45
46 /* Type for a proxied invocation return/reply handler. */
47 typedef void (*mrp_domain_return_cb_t)(int error, int retval, int narg,
48                                        mrp_domctl_arg_t *args, void *user_data);
49
50 typedef struct {
51     char                   *name;        /* method name */
52     int                     max_out;     /* max. number of return arguments */
53     mrp_domain_invoke_cb_t  cb;          /* handler callback */
54     void                   *user_data;   /* opaque callback user data */
55 } mrp_domain_method_def_t;
56
57
58
59 /* Type for handling proxied invocation to domain controllers. */
60 typedef int (*mrp_domain_invoke_handler_t)(void *handler_data, const char *id,
61                                            const char *method, int narg,
62                                            mrp_domctl_arg_t *args,
63                                            mrp_domain_return_cb_t return_cb,
64                                            void *user_data);
65
66 /* Initialize domain-specific context parts. */
67 void domain_setup(mrp_context_t *ctx);
68
69 /* Register a domain method. */
70 int mrp_register_domain_methods(mrp_context_t *ctx,
71                                 mrp_domain_method_def_t *defs, size_t ndef);
72
73 /* Find a registered domain method. */
74 int mrp_lookup_domain_method(mrp_context_t *ctx, const char *method,
75                              mrp_domain_invoke_cb_t *cb, int *max_out,
76                              void **user_data);
77
78 /* Invoke the named method of the specified domain. */
79 int mrp_invoke_domain(mrp_context_t *ctx, const char *domain, const char *method,
80                       int narg, mrp_domctl_arg_t *args,
81                       mrp_domain_return_cb_t return_cb, void *user_data);
82
83 /* Set the domain invoke handler. */
84 int mrp_set_domain_invoke_handler(mrp_context_t *ctx,
85                                   mrp_domain_invoke_handler_t handler,
86                                   void *handler_data);
87
88 MRP_CDECL_END
89
90 #endif /* __MURPHY_CORE_DOMAIN__ */