libamxb  4.8.2
Bus Agnostic C API
amxb_types.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** SPDX-License-Identifier: BSD-2-Clause-Patent
4 **
5 ** SPDX-FileCopyrightText: Copyright (c) 2023 SoftAtHome
6 **
7 ** Redistribution and use in source and binary forms, with or without modification,
8 ** are permitted provided that the following conditions are met:
9 **
10 ** 1. Redistributions of source code must retain the above copyright notice,
11 ** this list of conditions and the following disclaimer.
12 **
13 ** 2. Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each copyright holder
18 ** and contributor hereby grants to those receiving rights under this license
19 ** a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
20 ** (except for failure to satisfy the conditions of this license) patent license
21 ** to make, have made, use, offer to sell, sell, import, and otherwise transfer
22 ** this software, where such license applies only to those patent claims, already
23 ** acquired or hereafter acquired, licensable by such copyright holder or contributor
24 ** that are necessarily infringed by:
25 **
26 ** (a) their Contribution(s) (the licensed copyrights of copyright holders and
27 ** non-copyrightable additions of contributors, in source or binary form) alone;
28 ** or
29 **
30 ** (b) combination of their Contribution(s) with the work of authorship to which
31 ** such Contribution(s) was added by such copyright holder or contributor, if,
32 ** at the time the Contribution is added, such addition causes such combination
33 ** to be necessarily infringed. The patent license shall not apply to any other
34 ** combinations which include the Contribution.
35 **
36 ** Except as expressly stated above, no rights or licenses from any copyright
37 ** holder or contributor is granted under this license, whether expressly, by
38 ** implication, estoppel or otherwise.
39 **
40 ** DISCLAIMER
41 **
42 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
51 ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 **
53 ****************************************************************************/
54 
55 #if !defined(__AMXB_TYPES_H__)
56 #define __AMXB_TYPES_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #ifndef __AMXP_SIGNAL_H__
64 #pragma GCC error "include <amxp/amxp_signal.h> before <amxb/amxb_types.h>"
65 #endif
66 
67 #ifndef __AMXD_TYPES_H__
68 #pragma GCC error "include <amxd/amxd_types.h> before <amxb/amxb_types.h>"
69 #endif
70 
71 
72 
73 #define AMXB_PUBLIC 0
74 #define AMXB_PROTECTED 1
75 
76 #define AMXB_DATA_SOCK 0
77 #define AMXB_LISTEN_SOCK 1
78 
79 typedef struct _amxb_be_funcs amxb_be_funcs_t;
80 typedef struct _amxb_bus_ctx amxb_bus_ctx_t;
81 
82 typedef struct _amxb_request amxb_request_t;
83 typedef struct _amxb_invoke amxb_invoke_t;
84 
85 typedef void (* amxb_be_cb_fn_t) (const amxb_bus_ctx_t* bus_ctx,
86  const amxc_var_t* const data,
87  void* priv);
88 
89 typedef void (* amxb_be_done_cb_fn_t) (const amxb_bus_ctx_t* bus_ctx,
90  amxb_request_t* req,
91  int status,
92  void* priv);
93 
95  const amxc_var_t* args,
96  void* priv);
97 
98 typedef struct _amxb_version {
99  int32_t major;
100  int32_t minor;
101  int32_t build;
103 
104 typedef struct _amxb_be_info {
108  const char* name;
109  const char* description;
112 
113 typedef amxb_be_info_t* (* amxb_be_info_fn_t)(void);
114 
116  amxc_llist_it_t it;
117  amxc_htable_it_t hit;
118  amxc_llist_t requests;
119  amxc_llist_t invoke_ctxs;
120  amxp_signal_mngr_t sigmngr;
122  void* bus_ctx;
123  amxd_dm_t* dm;
124  amxc_htable_t subscriptions;
125  uint32_t access;
126  uint32_t socket_type;
127  amxc_llist_t client_subs;
128  void* priv;
129 };
130 
139  amxc_llist_it_t it;
140  amxc_var_t* result;
144  void* bus_data;
145  void* priv;
146  uint32_t flags;
147 };
148 
149 struct _amxb_invoke {
150  amxc_llist_it_t it;
151  char* object;
152  char* interface;
153  char* method;
154  void* bus_data;
155 };
156 
157 typedef struct _amxb_subscription {
158  char* object;
159  amxp_slot_fn_t slot_cb;
160  void* priv;
161  amxc_llist_it_t it;
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif // __AMXB_TYPES_H__
struct _amxb_subscription amxb_subscription_t
void(* amxb_be_cb_fn_t)(const amxb_bus_ctx_t *bus_ctx, const amxc_var_t *const data, void *priv)
Definition: amxb_types.h:85
void(* amxb_be_done_cb_fn_t)(const amxb_bus_ctx_t *bus_ctx, amxb_request_t *req, int status, void *priv)
Definition: amxb_types.h:89
int(* amxb_be_task_fn_t)(amxb_bus_ctx_t *bus_ctx, const amxc_var_t *args, void *priv)
Definition: amxb_types.h:94
struct _amxb_version amxb_version_t
struct _amxb_be_info amxb_be_info_t
The back-end interface structure.
const amxb_version_t * min_supported
Definition: amxb_types.h:105
const char * description
Definition: amxb_types.h:109
const amxb_version_t * be_version
Definition: amxb_types.h:107
const char * name
Definition: amxb_types.h:108
amxb_be_funcs_t * funcs
Definition: amxb_types.h:110
const amxb_version_t * max_supported
Definition: amxb_types.h:106
const amxb_be_funcs_t * bus_fn
Definition: amxb_types.h:121
amxc_llist_t requests
Definition: amxb_types.h:118
amxc_llist_t client_subs
Definition: amxb_types.h:127
uint32_t access
Definition: amxb_types.h:125
amxd_dm_t * dm
Definition: amxb_types.h:123
amxp_signal_mngr_t sigmngr
Definition: amxb_types.h:120
amxc_htable_t subscriptions
Definition: amxb_types.h:124
uint32_t socket_type
Definition: amxb_types.h:126
amxc_llist_t invoke_ctxs
Definition: amxb_types.h:119
amxc_htable_it_t hit
Definition: amxb_types.h:117
amxc_llist_it_t it
Definition: amxb_types.h:116
void * bus_ctx
Definition: amxb_types.h:122
amxc_llist_it_t it
Definition: amxb_types.h:150
void * bus_data
Definition: amxb_types.h:154
char * interface
Definition: amxb_types.h:152
char * method
Definition: amxb_types.h:153
char * object
Definition: amxb_types.h:151
A request structure.
Definition: amxb_types.h:138
amxc_var_t * result
Definition: amxb_types.h:140
amxb_be_cb_fn_t cb_fn
Definition: amxb_types.h:141
uint32_t flags
Definition: amxb_types.h:146
void * bus_data
Definition: amxb_types.h:144
amxb_be_done_cb_fn_t done_fn
Definition: amxb_types.h:142
amxc_llist_it_t it
Definition: amxb_types.h:139
amxp_slot_fn_t slot_cb
Definition: amxb_types.h:159
amxc_llist_it_t it
Definition: amxb_types.h:161
int32_t major
Definition: amxb_types.h:99
int32_t minor
Definition: amxb_types.h:100
int32_t build
Definition: amxb_types.h:101
static amxb_bus_ctx_t * bus_ctx
Definition: test_amxb_e2e.c:84