Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_runtime.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Implementation of afw_adaptor_factory interface for afw_runtime
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 /* Declares and rti/inf defines for interface afw_adaptor_factory */
19 #define AFW_IMPLEMENTATION_ID "afw_runtime"
23 
24 typedef struct {
25  void *always_NULL;
27  void *data;
29 
30 
31 typedef struct {
32  union {
33  const afw_object_t object;
34  impl_ht_object_cb_entry cb_entry;
35  };
37 
38 
39 static const afw_object_t *
40 impl_entry_to_object(
41  const impl_ht_object_entry *entry,
42  afw_xctx_t *xctx)
43 {
44  const afw_object_t *result;
45 
46  if (!entry) {
47  result = NULL;
48  }
49 
50  else if ((entry)->cb_entry.always_NULL == NULL) {
51  result = entry->cb_entry.cb(entry->cb_entry.data, xctx->p, xctx);
52  }
53 
54  else {
55  result = (const afw_object_t *)entry;
56  }
57 
58  return result;
59 }
60 
61 
62 static const afw_object_t *
63 impl_get_object(
64  apr_hash_t *ht, const void *key, apr_ssize_t klen,
65  afw_xctx_t *xctx)
66 {
67  const afw_object_t *result;
68  const impl_ht_object_entry *entry;
69 
70  entry = apr_hash_get(ht, key, klen);
71 
72  result = impl_entry_to_object(entry, xctx);
73 
74  return result;
75 }
76 
77 
79 impl_runtime_meta_const_embedded_untyped_object = {
80  NULL,
81  NULL,
83  false
84 };
85 
86 AFW_RUNTIME_OBJECT_INF(
87  afw_runtime_inf_const_embedded_untyped_object,
88  impl_runtime_meta_const_embedded_untyped_object);
89 
90 
92  apr_hash_t *types_ht;
93 };
94 
95 typedef struct impl_afw_adaptor_self_s {
96  afw_adaptor_t pub;
97 
98  /* Private implementation variables */
99 
101 
104 
105  /* Private implementation variables */
106 
107  afw_adaptor_object_type_cache_t object_type_cache;
108 
110 
111 static const afw_object_t *
112 impl_resolve_untyped_object(
114  const afw_object_t *embedding_object,
115  const afw_utf8_t *property_name,
116  const afw_pool_t *p,
117  afw_xctx_t *xctx);
118 
119 static const afw_list_t *
120 impl_resolve_list(
121  const afw_runtime_unresolved_const_list_t *unresolved,
122  const afw_pool_t *p,
123  afw_xctx_t *xctx);
124 
125 static const afw_runtime_property_t *
126 impl_resolve_property(
127  const afw_runtime_unresolved_property_t *unresolved,
128  const afw_object_t *embedding_object,
129  const afw_pool_t *p,
130  afw_xctx_t *xctx);
131 
132 static const afw_runtime_property_t * const *
133 impl_resolve_properties(
134  const afw_runtime_unresolved_property_t * const *properties,
135  const afw_object_t *embedding_object,
136  const afw_pool_t *p,
137  afw_xctx_t *xctx);
138 
139 
140 static const afw_utf8_t impl_factory_description =
141 AFW_UTF8_LITERAL("Adaptor type for accessing runtime objects.");
142 
143 static const afw_adaptor_factory_t
144 impl_factory =
145 {
146  &impl_afw_adaptor_factory_inf,
147  AFW_UTF8_LITERAL("afw_runtime"),
148  &impl_factory_description
149 };
150 
151 
152 static void
153 impl_set_entry(
154  const afw_utf8_t *object_type_id,
155  const afw_utf8_t *object_id,
156  const impl_ht_object_entry *entry,
157  afw_boolean_t overwrite,
158  afw_xctx_t *xctx)
159 {
160  afw_runtime_objects_t *runtime_objects;
161  apr_hash_t *ht;
162  apr_hash_t *test_ht;
163  const afw_pool_t *p;
164  afw_xctx_t *env_xctx;
165 
166  p = xctx->env->p;
167 
168  for (env_xctx = xctx; env_xctx->parent; env_xctx = env_xctx->parent);
169  runtime_objects = (afw_runtime_objects_t *)env_xctx->runtime_objects;
170 
171  ht = NULL;
172 
173  if (!runtime_objects) {
174  runtime_objects = afw_pool_calloc_type(p, afw_runtime_objects_t, xctx);
175  env_xctx->runtime_objects = runtime_objects;
176  }
177 
178  if (!runtime_objects->types_ht) {
179  runtime_objects->types_ht = apr_hash_make(afw_pool_get_apr_pool(p));
180  }
181 
182  else {
183  ht = apr_hash_get(runtime_objects->types_ht,
184  object_type_id->s, object_type_id->len);
185  }
186 
187  if (!ht) {
188  ht = apr_hash_make(afw_pool_get_apr_pool(p));
189  apr_hash_set(runtime_objects->types_ht,
190  object_type_id->s, object_type_id->len, ht);
191  }
192 
193  if (!overwrite) {
194  test_ht = apr_hash_get(ht, object_id->s, object_id->len);
195  if (test_ht) {
196  AFW_THROW_ERROR_FZ(general, xctx,
197  "Runtime object /afw/%"
198  AFW_UTF8_FMT "/%" AFW_UTF8_FMT " already set",
199  AFW_UTF8_FMT_ARG(object_type_id),
200  AFW_UTF8_FMT_ARG(object_id));
201  }
202  }
203  apr_hash_set(ht, object_id->s, object_id->len, entry);
204 }
205 
206 
207 
208 /* Set an object pointer in the environment's runtime objects. */
209 AFW_DEFINE(void)
211  const afw_object_t *object, afw_boolean_t overwrite, afw_xctx_t *xctx)
212 {
213  const afw_utf8_t *object_id;
214  const afw_utf8_t *object_type_id;
215 
216  object_id = afw_object_meta_get_object_id(object, xctx);
217  object_type_id = afw_object_meta_get_object_type_id(object, xctx);
218 
219  impl_set_entry(object_type_id, object_id,
220  (const impl_ht_object_entry *)object, overwrite, xctx);
221 
222  afw_object_add_reference(object, xctx);
223 }
224 
225 
226 /* Set a list of object pointers in the environment's runtime objects. */
227 AFW_DEFINE(void)
229  const afw_object_t * const * objects, afw_boolean_t overwrite,
230  afw_xctx_t *xctx)
231 {
232  for (; *objects; objects++) {
233  afw_runtime_env_set_object(*objects, overwrite, xctx);
234  }
235 }
236 
237 
238 /* Set environment object accessed via callback. */
239 AFW_DEFINE(void)
241  const afw_utf8_t *object_type_id,
242  const afw_utf8_t *object_id,
244  void *data,
245  afw_boolean_t overwrite,
246  afw_xctx_t *xctx)
247 {
249 
250  entry = afw_pool_calloc_type(xctx->env->p,
252  entry->cb = callback;
253  entry->data = data;
254 
255  impl_set_entry(object_type_id, object_id,
256  (const impl_ht_object_entry *)entry, overwrite, xctx);
257 }
258 
259 
260 
261 AFW_DEFINE(void)
263  const afw_utf8_t *object_type_id,
264  const afw_utf8_t *object_id,
265  afw_xctx_t *xctx)
266 {
267  const afw_object_t *object;
268  const afw_xctx_t *c;
269  apr_hash_t *ht;
270 
271  object = NULL;
272  for (c = xctx; c; c = c->parent) {
273  if (c->runtime_objects && c->runtime_objects->types_ht) {
274  ht = apr_hash_get(c->runtime_objects->types_ht,
275  object_type_id->s, object_type_id->len);
276  if (ht) {
277  object = impl_get_object(ht, object_id->s, object_id->len,
278  xctx);
279  if (object) {
280  apr_hash_set(ht, object_id->s, object_id->len, NULL);
281  afw_object_release(object, xctx);
282  break;
283  }
284  }
285  }
286  }
287 }
288 
289 
290 /* Set an object pointer in the xctx's runtime objects. */
291 AFW_DEFINE(void)
293  const afw_object_t *object, afw_boolean_t overwrite,
294  afw_xctx_t *xctx)
295 {
296  const afw_utf8_t *id;
297  const afw_utf8_t *type;
298  afw_runtime_objects_t *runtime_objects;
299  apr_hash_t *ht;
300  apr_hash_t *test_ht;
301  apr_pool_t *p;
302 
303  p = afw_pool_get_apr_pool(xctx->p);
304  id = afw_object_meta_get_object_id(object, xctx);
305  type = afw_object_meta_get_object_type_id(object, xctx);
306 
307  ht = NULL;
308  runtime_objects = (afw_runtime_objects_t *)xctx->runtime_objects;
309 
310  if (!runtime_objects) {
311  runtime_objects = afw_xctx_calloc_type(afw_runtime_objects_t, xctx);
312  xctx->runtime_objects = runtime_objects;
313  }
314 
315  if (!runtime_objects->types_ht) {
316  runtime_objects->types_ht = apr_hash_make(p);
317  }
318 
319  else {
320  ht = apr_hash_get(runtime_objects->types_ht, type->s, type->len);
321  }
322 
323  if (!ht) {
324  ht = apr_hash_make(afw_pool_get_apr_pool(xctx->p));
325  apr_hash_set(runtime_objects->types_ht, type->s, type->len, ht);
326  }
327 
328  if (!overwrite) {
329  test_ht = apr_hash_get(ht, id->s, id->len);
330  if (test_ht) {
331  AFW_THROW_ERROR_FZ(general, xctx,
332  "Runtime object /afw/%"
333  AFW_UTF8_FMT "/%" AFW_UTF8_FMT " already set",
335  }
336  }
337  afw_object_add_reference(object, xctx);
338  apr_hash_set(ht, id->s, id->len, object);
339 }
340 
341 
342 /* Set a list of object pointers in the xctx's runtime objects. */
343 AFW_DEFINE(void)
345  const afw_object_t * const * objects, afw_boolean_t overwrite,
346  afw_xctx_t *xctx)
347 {
348  for (; *objects; objects++) {
349  afw_runtime_xctx_set_object(*objects, overwrite, xctx);
350  }
351 }
352 
353 
354 /* Register runtime object map interfaces. */
355 AFW_DEFINE(void)
357  const afw_object_inf_t * const * inf,
358  afw_xctx_t *xctx)
359 {
360  const afw_runtime_object_type_meta_t *meta;
361 
362  /* Register all maps interfaces. */
363  for (; *inf; inf++) {
364  meta = (*inf)->rti.implementation_specific;
366  meta->object_type_id, *inf, xctx);
367  }
368 }
369 
370 
371 /* Create and register runtime object map interfaces. */
372 AFW_DEFINE(void)
374  const afw_interface_implementation_rti_t * const * rti,
375  afw_xctx_t *xctx)
376 {
377  const afw_pool_t *p = xctx->env->p;
378  afw_object_inf_t *inf;
379  const afw_runtime_object_type_meta_t *unresolved_meta;
382  const afw_runtime_object_map_property_t *unresolved_properties;
384  afw_size_t count;
385 
386  /* Register all map interfaces. */
387  for (; *rti; rti++) {
388 
389  /* Model inf after afw_runtime_inf_const_embedded_untyped_object */
390  inf = afw_pool_calloc_type(p, afw_object_inf_t, xctx);
391  afw_memory_copy(inf, &afw_runtime_inf_const_embedded_untyped_object);
392  afw_memory_copy(&inf->rti, *rti);
393 
394  /* Resolve meta. */
395  unresolved_meta = (*rti)->implementation_specific;
397  xctx);
398  inf->rti.implementation_specific = meta;
399  afw_memory_copy(meta, unresolved_meta);
400 
401  /* Resolve object map. */
402  if (meta->property_map && meta->property_map->property_count > 0) {
404  memcpy(map, meta->property_map, sizeof(afw_runtime_object_map_t));
405  meta->property_map = map;
406 
407  unresolved_properties = map->properties;
408  properties = afw_pool_calloc(p,
410  map->property_count, xctx);
411  map->properties = properties;
412  memcpy(properties, unresolved_properties,
414  map->property_count);
415 
416  for (count = map->property_count; count > 0; count--, properties++)
417  {
418  properties->data_type =
420  properties->unresolved_data_type_id, xctx);
421  if (properties->unresolved_data_type_parameter_data_type_id) {
422  properties->data_type_parameter_data_type =
424  properties->unresolved_data_type_parameter_data_type_id, xctx);
425  }
426  if (!properties->accessor) {
427  properties->accessor =
429  properties->accessor_name, xctx);
430  }
431  if (!properties->data_type || !properties->accessor)
432  {
433  AFW_THROW_ERROR_FZ(general, xctx,
434  "Error resolving runtime object map %" AFW_UTF8_FMT,
436  }
437  }
438  }
439 
440  /* Register inf. */
442  meta->object_type_id, inf, xctx);
443  }
444 }
445 
446 
447 /* Create an indirect runtime object using a know inf. */
448 AFW_DEFINE(const afw_object_t *)
450  const afw_object_inf_t *inf,
451  const afw_utf8_t *object_id,
452  void * internal,
453  const afw_pool_t *p,
454  afw_xctx_t *xctx)
455 {
456  const afw_runtime_object_type_meta_t *meta;
458 
459  /* Get object id. */
460  meta = inf->rti.implementation_specific;
461 
462  /* Make an indirect object. */
464  xctx);
465  obj->pub.inf = inf;
466  obj->pub.p = p;
467  obj->pub.meta.id = object_id;
468  obj->pub.meta.object_type_uri = meta->object_type_id;
469  obj->pub.meta.object_uri = afw_object_path_make(
470  &afw_s_afw, meta->object_type_id, object_id,
471  p, xctx);
472  obj->internal = internal;
473 
474  /* Return object. */
475  return (const afw_object_t *)obj;
476 }
477 
478 
479 /* Create and set an indirect runtime object. */
480 AFW_DEFINE(const afw_object_t *)
482  const afw_utf8_t *object_type_id,
483  const afw_utf8_t *object_id,
484  void * internal,
485  const afw_pool_t *p,
486  afw_xctx_t *xctx)
487 {
488  const afw_object_inf_t *inf;
489 
490  /* Get inf associated with object type. */
492  object_type_id, xctx);
493  if (!inf) {
494  AFW_THROW_ERROR_FZ(general, xctx,
495  "Runtime object map %" AFW_UTF8_FMT " is not registered",
496  AFW_UTF8_FMT_ARG(object_type_id));
497  }
498 
500  object_id, internal, p, xctx);
501 }
502 
503 
504 
505 /* Create and set an indirect runtime object using a know inf. */
506 AFW_DEFINE(void)
508  const afw_object_inf_t *inf,
509  const afw_utf8_t *object_id,
510  void * internal,
511  afw_boolean_t overwrite,
512  afw_xctx_t *xctx)
513 {
514  const afw_object_t *obj;
515 
516  /* Create runtime object. */
518  internal, xctx->env->p, xctx);
519 
520  /* Set it as a runtime object. */
521  afw_runtime_env_set_object(obj, overwrite, xctx);
522 }
523 
524 
525 
526 /* Create and set an indirect runtime object in environment. */
527 AFW_DEFINE(void)
529  const afw_utf8_t *object_type_id,
530  const afw_utf8_t *object_id,
531  void * internal,
532  afw_boolean_t overwrite,
533  afw_xctx_t *xctx)
534 {
535  const afw_object_t *obj;
536 
537  /* Create runtime object. */
538  obj = afw_runtime_object_create_indirect(object_type_id, object_id,
539  internal, xctx->env->p, xctx);
540 
541  /* Set it as a runtime object. */
542  afw_runtime_env_set_object(obj, overwrite, xctx);
543 }
544 
545 
546 
547 static const afw_object_t *
548 impl_resolve_untyped_object(
550  const afw_object_t *embedding_object,
551  const afw_utf8_t *property_name,
552  const afw_pool_t *p, afw_xctx_t *xctx)
553 {
554 
556  const afw_list_t *parent_paths;
557  const afw_object_t *delta;
558 
559  resolved = afw_pool_calloc_type(p,
561  resolved->pub.inf = &afw_runtime_inf_const_embedded_untyped_object;
562  resolved->pub.p = p;
563  resolved->pub.meta.embedding_object = embedding_object;
564  resolved->pub.meta.id = property_name;
565 
566  resolved->properties =
567  impl_resolve_properties(unresolved->properties, embedding_object,
568  p, xctx);
569 
570  if (unresolved->parent_paths) {
572  (const afw_object_t *)resolved, xctx);
573  parent_paths = afw_list_create_wrapper_for_array(
574  (const void *)unresolved->parent_paths, false,
576  p, xctx);
578  &afw_s_parentPaths, parent_paths, xctx);
579  }
580 
581  return (const afw_object_t *)resolved;
582 }
583 
584 
585 static const afw_list_t *
586 impl_resolve_list(
587  const afw_runtime_unresolved_const_list_t *unresolved,
588  const afw_pool_t *p,
589  afw_xctx_t *xctx)
590 {
591  const afw_data_type_t *data_type;
592  const afw_list_t *result;
593 
594  data_type = afw_environment_get_data_type(&unresolved->data_type_id, xctx);
595  if (!data_type) {
596  AFW_THROW_ERROR_Z(general, "Unsupported data type", xctx);
597  }
598 
599  result = afw_list_create_wrapper_for_array(unresolved->array,
600  false, data_type, unresolved->count, p, xctx);
601  return result;
602 }
603 
604 
605 static const afw_runtime_property_t *
606 impl_resolve_property(
607  const afw_runtime_unresolved_property_t *unresolved,
608  const afw_object_t *embedding_object,
609  const afw_pool_t *p,
610  afw_xctx_t *xctx)
611 {
612  afw_runtime_property_t *resolved;
613  const afw_object_t *object;
614  const afw_list_t *list;
615  const afw_utf8_t *string;
616  const afw_utf8_t *name;
617 
618  resolved = afw_pool_calloc_type(p, afw_runtime_property_t, xctx);
619  resolved->name = afw_utf8_from_utf8_z(unresolved->name, p, xctx);
620 
621  switch (unresolved->value.type) {
622 
624  resolved->value = (unresolved->value.boolean)
626  : afw_value_false;
627  break;
628 
630  resolved->value = afw_value_create_double(
631  unresolved->value.number, p, xctx);
632  break;
633 
635  resolved->value = afw_value_create_integer(
636  unresolved->value.integer, p, xctx);
637  break;
638 
640  list = impl_resolve_list(unresolved->value.list, p, xctx);
641  resolved->value = afw_value_create_list(list, p, xctx);
642  break;
643 
645  name = afw_utf8_create(unresolved->name, -1, p, xctx);
646  object = impl_resolve_untyped_object(unresolved->value.object,
647  embedding_object, name, p, xctx);
648  resolved->value = afw_value_create_object(object, p, xctx);
649  break;
650 
652  string = afw_utf8_from_utf8_z(unresolved->value.string, p, xctx);
653  resolved->value = afw_value_create_string(string, p, xctx);
654  break;
655 
656  default:
657  AFW_THROW_ERROR_Z(general, "Unexpected type", xctx);
658  }
659 
660  return resolved;
661 }
662 
663 
664 
665 static const afw_runtime_property_t * const *
666 impl_resolve_properties(
667  const afw_runtime_unresolved_property_t * const * properties,
668  const afw_object_t *embedding_object,
669  const afw_pool_t *p,
670  afw_xctx_t *xctx)
671 {
672  afw_size_t count;
673  const afw_runtime_property_t * * resolved;
674  const afw_runtime_property_t * const * result;
675  const afw_runtime_unresolved_property_t * const *unresolved;
676 
677  /* Count properties. */
678  for (count = 0, unresolved = properties;
679  *unresolved; count++, unresolved++);
680 
681  /* Create list of resolved properties. */
682  resolved = afw_pool_malloc(p,
683  (count + 1) * sizeof(afw_runtime_property_t *), xctx);
684  result = resolved;
685  for (unresolved = properties; *unresolved; unresolved++)
686  {
687  *resolved++ = impl_resolve_property(*unresolved, embedding_object,
688  p, xctx);
689  }
690  *resolved++ = NULL;
691 
692  /* Return resolved properties. */
693  return result;
694 }
695 
696 
697 /*
698  * Resolve a runtime const object.
699  */
700 AFW_DEFINE(const afw_object_t *)
702  const afw_runtime_unresolved_const_object_t *unresolved,
703  const afw_pool_t *p,
704  afw_xctx_t *xctx)
705 {
707  afw_value_list_t *parent_paths;
708 
709  /* Allocate memory for const object. */
710  o = afw_pool_calloc_type(p,
712  o->pub.p = p;
713 
714  /* Get interface for object. */
716  unresolved->object_type_id, xctx);
717  if (!o->pub.inf) {
718  AFW_THROW_ERROR_FZ(general, xctx,
719  "No map available for object type %" AFW_UTF8_FMT,
720  AFW_UTF8_FMT_ARG(unresolved->object_type_id));
721  }
722 
723  /* Copy id and paths. */
724  o->pub.meta.id = unresolved->object_id;
725  o->pub.meta.object_type_uri = unresolved->object_type_id;
726  o->pub.meta.object_uri = unresolved->path;
727 
728  if (unresolved->parent_path.len > 0) {
729  parent_paths = afw_value_allocate_list(p, xctx);
730  parent_paths->internal = afw_list_create_wrapper_for_array(
731  (const void *)&unresolved->parent_path, false,
732  afw_data_type_anyURI, 1, p, xctx);
734  parent_paths, xctx);
735  }
736 
737  o->properties = impl_resolve_properties(unresolved->properties,
738  (const afw_object_t *)o, p, xctx);
739 
740  /* Return object. */
741  return (afw_object_t *)o;
742 }
743 
744 
745 /*
746  * Resolve and set a NULL terminated list of object pointers in the
747  * xctx's runtime objects.
748  */
749 AFW_DEFINE(void)
751  const afw_runtime_unresolved_const_object_t * const * unresolved,
752  afw_boolean_t overwrite, afw_xctx_t *xctx)
753 {
754  const afw_object_t *obj;
755  const afw_pool_t *p = xctx->env->p;
756 
757  for (; *unresolved; unresolved++) {
758  obj = afw_runtime_resolve_const_object(*unresolved,
759  p, xctx);
760  afw_runtime_env_set_object(obj, false, xctx);
761  }
762 }
763 
764 
765 
766 typedef struct {
767  const afw_utf8_t *object_type_id;
768  const afw_utf8_t *object_id;
770 
771 
772 
773 static afw_boolean_t
774 impl_check_manifest_cb(
775  const afw_object_t *object,
776  void *context,
777  afw_xctx_t *xctx)
778 {
779  const afw_value_t *providesObjects_value;
780  const afw_utf8_t *extension_id;
781  const afw_utf8_t *module_path;
782  const afw_utf8_t *entry;
783  const afw_iterator_t *iterator;
784  const afw_list_t *list;
785  impl_check_manifest_cb_context_t *ctx = context;
786  afw_utf8_t s;
787 
788  if (!object) {
789  return false;
790  }
791 
792  providesObjects_value = afw_object_get_property(object, &afw_s_providesObjects, xctx);
793  if (!providesObjects_value) {
794  return false;
795  }
796 
797  if (!afw_value_is_list_of_string(providesObjects_value) &&
798  !afw_value_is_list_of_anyURI(providesObjects_value))
799  {
800  return false;
801  }
802 
803  /* Loop through entries. */
804  list = ((const afw_value_list_t *)providesObjects_value)->internal;
805  for (iterator = NULL;;)
806  {
807  afw_list_get_next_internal(list, &iterator, NULL,
808  (const void **)&entry, xctx);
809  if (!entry) {
810  break;
811  }
812 
813  /* Check for entry match. */
814  if (!afw_utf8_starts_with_z(entry, "/afw/")) {
815  continue;
816  }
817  s.s = entry->s + 5;
818  s.len = entry->len - 5;
819  if (!afw_utf8_starts_with(&s, ctx->object_type_id)) {
820  continue;
821  }
822  s.s = s.s + ctx->object_type_id->len;
823  s.len = s.len - ctx->object_type_id->len;
824  if (s.len == 0 || *(s.s) != '/') {
825  continue;
826  }
827  s.s++;
828  s.len--;
829  if (!afw_utf8_equal(&s, ctx->object_id)) {
830  continue;
831  }
832 
833  /* If extension provides object, load extension and break. */
834  extension_id = afw_object_old_get_property_as_string(object,
835  &afw_s_extensionId, xctx);
836  module_path = afw_object_old_get_property_as_string(object,
837  &afw_s_modulePath, xctx);
838  if (extension_id && module_path) {
839  afw_environment_load_extension(extension_id, module_path,
840  NULL, xctx);
841  /*Return indicating complete. */
842  return true;
843  }
844  }
845 
846  /* Return indicating not to short circuit */
847  return false;
848 }
849 
850 
851 /* Get a runtime object. */
852 AFW_DEFINE(const afw_object_t *)
854  const afw_utf8_t *object_type_id, const afw_utf8_t *object_id,
855  afw_xctx_t *xctx)
856 {
857  const afw_object_t *result;
858  const afw_xctx_t *c;
859  apr_hash_t *ht;
861 
862  result = NULL;
863  for (c = xctx; c; c = c->parent) {
864  if (c->runtime_objects && c->runtime_objects->types_ht) {
865  ht = apr_hash_get(c->runtime_objects->types_ht,
866  object_type_id->s, object_type_id->len);
867  if (ht) {
868  result = impl_get_object(ht, object_id->s, object_id->len,
869  xctx);
870  if (result) break;
871  }
872  }
873  }
874 
875  if (!result) {
876  ctx.object_type_id = object_type_id;
877  ctx.object_id = object_id;
878  afw_runtime_foreach(&afw_s__AdaptiveManifest_,
879  &ctx, impl_check_manifest_cb, xctx);
880  for (c = xctx; c; c = c->parent) {
881  if (c->runtime_objects && c->runtime_objects->types_ht) {
882  ht = apr_hash_get(c->runtime_objects->types_ht,
883  object_type_id->s, object_type_id->len);
884  if (ht) {
885  result = impl_get_object(ht, object_id->s, object_id->len,
886  xctx);
887  if (result) break;
888  }
889  }
890  }
891  }
892 
893  if (result) afw_object_add_reference(result, xctx);
894  return result;
895 }
896 
897 
898 /* Call a callback for each runtime object. */
899 AFW_DEFINE(void)
901  const afw_utf8_t *object_type_id,
902  void *context, afw_object_cb_t callback,
903  afw_xctx_t *xctx)
904 {
905  /*
906  * Function impl_afw_adaptor_session_retrieve_objects() can accept NULL
907  * session instance for a session-less retrieve.
908  */
910  object_type_id, NULL, context, callback, NULL, xctx->p, xctx);
911 }
912 
913 
916 {
917  return &impl_factory;
918 }
919 
920 
921 /*
922  * Implementation of method create_adaptor_cede_p of interface afw_adaptor_factory.
923  */
924 const afw_adaptor_t *
925 impl_afw_adaptor_factory_create_adaptor_cede_p (
926  const afw_adaptor_factory_t * instance,
927  const afw_object_t * properties,
928  const afw_pool_t * p,
929  afw_xctx_t *xctx)
930 {
931  afw_adaptor_t *adaptor;
932 
934  &impl_afw_adaptor_inf,
935  sizeof(impl_afw_adaptor_self_t), properties, p, xctx);
936 
937  /* If this is afw adaptor, remember it in environment. */
938  if (afw_utf8_equal(&adaptor->adaptor_id, &afw_s_afw)) {
939  ((afw_environment_t*)xctx->env)->afw_adaptor = adaptor;
940  }
941 
942  return adaptor;
943 }
944 
945 
946 /*
947  * Implementation of method destroy of interface afw_adaptor.
948  */
949 void
951  const afw_adaptor_t * instance,
952  afw_xctx_t *xctx)
953 {
954  /* Release pool. */
955  afw_pool_release(instance->p, xctx);
956 }
957 
958 
959 /* Get an internal session for runtime objects. */
962 {
963  return impl_afw_adaptor_create_adaptor_session(NULL, xctx);
964 }
965 
966 
967 /*
968  * Implementation of method create_adaptor_session of interface afw_adaptor.
969  */
970 const afw_adaptor_session_t *
972  const afw_adaptor_t * instance,
973  afw_xctx_t *xctx)
974 {
976  const afw_pool_t *session_p;
977 
978  session_p = afw_pool_create(xctx->p, xctx);;
979  self = afw_pool_calloc_type(session_p, impl_afw_adaptor_session_self_t, xctx);
980  self->pub.inf = &impl_afw_adaptor_session_inf;
981  self->pub.adaptor = instance;
982  self->pub.p = session_p;
983 
984  return (const afw_adaptor_session_t *)self;
985 }
986 
987 
988 /*
989  * Implementation of method get_additional_metrics of interface afw_adaptor.
990  */
991 const afw_object_t *
993  const afw_adaptor_t * instance,
994  const afw_pool_t * p,
995  afw_xctx_t *xctx)
996 {
997  /* There are no adaptor specific metrics. */
998  return NULL;
999 }
1000 
1001 
1002 /* ----------------- Runtime adaptor session implementation ---------------- */
1003 
1004 /*
1005  * Implementation of method destroy of interface afw_adaptor_session.
1006  */
1007 void
1009  const afw_adaptor_session_t * instance,
1010  afw_xctx_t *xctx)
1011 {
1012  /* Assign instance pointer to self. */
1014  (impl_afw_adaptor_session_self_t *)instance;
1015 
1016  /* Release pool. */
1017  afw_pool_release(self->pub.p, xctx);
1018 }
1019 
1020 
1021 
1022 /*
1023  * Implementation of method retrieve_objects of interface afw_adaptor_session.
1024  *
1025  * This function is also called by afw_runtime_foreach() with a NULL session
1026  * instance. In this case, custom handled object types are not supported.
1027  */
1028 void
1030  const afw_adaptor_session_t *instance,
1031  const afw_adaptor_impl_request_t *impl_request,
1032  const afw_utf8_t *object_type_id,
1033  const afw_query_criteria_t *criteria,
1034  void *context,
1035  afw_object_cb_t callback,
1036  const afw_object_t *adaptor_type_specific,
1037  const afw_pool_t *p,
1038  afw_xctx_t *xctx)
1039 {
1040  const afw_object_t *obj;
1041  const afw_xctx_t *c;
1042  apr_hash_t *ht;
1043  apr_pool_t *apr_p;
1044  apr_hash_index_t *hi;
1045  const afw_runtime_custom_t *custom;
1046  const impl_ht_object_entry *entry;
1047 
1048  /* If this is a custom handled object type, call its function and return. */
1049  if (instance) {
1050  custom = afw_environment_get_runtime_custom(object_type_id, xctx);
1051  if (custom) {
1052  custom->retrieve_objects(instance, impl_request,
1053  object_type_id, criteria,
1054  context, callback, NULL, p, xctx);
1055  return;
1056  }
1057  }
1058 
1059  /* Call callback with all applicable set runtime objects. */
1060  apr_p = afw_pool_get_apr_pool(p);
1061  for (c = xctx; c; c = c->parent) {
1062  if (c->runtime_objects && c->runtime_objects->types_ht) {
1063  ht = apr_hash_get(c->runtime_objects->types_ht,
1064  object_type_id->s, object_type_id->len);
1065  if (ht) {
1066  for (hi = apr_hash_first(apr_p, ht); hi;
1067  hi = apr_hash_next(hi))
1068  {
1069  apr_hash_this(hi, NULL, NULL, (void **)&entry);
1070  obj = impl_entry_to_object(entry, xctx);
1072  criteria, p, xctx))
1073  {
1074  /* If complete, short circuit retrieve and return. */
1075  if (callback(obj, context, xctx)) {
1076  return;
1077  }
1078  }
1079  }
1080  }
1081  }
1082  }
1083 
1084  /* Call callback one last time with NULL object pointer. */
1085  callback(NULL, context, xctx);
1086 }
1087 
1088 
1089 
1090 /*
1091  * Implementation of method get_object for interface afw_adaptor_session.
1092  */
1093 void
1095  const afw_adaptor_session_t *instance,
1096  const afw_adaptor_impl_request_t *impl_request,
1097  const afw_utf8_t *object_type_id,
1098  const afw_utf8_t *object_id,
1099  void *context,
1100  afw_object_cb_t callback,
1101  const afw_object_t *adaptor_type_specific,
1102  const afw_pool_t *p,
1103  afw_xctx_t *xctx)
1104 {
1105  const afw_object_t *object;
1106  const afw_runtime_custom_t *custom;
1107 
1108  /* If this is a custom handled object type, call its function and return. */
1109  custom = afw_environment_get_runtime_custom(object_type_id, xctx);
1110  if (custom) {
1111  custom->get_object(instance, impl_request,
1112  object_type_id, object_id,
1113  context, callback, adaptor_type_specific, p, xctx);
1114  return;
1115  }
1116 
1117  /* Call callback with object. */
1118  object = afw_runtime_get_object(object_type_id, object_id, xctx);
1119  if (object) afw_object_add_reference(object, xctx);
1120 
1121  callback(object, context, xctx);
1122 }
1123 
1124 
1125 
1126 /*
1127  * Implementation of method add_object for interface afw_adaptor_session.
1128  */
1129 const afw_utf8_t *
1131  const afw_adaptor_session_t *instance,
1132  const afw_adaptor_impl_request_t *impl_request,
1133  const afw_utf8_t *object_type_id,
1134  const afw_utf8_t *suggested_object_id,
1135  const afw_object_t *object,
1136  const afw_object_t *adaptor_type_specific,
1137  afw_xctx_t *xctx)
1138 {
1139  AFW_ADAPTOR_IMPL_ERROR_ADAPTOR_IMMUTABLE;
1140 }
1141 
1142 
1143 
1144 /*
1145  * Implementation of method modify_object for interface afw_adaptor_session.
1146  */
1147 void
1149  const afw_adaptor_session_t *instance,
1150  const afw_adaptor_impl_request_t *impl_request,
1151  const afw_utf8_t *object_type_id,
1152  const afw_utf8_t *object_id,
1153  const afw_adaptor_modify_entry_t *const *entry,
1154  const afw_object_t *adaptor_type_specific,
1155  afw_xctx_t *xctx)
1156 {
1157  AFW_ADAPTOR_IMPL_ERROR_ADAPTOR_IMMUTABLE;
1158 }
1159 
1160 
1161 
1162 /*
1163  * Implementation of method replace_object for interface afw_adaptor_session.
1164  */
1165 void
1167  const afw_adaptor_session_t *instance,
1168  const afw_adaptor_impl_request_t *impl_request,
1169  const afw_utf8_t *object_type_id,
1170  const afw_utf8_t *object_id,
1171  const afw_object_t *replacement_object,
1172  const afw_object_t *adaptor_type_specific,
1173  afw_xctx_t *xctx)
1174 {
1175  AFW_ADAPTOR_IMPL_ERROR_ADAPTOR_IMMUTABLE;
1176 }
1177 
1178 
1179 
1180 /*
1181  * Implementation of method delete_object for interface afw_adaptor_session.
1182  */
1183 void
1185  const afw_adaptor_session_t *instance,
1186  const afw_adaptor_impl_request_t *impl_request,
1187  const afw_utf8_t *object_type_id,
1188  const afw_utf8_t *object_id,
1189  const afw_object_t *adaptor_type_specific,
1190  afw_xctx_t *xctx)
1191 {
1192 
1193  AFW_ADAPTOR_IMPL_ERROR_ADAPTOR_IMMUTABLE;
1194 }
1195 
1196 
1197 
1198 /*
1199  * Implementation of method begin_transaction of interface afw_adaptor_session.
1200  */
1203  const afw_adaptor_session_t * instance,
1204  afw_xctx_t *xctx)
1205 {
1206  /* No transaction support. */
1207  return NULL;
1208 }
1209 
1210 
1211 
1212 /*
1213  * Implementation of method get_journal_interface of interface afw_adaptor_session.
1214  */
1215 const afw_adaptor_journal_t *
1216 impl_afw_adaptor_session_get_journal_interface (
1217  const afw_adaptor_session_t * instance,
1218  afw_xctx_t *xctx)
1219 {
1220  /* No journal support. */
1221  return NULL;
1222 }
1223 
1224 
1225 
1226 /*
1227  * Implementation of method get_key_value_interface of interface afw_adaptor_session.
1228  */
1231  const afw_adaptor_session_t * instance,
1232  afw_xctx_t *xctx)
1233 {
1234  /* No key support. */
1235  return NULL;
1236 }
1237 
1238 
1239 
1240 /*
1241  * Implementation of method get_index_interface of interface afw_adaptor_session.
1242  */
1245  const afw_adaptor_session_t * instance,
1246  afw_xctx_t *xctx)
1247 {
1248  /* No index support. */
1249  return NULL;
1250 }
1251 
1252 
1253 /*
1254  * Implementation of method get_object_type_cache_interface for interface
1255  * afw_adaptor_session.
1256  */
1258 impl_afw_adaptor_session_get_object_type_cache_interface(
1259  const afw_adaptor_session_t * instance,
1260  afw_xctx_t *xctx)
1261 {
1263  (impl_afw_adaptor_session_self_t *)instance;
1264 
1266  &self->object_type_cache,
1268  instance, true, xctx);
1269 
1270  return &self->object_type_cache;
1271 }
1272 
1273 
1274 /* ----------------- Object implementation ----------------------- */
1275 
1276 typedef struct impl_runtime_iterator_s {
1277  const afw_runtime_object_map_property_t *map_entry;
1278  const afw_runtime_property_t ** extra_prop;
1280 
1281 /* Find map entry for property. */
1282 static const afw_value_t *
1283 impl_make_value_from_map_entry(
1284  const afw_object_t *instance,
1286  afw_xctx_t *xctx)
1287 {
1288  const afw_runtime_object_type_meta_t *meta;
1289  const char * internal;
1290 
1291  meta = instance->inf->rti.implementation_specific;
1292 
1293  if (prop->offset == -1) {
1294  return prop->accessor(prop,
1295  (const void *)
1296  ((const afw_runtime_object_indirect_t *)instance)->internal,
1297  xctx->p, xctx);
1298  }
1299  else {
1300  internal = (const char *)
1301  ((meta->indirect)
1302  ? ((const afw_runtime_object_indirect_t *)instance)->internal
1303  : instance);
1304  return prop->accessor(prop, (const void *)(internal + prop->offset),
1305  xctx->p, xctx);
1306  }
1307 }
1308 
1309 
1310 
1311 /*
1312  * Implementation of method release of interface afw_object.
1313  */
1314 void
1316  const afw_object_t * instance,
1317  afw_xctx_t *xctx)
1318 {
1320 }
1321 
1322 
1323 
1324 /*
1325  * Implementation of method add_reference of interface afw_object.
1326  */
1327 void
1329  const afw_object_t * instance,
1330  afw_xctx_t *xctx)
1331 {
1333 }
1334 
1335 
1336 
1337 /*
1338  * Implementation of method get_count for interface afw_object.
1339  */
1340 afw_size_t
1342  const afw_object_t * instance,
1343  afw_xctx_t * xctx)
1344 {
1345 // <afwdev {prefixed_interface_name}>_self_t *self =
1346 // (<afwdev {prefixed_interface_name}>_self_t *)instance;
1347 
1349  AFW_THROW_ERROR_Z(general, "Method not implemented.", xctx);
1350 
1351 }
1352 
1353 
1354 
1355 /*
1356  * Implementation of method get_object_type_id of interface afw_object.
1357  */
1358 const afw_utf8_t *
1360  const afw_object_t * instance,
1361  afw_xctx_t *xctx)
1362 {
1363  const afw_runtime_object_type_meta_t *meta;
1364 
1365  meta = instance->inf->rti.implementation_specific;
1366 
1367  return (meta) ? meta->object_type_id : NULL;
1368 }
1369 
1370 
1371 
1372 /*
1373  * Implementation of method get_property of interface afw_object.
1374  */
1375 const afw_value_t *
1377  const afw_object_t * instance,
1378  const afw_utf8_t * property_name,
1379  afw_xctx_t *xctx)
1380 {
1382  const afw_runtime_property_t **more;
1383  afw_size_t count;
1384  const afw_runtime_object_type_meta_t *meta;
1385  const char * internal;
1386 
1387  meta = instance->inf->rti.implementation_specific;
1388 
1389  /* Search for property and return it if found. */
1390  if (meta->property_map) {
1391  for (prop = meta->property_map->properties,
1392  count = meta->property_map->property_count;
1393  count > 0;
1394  prop++, count--)
1395  {
1396  if (afw_utf8_equal(property_name, prop->name)) {
1397  return impl_make_value_from_map_entry(instance, prop, xctx);
1398  }
1399  }
1400  }
1401 
1402  /* Search unmapped properties. */
1403  internal = (const char *)
1404  ((meta->indirect)
1405  ? ((const afw_runtime_object_indirect_t *)instance)->internal
1406  : instance);
1407  more = (const afw_runtime_property_t **)
1408  ((meta->properties_offset != -1)
1409  ? *((const afw_runtime_property_t **)
1410  (internal + meta->properties_offset))
1411  : NULL);
1412 
1413  if (more) {
1414  for (; *more; more++) {
1415  if (afw_utf8_equal(property_name, (*more)->name)) {
1416  return (*more)->value;
1417  }
1418  }
1419  }
1420 
1421  /* Return NULL if not found. */
1422  return NULL;
1423 }
1424 
1425 
1426 
1427 /*
1428  * Implementation of method get_meta for interface afw_object.
1429  */
1430 const afw_value_t *
1432  const afw_object_t *instance,
1433  const afw_pool_t *p,
1434  afw_xctx_t *xctx)
1435 {
1437  instance, p, xctx);
1438 }
1439 
1440 
1441 
1442 /*
1443  * Implementation of method get_property_meta for interface afw_object.
1444  */
1445 const afw_value_t *
1447  const afw_object_t *instance,
1448  const afw_utf8_t *property_name,
1449  const afw_pool_t *p,
1450  afw_xctx_t *xctx)
1451 {
1453  instance, property_name, p, xctx);
1454 }
1455 
1456 
1457 
1458 /*
1459  * Implementation of method get_next_property of interface afw_object.
1460  */
1461 const afw_value_t *
1463  const afw_object_t * instance,
1464  const afw_iterator_t * * iterator,
1465  const afw_utf8_t * * property_name,
1466  afw_xctx_t *xctx)
1467 {
1468  const afw_runtime_object_map_property_t *map_entry;
1469  const afw_value_t *result;
1471  const afw_runtime_object_type_meta_t *meta;
1472  const char * internal;
1473 
1474  meta = instance->inf->rti.implementation_specific;
1475 
1476  /* If iterator is not NULL, it point to last property pointer. */
1477  if (*iterator) {
1478  i = (impl_runtime_iterator_t *)*iterator;
1479  }
1480  else {
1482  *iterator = (afw_iterator_t *)i;
1483  i->map_entry = (meta->property_map)
1484  ? meta->property_map->properties
1485  : NULL;
1486  }
1487 
1488  /*
1489  prop = *(const afw_runtime_object_map_property_t **)iterator;
1490  }
1491  / * If iterator is NULL, start from beginning. * /
1492  else {
1493  prop = self->property_map->properties;
1494  }*/
1495 
1496  do {
1497  if (!i->extra_prop) {
1498 
1499  if (i->map_entry &&
1500  i->map_entry < meta->property_map->properties +
1501  meta->property_map->property_count)
1502  {
1503  map_entry = i->map_entry;
1504  (i->map_entry)++;
1505  *property_name = map_entry->name;
1506  result = impl_make_value_from_map_entry(instance, map_entry,
1507  xctx);
1508  if (result) break;
1509  continue;
1510  }
1511 
1512  internal = (const char *)
1513  ((meta->indirect)
1514  ? ((const afw_runtime_object_indirect_t *)instance)->internal
1515  : instance);
1516  i->extra_prop = (const afw_runtime_property_t **)
1517  ((meta->properties_offset != -1)
1518  ? *((const afw_runtime_property_t **)
1519  (internal + meta->properties_offset))
1520  : NULL);
1521  }
1522 
1523  if (i->extra_prop && *(i->extra_prop)) {
1524  result = (*(i->extra_prop))->value;
1525  *property_name = (*(i->extra_prop))->name;
1526  (i->extra_prop)++;
1527  break;
1528  }
1529 
1530  *iterator = NULL;
1531  *property_name = NULL;
1532  result = NULL;
1533  break;
1534 
1535  } while (1);
1536 
1537  return result;
1538 }
1539 
1540 
1541 
1542 /*
1543  * Implementation of method get_next_property_meta for interface afw_object.
1544  */
1545 const afw_value_t *
1547  const afw_object_t *instance,
1548  const afw_iterator_t **iterator,
1549  const afw_utf8_t **property_name,
1550  const afw_pool_t *p,
1551  afw_xctx_t *xctx)
1552 {
1554  instance, iterator, property_name, p, xctx);
1555 }
1556 
1557 
1558 /*
1559  * Implementation of method has_property of interface afw_object.
1560  */
1563  const afw_object_t * instance,
1564  const afw_utf8_t * property_name,
1565  afw_xctx_t *xctx)
1566 {
1567  /* Use impl_get_own_property() to determine if property exists. */
1568  return afw_runtime_object_get_property(instance, property_name, xctx)
1569  ? AFW_TRUE
1570  : AFW_FALSE;
1571 }
1572 
1573 
1574 
1575 /*
1576  * Implementation of method get_setter of interface afw_object.
1577  */
1578 const afw_object_setter_t *
1580  const afw_object_t * instance,
1581  afw_xctx_t *xctx)
1582 {
1583  return NULL;
1584 }
Interface afw_interface implementation declares.
Interface afw_interface implementation declares.
AFW_DEFINE(const afw_object_t *)
Interface afw_interface implementation declares.
Adaptive Framework Core Internal.
const afw_object_t * impl_afw_adaptor_get_additional_metrics(const afw_adaptor_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
Definition: afw_runtime.c:992
void impl_afw_adaptor_destroy(const afw_adaptor_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:950
const afw_adaptor_session_t * impl_afw_adaptor_create_adaptor_session(const afw_adaptor_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:971
afw_adaptor_impl_object_type_cache_initialize(afw_adaptor_object_type_cache_t *object_type_cache, const afw_adaptor_object_type_cache_inf_t *inf, const afw_adaptor_session_t *session, afw_boolean_t all_object_types_immutable, afw_xctx_t *xctx)
Initialize object type cache instance.
afw_adaptor_impl_create_cede_p(const afw_adaptor_inf_t *inf, afw_size_t instance_size, const afw_object_t *properties, const afw_pool_t *p, afw_xctx_t *xctx)
Developers should call this in all create functions for afw_adaptor.
afw_adaptor_impl_object_type_cache_inf
inf for an implementation of afw_adaptor_object_type_cache.
void impl_afw_adaptor_session_modify_object(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_adaptor_modify_entry_t *const *entry, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Definition: afw_runtime.c:1148
void impl_afw_adaptor_session_replace_object(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_t *replacement_object, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Definition: afw_runtime.c:1166
void impl_afw_adaptor_session_delete_object(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Definition: afw_runtime.c:1184
void impl_afw_adaptor_session_retrieve_objects(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_query_criteria_t *criteria, void *context, afw_object_cb_t callback, const afw_object_t *adaptor_type_specific, const afw_pool_t *p, afw_xctx_t *xctx)
Definition: afw_runtime.c:1029
const afw_adaptor_transaction_t * impl_afw_adaptor_session_begin_transaction(const afw_adaptor_session_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:1202
void impl_afw_adaptor_session_destroy(const afw_adaptor_session_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:1008
const afw_adaptor_impl_index_t * impl_afw_adaptor_session_get_index_interface(const afw_adaptor_session_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:1244
const afw_utf8_t * impl_afw_adaptor_session_add_object(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_utf8_t *suggested_object_id, const afw_object_t *object, const afw_object_t *adaptor_type_specific, afw_xctx_t *xctx)
Definition: afw_runtime.c:1130
void impl_afw_adaptor_session_get_object(const afw_adaptor_session_t *instance, const afw_adaptor_impl_request_t *impl_request, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, void *context, afw_object_cb_t callback, const afw_object_t *adaptor_type_specific, const afw_pool_t *p, afw_xctx_t *xctx)
Definition: afw_runtime.c:1094
const afw_adaptor_key_value_t * impl_afw_adaptor_session_get_key_value_interface(const afw_adaptor_session_t *instance, afw_xctx_t *xctx)
Definition: afw_runtime.c:1230
afw_data_type_anyURI
Data type struct for anyURI.
#define afw_value_is_list_of_anyURI(A_VALUE)
Macro to determine if value is evaluated list of anyURI.
afw_value_create_double(double internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type double value.
afw_value_create_integer(afw_integer_t internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type integer value.
afw_value_create_list(const afw_list_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type list value.
afw_value_allocate_list(const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for unmanaged data type list value.
afw_object_set_property_as_list(const afw_object_t *object, const afw_utf8_t *property_name, const afw_list_t *internal, afw_xctx_t *xctx)
Set property function for data type list values.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define afw_object_old_get_property_as_string(object, property_name, xctx)
Get property function for data type string value.
#define afw_value_is_list_of_string(A_VALUE)
Macro to determine if value is evaluated list of string.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
#define AFW_FALSE
Definition: afw_common.h:392
afw_boolean_t(* afw_object_cb_t)(const afw_object_t *object, void *context, afw_xctx_t *xctx)
Typedef for afw_adaptor_session_object callback.
Definition: afw_common.h:1176
#define AFW_UTF8_LITERAL(A_STRING)
String literal initializer.
Definition: afw_common.h:582
struct afw_iterator_s afw_iterator_t
#define AFW_TRUE
Definition: afw_common.h:383
_Bool afw_boolean_t
Definition: afw_common.h:373
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
#define offsetof(type, member)
Definition: afw_common.h:135
const afw_runtime_custom_t * afw_environment_get_runtime_custom(const afw_utf8_t *object_type_id, afw_xctx_t *xctx)
Get afw_runtime_custom_t for a custom handled runtime object type.
afw_environment_load_extension(const afw_utf8_t *extension_id, const afw_utf8_t *module_path, const afw_object_t *properties, afw_xctx_t *xctx)
Load and initialize environment extension.
const afw_data_type_t * afw_environment_get_data_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the data_type associated with configuration entry type.
void afw_environment_register_runtime_object_map_inf(const afw_utf8_t *object_type_id, const afw_object_inf_t *inf, afw_xctx_t *xctx)
Register a runtime object map interface.
afw_runtime_value_accessor_t afw_environment_get_runtime_value_accessor(const afw_utf8_t *accessor_name, afw_xctx_t *xctx)
Get the interface associated with a runtime object map.
const afw_object_inf_t * afw_environment_get_runtime_object_map_inf(const afw_utf8_t *object_type_id, afw_xctx_t *xctx)
Get the interface associated with a runtime object map.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319
#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
#define afw_list_get_next_internal(instance, iterator, data_type, internal, xctx)
Call method get_next_internal of interface afw_list.
afw_list_create_wrapper_for_array(const void *array, afw_boolean_t indirect, const afw_data_type_t *data_type, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx)
Create a immutable list wrapper for an array.
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
Definition: afw_memory.h:39
afw_object_impl_internal_get_meta(const afw_object_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
A general impl of method get_meta for interface afw_object.
afw_object_impl_internal_get_property_meta(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
A general impl of method get_property_meta for interface afw_object.
afw_object_impl_internal_get_next_property_meta(const afw_object_t *instance, const afw_iterator_t **iterator, const afw_utf8_t **property_name, const afw_pool_t *p, afw_xctx_t *xctx)
A general impl of method get_next_property_meta for interface afw_object.
#define afw_object_get_property(instance, property_name, xctx)
Call method get_property of interface afw_object.
#define afw_object_add_reference(instance, xctx)
Call method add_reference of interface afw_object.
#define afw_object_release(instance, xctx)
Call method release of interface afw_object.
#define afw_object_meta_get_object_type_id(instance, xctx)
Get object's object_type_id.
afw_object_meta_set_parent_paths(const afw_object_t *instance, const afw_value_list_t *parent_paths, afw_xctx_t *xctx)
Set meta parentPaths property.
afw_object_meta_get_nonempty_delta(const afw_object_t *instance, afw_xctx_t *xctx)
Return meta delta object for an object creating an empty one if needed.
afw_object_meta_get_object_id(const afw_object_t *instance, afw_xctx_t *xctx)
Get entity object's object id.
afw_object_path_make(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_pool_t *p, afw_xctx_t *xctx)
Construct an object path in a specified pool.
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
#define afw_pool_malloc_type(instance, type, xctx)
Macro to allocate uncleared memory to hold type in pool.
Definition: afw_pool.h:182
afw_query_criteria_test_object(const afw_object_t *obj, const afw_query_criteria_t *criteria, const afw_pool_t *p, afw_xctx_t *xctx)
Test object against query criteria.
void afw_runtime_object_release(const afw_object_t *instance, afw_xctx_t *xctx)
Method release for runtime object.
Definition: afw_runtime.c:1315
afw_runtime_env_resolve_and_set_const_objects(const afw_runtime_unresolved_const_object_t *const *unresolved, afw_boolean_t overwrite, afw_xctx_t *xctx)
Resolve and set a NULL terminated list of object pointers in the xctx's runtime objects.
Definition: afw_runtime.c:750
afw_size_t afw_runtime_object_get_count(const afw_object_t *instance, afw_xctx_t *xctx)
Method get_count for runtime object.
Definition: afw_runtime.c:1341
afw_runtime_object_create_indirect(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, void *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create an indirect runtime object.
Definition: afw_runtime.c:481
const afw_object_t *(* afw_runtime_object_wrapper_p_cb_t)(void *data, const afw_pool_t *p, afw_xctx_t *xctx)
Typedef used for afw_runtime_env_set_object_cb_wrapper() cb.
Definition: afw_runtime.h:380
afw_runtime_env_create_and_set_indirect_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, void *internal, afw_boolean_t overwrite, afw_xctx_t *xctx)
Create and set an indirect runtime object.
Definition: afw_runtime.c:528
const afw_utf8_t * afw_runtime_object_get_object_type_id(const afw_object_t *instance, afw_xctx_t *xctx)
Method get_object_type_id for runtime object.
Definition: afw_runtime.c:1359
afw_runtime_xctx_set_objects(const afw_object_t *const *objects, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set a list of object pointers in the xctx's runtime objects.
Definition: afw_runtime.c:344
afw_boolean_t afw_runtime_object_has_property(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Method has_property for runtime object.
Definition: afw_runtime.c:1562
const afw_value_t * afw_runtime_object_get_meta(const afw_object_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
Method get_meta for runtime object.
Definition: afw_runtime.c:1431
afw_runtime_get_internal_session(afw_xctx_t *xctx)
Get an internal session for runtime objects.
Definition: afw_runtime.c:961
afw_runtime_env_set_object(const afw_object_t *object, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set an object pointer in the environment's runtime objects.
Definition: afw_runtime.c:210
const afw_value_t * afw_runtime_object_get_next_own_property(const afw_object_t *instance, const afw_iterator_t **iterator, const afw_utf8_t **property_name, afw_xctx_t *xctx)
Method get_next_property for runtime object.
Definition: afw_runtime.c:1462
afw_runtime_remove_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Remove object by object type id and object id.
Definition: afw_runtime.c:262
afw_runtime_get_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Get a runtime object.
Definition: afw_runtime.c:853
afw_runtime_resolve_const_object(const afw_runtime_unresolved_const_object_t *unresolved, const afw_pool_t *p, afw_xctx_t *xctx)
Resolve a runtime const object.
Definition: afw_runtime.c:701
void afw_runtime_object_add_reference(const afw_object_t *instance, afw_xctx_t *xctx)
Method add_reference for runtime object.
Definition: afw_runtime.c:1328
afw_runtime_object_create_indirect_using_inf(const afw_object_inf_t *inf, const afw_utf8_t *object_id, void *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create an indirect runtime object.
Definition: afw_runtime.c:449
const afw_object_setter_t * afw_runtime_object_get_setter(const afw_object_t *instance, afw_xctx_t *xctx)
Method get_setter for runtime object.
Definition: afw_runtime.c:1579
afw_runtime_xctx_set_object(const afw_object_t *object, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set an object pointer in the xctx's runtime objects.
Definition: afw_runtime.c:292
afw_runtime_env_create_and_set_indirect_object_using_inf(const afw_object_inf_t *inf, const afw_utf8_t *object_id, void *internal, afw_boolean_t overwrite, afw_xctx_t *xctx)
Create and set an indirect runtime object.
Definition: afw_runtime.c:507
afw_runtime_register_object_map_infs(const afw_object_inf_t *const *inf, afw_xctx_t *xctx)
Register runtime object map interfaces.
Definition: afw_runtime.c:356
const afw_value_t * afw_runtime_object_get_next_property_meta(const afw_object_t *instance, const afw_iterator_t **iterator, const afw_utf8_t **property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Method get_next_property_meta for runtime object.
Definition: afw_runtime.c:1546
afw_runtime_foreach(const afw_utf8_t *object_type_id, void *context, afw_object_cb_t callback, afw_xctx_t *xctx)
Call a callback for each runtime object.
Definition: afw_runtime.c:900
afw_runtime_get_adaptor_factory()
Get singleton factory for runtime adaptor.
Definition: afw_runtime.c:915
afw_runtime_env_set_object_cb_wrapper(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_runtime_object_wrapper_p_cb_t callback, void *data, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set environment object accessed via callback.
Definition: afw_runtime.c:240
const afw_value_t * afw_runtime_object_get_property(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Method get_property for runtime object.
Definition: afw_runtime.c:1376
const afw_value_t * afw_runtime_object_get_property_meta(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Method get_property_meta for runtime object.
Definition: afw_runtime.c:1446
afw_runtime_resolve_and_register_object_map_infs(const afw_interface_implementation_rti_t *const *rti, afw_xctx_t *xctx)
Create and register runtime object map interfaces.
Definition: afw_runtime.c:373
afw_runtime_env_set_objects(const afw_object_t *const *objects, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set a list of object pointers in the environment's runtime objects.
Definition: afw_runtime.c:228
@ afw_runtime_unresolved_primitive_type_list
Definition: afw_runtime.h:278
@ afw_runtime_unresolved_primitive_type_string
value points to afw_utf8_z_t.
Definition: afw_runtime.h:287
@ afw_runtime_unresolved_primitive_type_object
Definition: afw_runtime.h:284
@ afw_runtime_unresolved_primitive_type_integer
Definition: afw_runtime.h:275
@ afw_runtime_unresolved_primitive_type_number
Definition: afw_runtime.h:272
@ afw_runtime_unresolved_primitive_type_boolean
Definition: afw_runtime.h:269
afw_boolean_t afw_utf8_starts_with_z(const afw_utf8_t *string, const afw_utf8_z_t *starts_with_z)
Check to see if a string starts with a utf8_z string.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
#define afw_utf8_from_utf8_z(s_z, p, xctx)
Make utf-8 string without copy in specified pool.
Definition: afw_utf8.h:254
afw_boolean_t afw_utf8_starts_with(const afw_utf8_t *string, const afw_utf8_t *starts_with)
Check to see if a string starts with another string.
#define afw_utf8_create(s, len, p, xctx)
Create utf-8 string without copy unless necessary in pool specified.
Definition: afw_utf8.h:239
afw_value_false
Adaptive value false.
Definition: afw_value.h:354
afw_value_true
Adaptive value true.
Definition: afw_value.h:348
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
Definition: afw_xctx.h:199
Interface afw_adaptor_factory public struct.
Interface afw_adaptor_impl_index public struct.
Internal request info used by afw_adaptor_impl*() functions.
Interface afw_adaptor_journal public struct.
Interface afw_adaptor_key_value public struct.
Adaptor modify entry.
Interface afw_adaptor_object_type_cache public struct.
Interface afw_adaptor public struct.
Interface afw_adaptor_session public struct.
Interface afw_adaptor_transaction public struct.
Interface afw_data_type public struct.
Struct for typedef afw_environment_t defined in afw_common.h.
Definition: afw_common.h:1383
const afw_pool_t * p
Pool used to hold environment.
Definition: afw_common.h:1386
Interface Implementation Run Time Information.
Interface afw_list public struct.
Interface afw_object_inf_s struct.
const afw_utf8_t * id
Object id or property name.
Definition: afw_common.h:782
const afw_utf8_t * object_uri
Object path or NULL.
Definition: afw_common.h:811
const afw_object_t * embedding_object
Embedding object.
Definition: afw_common.h:768
const afw_utf8_t * object_type_uri
Object type object URI or NULL.
Definition: afw_common.h:796
Interface afw_object public struct.
Interface afw_object_setter public struct.
Interface afw_pool public struct.
Parsed query criteria.
const afw_runtime_property_t *const * properties
Definition: afw_runtime.h:189
afw_adaptor_session_get_object_t get_object
The session get_object method.
Definition: afw_runtime.h:49
afw_adaptor_session_retrieve_objects_t retrieve_objects
The session retrieve_objects method.
Definition: afw_runtime.h:46
Struct for runtime objects.
Definition: afw_runtime.h:174
Struct for runtime object map property.
Definition: afw_runtime.h:99
afw_size_t offset
Offset of internal property value in internal object struct.
Definition: afw_runtime.h:108
const afw_utf8_t * accessor_name
Name of registered runtime value accessor function.
Definition: afw_runtime.h:151
afw_runtime_value_accessor_t accessor
Accessor function or NULL.
Definition: afw_runtime.h:160
const afw_utf8_t * name
Property name.
Definition: afw_runtime.h:102
const afw_utf8_t * object_type_id
Object Type Id.
Definition: afw_runtime.h:61
size_t properties_offset
Runtime properties offset in internal.
Definition: afw_runtime.h:77
const afw_runtime_object_map_t * property_map
Map of property offsets in internal or NULL.
Definition: afw_runtime.h:68
afw_boolean_t indirect
Internal is indirect.
Definition: afw_runtime.h:89
const afw_runtime_unresolved_property_t ** properties
Definition: afw_runtime.h:254
Runtime unresolved property.
Definition: afw_runtime.h:313
const afw_utf8_z_t * name
Property name.
Definition: afw_runtime.h:316
afw_runtime_unresolved_value_t value
Unresolved value.
Definition: afw_runtime.h:319
afw_runtime_unresolved_primitive_type_t type
Primitive type of value.
Definition: afw_runtime.h:297
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type list values.
Interface afw_value public struct.
Interface afw_xctx public struct.
Definition: afw_runtime.c:24
Definition: afw_runtime.c:31