Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_object_aggregate_external.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive framework memory functions
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
17 #include "afw_internal.h"
18 
19 #define impl_afw_object_get_meta afw_object_impl_internal_get_meta
20 
21 #define impl_afw_object_get_property_meta \
22  afw_object_impl_internal_get_property_meta
23 
24 #define impl_afw_object_get_next_property_meta \
25  afw_object_impl_internal_get_next_property_meta
26 
27 /* Declares and rti/inf defines for interface afw_object */
28 #define AFW_IMPLEMENTATION_ID "afw_object_aggregate_external"
30 
31 
32 
33 AFW_DEFINE(const afw_object_t *)
35  const afw_object_t * const *object_list,
36  const afw_pool_t *p,
37  afw_xctx_t *xctx)
38 {
40 
42  self->pub.inf = &impl_afw_object_inf;
43  self->pub.p = p;
44  self->object_list = object_list;
45  return (const afw_object_t *)self;
46 }
47 
48 
49 
50 /*
51  * Implementation of method release for interface afw_object.
52  */
53 void
54 impl_afw_object_release(
55  const afw_object_t * instance,
56  afw_xctx_t *xctx)
57 {
58  /* Not managed. */
59 }
60 
61 /*
62  * Implementation of method add_reference for interface afw_object.
63  */
64 void
65 impl_afw_object_add_reference(
66  const afw_object_t * instance,
67  afw_xctx_t *xctx)
68 {
69  /* Not managed. */
70 }
71 
72 /*
73  * Implementation of method get_count for interface afw_object.
74  */
77  const afw_object_t * instance,
78  afw_xctx_t * xctx)
79 {
80 // <afwdev {prefixed_interface_name}>_self_t *self =
81 // (<afwdev {prefixed_interface_name}>_self_t *)instance;
82 
84  AFW_THROW_ERROR_Z(general, "Method not implemented.", xctx);
85 
86 }
87 
88 /*
89  * Implementation of method get_property for interface afw_object.
90  */
91 const afw_value_t *
92 impl_afw_object_get_property(
93  const afw_object_t * instance,
94  const afw_utf8_t * property_name,
95  afw_xctx_t *xctx)
96 {
99  const afw_object_t * const *obj;
100  const afw_value_t *result;
101 
102  for (obj = self->object_list, result = NULL; *obj; obj++) {
103  result = afw_object_get_property(*obj, property_name, xctx);
104  if (result) {
105  break;
106  }
107  }
108  return result;
109 }
110 
111 
112 /*
113  * Implementation of method get_next_property for interface afw_object.
114  */
115 const afw_value_t *
116 impl_afw_object_get_next_property(
117  const afw_object_t * instance,
118  const afw_iterator_t * * iterator,
119  const afw_utf8_t * * property_name,
120  afw_xctx_t *xctx)
121 {
124  const afw_value_t *result;
125 
126  if (!*iterator) {
127  *iterator = (const afw_iterator_t *)&self->iterator;
128  self->iterator.object = self->object_list;
129  self->iterator.iterator = NULL;
130  }
131 
132  result = NULL;
133  for (; *self->iterator.object; self->iterator.object++) {
135  *self->iterator.object, &self->iterator.iterator,
136  property_name, xctx);
137  if (result) {
138  break;
139  }
140  }
141 
142  if (!result) {
143  *iterator = NULL;
144  }
145 
146  return result;
147 }
148 
149 /*
150  * Implementation of method has_property for interface afw_object.
151  */
153 impl_afw_object_has_property(
154  const afw_object_t * instance,
155  const afw_utf8_t * property_name,
156  afw_xctx_t *xctx)
157 {
158  return impl_afw_object_get_property(instance, property_name, xctx) != NULL;
159 }
160 
161 /*
162  * Implementation of method get_setter for interface afw_object.
163  */
164 const afw_object_setter_t *
165 impl_afw_object_get_setter(
166  const afw_object_t * instance,
167  afw_xctx_t *xctx)
168 {
171 
172  return afw_object_get_setter(*self->object_list, xctx);
173 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
struct afw_iterator_s afw_iterator_t
_Bool afw_boolean_t
Definition: afw_common.h:373
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
afw_size_t impl_afw_object_get_count(const afw_object_t *instance, afw_xctx_t *xctx)
#define afw_object_get_property(instance, property_name, xctx)
Call method get_property of interface afw_object.
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
#define afw_object_get_setter(instance, xctx)
Call method get_setter of interface afw_object.
afw_object_aggregate_external_create(const afw_object_t *const *object_list, const afw_pool_t *p, afw_xctx_t *xctx)
Create an aggregate object with an external object list.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
Interface afw_object public struct.
Interface afw_object_setter public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
Interface afw_xctx public struct.