libamxs  0.6.0
Data Model Synchronization C API
amxs_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(__AMXS_TYPES_H__)
56 #define __AMXS_TYPES_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
74 #include <amxp/amxp_signal.h>
75 #include <amxp/amxp_slot.h>
76 #include <amxd/amxd_types.h>
77 #include <amxb/amxb.h>
78 
79 typedef enum _amxs_sync_direction {
84 
85 typedef enum _amxs_status {
97 
98 typedef enum _amxs_sync_entry_type {
104 
105 typedef struct _amxs_sync_entry amxs_sync_ctx_t;
106 typedef struct _amxs_sync_entry amxs_sync_object_t;
107 typedef struct _amxs_sync_entry amxs_sync_param_t;
108 typedef struct _amxs_sync_entry amxs_sync_entry_t;
109 
132  amxs_sync_direction_t direction,
133  const amxc_var_t* input,
134  amxc_var_t* output,
135  void* priv);
136 
157  amxs_sync_direction_t direction,
158  amxc_var_t* data,
159  void* priv);
160 
162  amxc_llist_it_t it; // Linked list iterator, it.list points to the parent object or context
163  char* a; // Name of object/parameter in object A
164  char* b; // Name of object/parameter in object B
165  int attributes; // Sync attributes
166  amxs_action_cb_t action_cb; // Action callback function
167  amxs_translation_cb_t translation_cb; // Translation callback function
168  void* priv; // Private data to be passed to the callback functions
169  amxc_llist_t entries; // List of child entries
170  amxs_sync_entry_type_t type; // Type of sync entry
171  amxb_bus_ctx_t* bus_ctx_a; // Bus context for object A
172  amxb_bus_ctx_t* bus_ctx_b; // Bus context for object B
173  amxc_llist_t subscriptions; // List of amxb subscriptions
174  amxp_signal_mngr_t* sig_mngr; // Signal manager only set on ctx entries to send/receive internal sync events
175  amxc_var_t a_to_b; // Htable of objects and parameters synced from A to B in case of a bidirectional sync
176  amxc_var_t b_to_a; // Htable of objects and parameters synced from B to A in case of a bidirectional sync
177  amxd_dm_t* local_dm_a; // Pointer to the local dm for object A, if available
178  amxd_dm_t* local_dm_b; // Pointer to the local dm for object B, if available
179 };
180 
190 #define AMXS_SYNC_DEFAULT 0x00
195 #define AMXS_SYNC_ONLY_B_TO_A 0x01
200 #define AMXS_SYNC_ONLY_A_TO_B 0x02
205 #define AMXS_SYNC_INIT_B 0x04
210 #define AMXS_SYNC_PARAM_BATCH 0x08
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif // __AMXS_TYPES_H__
217 
enum _amxs_sync_entry_type amxs_sync_entry_type_t
_amxs_status
Definition: amxs_types.h:85
@ amxs_status_ok
Definition: amxs_types.h:86
@ amxs_status_object_not_found
Definition: amxs_types.h:93
@ amxs_status_unknown_error
Definition: amxs_types.h:90
@ amxs_status_subscription_failed
Definition: amxs_types.h:94
@ amxs_status_invalid_type
Definition: amxs_types.h:92
@ amxs_status_invalid_attr
Definition: amxs_types.h:88
@ amxs_status_last
Definition: amxs_types.h:95
@ amxs_status_duplicate
Definition: amxs_types.h:87
@ amxs_status_invalid_arg
Definition: amxs_types.h:89
@ amxs_status_empty_context
Definition: amxs_types.h:91
enum _amxs_sync_direction amxs_sync_direction_t
_amxs_sync_direction
Definition: amxs_types.h:79
@ amxs_sync_a_to_b
Definition: amxs_types.h:80
@ amxs_sync_b_to_a
Definition: amxs_types.h:81
@ amxs_sync_invalid
Definition: amxs_types.h:82
enum _amxs_status amxs_status_t
_amxs_sync_entry_type
Definition: amxs_types.h:98
@ amxs_sync_type_param
Definition: amxs_types.h:102
@ amxs_sync_type_invalid
Definition: amxs_types.h:99
@ amxs_sync_type_object
Definition: amxs_types.h:101
@ amxs_sync_type_ctx
Definition: amxs_types.h:100
amxs_status_t(* amxs_action_cb_t)(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, amxc_var_t *data, void *priv)
Definition of the action callback function.
Definition: amxs_types.h:156
amxs_status_t(* amxs_translation_cb_t)(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, const amxc_var_t *input, amxc_var_t *output, void *priv)
Definition of the translation callback function.
Definition: amxs_types.h:131
Definition: amxs_types.h:161
amxd_dm_t * local_dm_b
Definition: amxs_types.h:178
char * a
Definition: amxs_types.h:163
amxs_sync_entry_type_t type
Definition: amxs_types.h:170
amxc_llist_it_t it
Definition: amxs_types.h:162
void * priv
Definition: amxs_types.h:168
amxb_bus_ctx_t * bus_ctx_a
Definition: amxs_types.h:171
amxd_dm_t * local_dm_a
Definition: amxs_types.h:177
amxs_translation_cb_t translation_cb
Definition: amxs_types.h:167
amxc_var_t b_to_a
Definition: amxs_types.h:176
amxc_var_t a_to_b
Definition: amxs_types.h:175
amxc_llist_t subscriptions
Definition: amxs_types.h:173
amxs_action_cb_t action_cb
Definition: amxs_types.h:166
int attributes
Definition: amxs_types.h:165
amxp_signal_mngr_t * sig_mngr
Definition: amxs_types.h:174
char * b
Definition: amxs_types.h:164
amxc_llist_t entries
Definition: amxs_types.h:169
amxb_bus_ctx_t * bus_ctx_b
Definition: amxs_types.h:172