Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_associative_array_template.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Associative Array Templates
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_ASSOCIATIVE_ARRAY_TEMPLATE_H__
10 #define __AFW_ASSOCIATIVE_ARRAY_TEMPLATE_H__
11 
24 #define AFW_ASSOCIATIVE_ARRAY_TEMPLATE(name, type) \
25 \
26 struct name##_s { \
27  const afw_pool_t *p; \
28 }; \
29 \
30 AFW_DEFINE_STATIC_INLINE( const name##_t * ) \
31 name##_create( \
32  afw_associative_array_add_reference_value_cb add_reference_value, \
33  afw_associative_array_release_value_cb release_value, \
34  const afw_pool_t *p, afw_xctx_t *xctx) \
35 {\
36  return (const name##_t *)afw_associative_array_create( \
37  add_reference_value, release_value, p, xctx); \
38 }\
39 \
40 AFW_DEFINE_STATIC_INLINE( void ) \
41 name##_release(const name##_t *instance, \
42  afw_xctx_t *xctx) \
43 {\
44  afw_associative_array_release( \
45  (const afw_associative_array_t *)instance, \
46  xctx); \
47 }\
48 \
49 AFW_DEFINE_STATIC_INLINE( void ) \
50 name##_add_reference(const name##_t *instance, \
51  afw_xctx_t *xctx) \
52 {\
53  afw_associative_array_add_reference( \
54  (const afw_associative_array_t *)instance, \
55  xctx); \
56 }\
57 \
58 AFW_DEFINE_STATIC_INLINE( const type * ) \
59 name##_get(const name##_t *instance, const afw_utf8_t *key, \
60  afw_xctx_t *xctx) \
61 {\
62  return afw_associative_array_get( \
63  (const afw_associative_array_t *)instance, \
64  key, xctx); \
65 }\
66 \
67 AFW_DEFINE_STATIC_INLINE( const type * ) \
68 name##_get_reference(const name##_t *instance, const afw_utf8_t *key, \
69  afw_xctx_t *xctx) \
70 {\
71  return afw_associative_array_get_reference( \
72  (const afw_associative_array_t *)instance, \
73  key, xctx); \
74 }\
75 \
76 AFW_DEFINE_STATIC_INLINE( void ) \
77 name##_for_each(const name##_t *instance, void *context, \
78  afw_value_cb_t callback, afw_xctx_t *xctx) \
79 {\
80  afw_associative_array_for_each( \
81  (const afw_associative_array_t *)instance, \
82  context, callback, xctx); \
83 }\
84 \
85 AFW_DEFINE_STATIC_INLINE( void ) \
86 name##_set(const name##_t *instance, \
87  const afw_utf8_t *key, const type *value, \
88  afw_xctx_t *xctx) \
89 {\
90  afw_associative_array_set( \
91  (const afw_associative_array_t *)instance, \
92  key, ( const void * )value, xctx); \
93 }\
94 
97 #endif /* __AFW_ASSOCIATIVE_ARRAY_TEMPLATE_H__ */