libamxd  6.4.1
Data Model Manager
amxd_dm.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(__AMXD_DM_H__)
56 #define __AMXD_DM_H__
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #include <amxd/amxd_types.h>
64 
97 
114 void amxd_dm_delete(amxd_dm_t** dm);
115 
135 
147 void amxd_dm_clean(amxd_dm_t* dm);
148 
150  amxd_object_t* const object);
151 
153  const char* name);
154 
176  amxd_object_t* const object);
177 
194 amxd_status_t amxd_dm_remove_root_object(amxd_dm_t* const dm, const char* name);
195 
211 
212 amxd_object_t* amxd_dm_get_object(amxd_dm_t* const dm, const char* name);
213 
215  const char* abs_path,
216  ...) __attribute__ ((format(printf, 2, 3)));
217 
219  amxc_llist_t* paths,
220  const char* abs_path,
221  ...) __attribute__ ((format(printf, 3, 4)));
222 
224  bool* key_path,
225  amxc_llist_t* paths,
226  const char* abs_path,
227  ...) __attribute__ ((format(printf, 4, 5)));
254 const char* amxd_dm_signal_get_path(amxd_dm_t* const dm,
255  const amxc_var_t* const signal_data);
256 
284  const amxc_var_t* const signal_data);
285 
287  amxd_param_t* param,
288  amxd_action_t reason,
289  const amxc_var_t* const args,
290  amxc_var_t* const retval);
291 static inline
293  return dm == NULL ? amxd_status_invalid_arg : dm->status;
294 }
295 
296 #ifdef __cplusplus
297 }
298 #endif
299 
300 #endif // __AMXD_DM_H__
301 
amxd_status_t amxd_dm_store_mib(amxd_dm_t *const dm, amxd_object_t *const object)
Definition: amxd_dm.c:378
amxd_object_t * amxd_dm_get_mib(amxd_dm_t *const dm, const char *name)
Definition: amxd_dm.c:397
amxd_object_t * amxd_dm_findf(amxd_dm_t *const dm, const char *abs_path,...) __attribute__((format(printf
static amxd_status_t amxd_dm_get_status(amxd_dm_t *dm)
Definition: amxd_dm.h:292
amxd_object_t amxd_status_t amxd_status_t amxd_dm_resolve_pathf_ext(amxd_dm_t *const dm, bool *key_path, amxc_llist_t *paths, const char *abs_path,...) __attribute__((format(printf
amxd_status_t amxd_dm_invoke_action(amxd_object_t *object, amxd_param_t *param, amxd_action_t reason, const amxc_var_t *const args, amxc_var_t *const retval)
Definition: amxd_dm.c:591
amxd_object_t * amxd_dm_get_object(amxd_dm_t *const dm, const char *name)
Definition: amxd_dm.c:466
amxd_object_t amxd_status_t amxd_dm_resolve_pathf(amxd_dm_t *const dm, amxc_llist_t *paths, const char *abs_path,...) __attribute__((format(printf
enum _amxd_action amxd_action_t
enum _amxd_status amxd_status_t
@ amxd_status_invalid_arg
Definition: amxd_types.h:96
amxd_object_t * amxd_dm_get_root(amxd_dm_t *const dm)
Fetches the root object of the data model.
Definition: amxd_dm.c:456
amxd_status_t amxd_dm_new(amxd_dm_t **dm)
Instantiate a new data model.
Definition: amxd_dm.c:306
amxd_status_t amxd_dm_remove_root_object(amxd_dm_t *const dm, const char *name)
Removes an object from the root of the data model.
Definition: amxd_dm.c:433
amxd_object_t amxd_status_t amxd_status_t const char * amxd_dm_signal_get_path(amxd_dm_t *const dm, const amxc_var_t *const signal_data)
Get the object path from a data model signal.
Definition: amxd_dm.c:560
void amxd_dm_delete(amxd_dm_t **dm)
Deletes a data model structure.
Definition: amxd_dm.c:321
amxd_status_t amxd_dm_add_root_object(amxd_dm_t *const dm, amxd_object_t *const object)
Adds an object to the root of the data model.
Definition: amxd_dm.c:418
amxd_object_t * amxd_dm_signal_get_object(amxd_dm_t *const dm, const amxc_var_t *const signal_data)
Get the object from a data model using the path in the recieved signal.
Definition: amxd_dm.c:573
amxd_status_t amxd_dm_init(amxd_dm_t *dm)
Initializes a data model structure.
Definition: amxd_dm.c:334
void amxd_dm_clean(amxd_dm_t *dm)
Cleans a data model structure.
Definition: amxd_dm.c:365
amxd_status_t status
Definition: amxd_types.h:263
static amxd_dm_t dm