Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_model_context.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Model Adaptor
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 /* Comment out next line to cause new model code to be called on modify, etc. */
15 #define __IMPL_DIRECT_MAPPED_CALLS_MODIFY_
16 
17 #include "afw_internal.h"
18 
19 
20 
21 /* Include mask for object level variables. */
22 #define IMPL_INCLUDE_MASK_OBJECT_LEVEL 1
23 
24 /* Include mask for object and property level variables. */
25 #define IMPL_INCLUDE_MASK_PROPERTY_LEVEL 2
26 
27 /* Include mask for object and property level variables. */
28 #define IMPL_INCLUDE_MASK_EITHER 3
29 
30 
31 /* Can be returned by on* to do default processing */
32 const afw_value_null_t
33 impl_useDefaultProcessing = {
35 };
36 
37 
38 /* Value accessor afw_model_internal_get_current_adaptorId. */
40 afw_model_internal_get_current_adaptorId(
42  const void *internal,
43  const afw_pool_t *p,
44  afw_xctx_t *xctx)
45 {
47 
48  if (!ctx->adaptor_id_value) {
49  ctx->adaptor_id_value =
51  &ctx->session_self->adaptor->pub.adaptor_id,
52  ctx->p, xctx);
53  }
54 
55  return ctx->adaptor_id_value;
56 }
57 
58 /* Value accessor afw_model_internal_get_current_adaptorTypeSpecific. */
60 afw_model_internal_get_current_adaptorTypeSpecific(
62  const void *internal,
63  const afw_pool_t *p,
64  afw_xctx_t *xctx)
65 {
67 
68  if (!ctx->adaptorTypeSpecific_value && ctx->adaptorTypeSpecific) {
69  ctx->adaptorTypeSpecific_value =
71  ctx->adaptorTypeSpecific, ctx->p, xctx);
72  }
73 
74  return ctx->adaptorTypeSpecific_value;
75 }
76 
77 /* Value accessor afw_model_internal_get_current_mapBackObject. */
79 afw_model_internal_get_current_mapBackObject(
81  const void *internal,
82  const afw_pool_t *p,
83  afw_xctx_t *xctx)
84 {
86 
87  return ctx->mapBackObject_value;
88 }
89 
90 /* Value accessor afw_model_internal_get_current_mapObject. */
92 afw_model_internal_get_current_mapObject(
94  const void *internal,
95  const afw_pool_t *p,
96  afw_xctx_t *xctx)
97 {
99 
100  return ctx->mapObject_value;
101 }
102 
103 /* Value accessor afw_model_internal_get_current_mappedAdaptorId. */
105 afw_model_internal_get_current_mappedAdaptorId(
107  const void *internal,
108  const afw_pool_t *p,
109  afw_xctx_t *xctx)
110 {
112 
113  return ctx->session_self->adaptor->mappedAdaptorId_value;
114 }
115 
116 /* Value accessor afw_model_internal_get_current_mappedObject. */
118 afw_model_internal_get_current_mappedObject(
120  const void *internal,
121  const afw_pool_t *p,
122  afw_xctx_t *xctx)
123 {
125 
126  if (!ctx->mapped_object_value && ctx->mapped_object) {
127  ctx->mapped_object_value = afw_value_create_object(
128  ctx->mapped_object, ctx->p, xctx);
129  }
130 
131  return ctx->mapped_object_value;
132 }
133 
134 /* Value accessor afw_model_internal_get_current_mappedObjectId. */
136 afw_model_internal_get_current_mappedObjectId(
138  const void *internal,
139  const afw_pool_t *p,
140  afw_xctx_t *xctx)
141 {
143 
144  if (!ctx->mapped_object_id_value && ctx->mapped_object) {
145  ctx->mapped_object_id_value =
147  ctx->mapped_object->meta.id, ctx->p, xctx);
148  }
149 
150  return ctx->mapped_object_id_value;
151 }
152 
153 /* Value accessor afw_model_internal_get_current_mappedObjectType. */
155 afw_model_internal_get_current_mappedObjectType(
157  const void *internal,
158  const afw_pool_t *p,
159  afw_xctx_t *xctx)
160 {
162 
163  if (!ctx->mapped_object_type_id_value && ctx->mapped_object) {
164  ctx->mapped_object_type_id_value =
166  afw_object_meta_get_object_type_id(ctx->mapped_object, xctx),
167  ctx->p, xctx);
168  }
169 
170  return ctx->mapped_object_type_id_value;
171 }
172 
173 /* Value accessor afw_model_internal_get_current_mappedPropertyName. */
175 afw_model_internal_get_current_mappedPropertyName(
177  const void *internal,
178  const afw_pool_t *p,
179  afw_xctx_t *xctx)
180 {
182 
183  if (!ctx->property_level.mapped_property_name_value &&
184  ctx->property_level.model_property_type)
185  {
186  ctx->property_level.mapped_property_name_value =
187  ctx->property_level.model_property_type->mapped_property_name_value;
188  }
189 
190  return ctx->property_level.mapped_property_name_value;
191 }
192 
193 /* Value accessor afw_model_internal_get_current_mappedValue. */
195 afw_model_internal_get_current_mappedValue(
197  const void *internal,
198  const afw_pool_t *p,
199  afw_xctx_t *xctx)
200 {
202 
203  return ctx->property_level.mapped_value;
204 }
205 
206 /* Value accessor afw_model_internal_get_current_modifyEntries. */
208 afw_model_internal_get_current_modifyEntries(
210  const void *internal,
211  const afw_pool_t *p,
212  afw_xctx_t *xctx)
213 {
215 
216  if (!ctx->adaptor_id_value) {
217  ctx->adaptor_id_value =
219  &ctx->session_self->adaptor->pub.adaptor_id,
220  ctx->p, xctx);
221  }
222 
223  return ctx->adaptor_id_value;
224 }
225 
226 /* Value accessor afw_model_internal_get_current_object. */
228 afw_model_internal_get_current_object(
230  const void *internal,
231  const afw_pool_t *p,
232  afw_xctx_t *xctx)
233 {
235 
236  if (!ctx->object_value && ctx->object) {
237  ctx->object_value = afw_value_create_object(
238  ctx->object, ctx->p, xctx);
239  }
240 
241  return ctx->object_value;
242 }
243 
244 /* Value accessor afw_model_internal_get_current_objectId. */
246 afw_model_internal_get_current_objectId(
248  const void *internal,
249  const afw_pool_t *p,
250  afw_xctx_t *xctx)
251 {
253 
254  if (!ctx->object_id_value && ctx->object_id) {
255  ctx->object_id_value =
257  ctx->object_id, ctx->p, xctx);
258  }
259 
260  return ctx->object_id_value;
261 }
262 
263 /* Value accessor afw_model_internal_get_current_objectType. */
265 afw_model_internal_get_current_objectType(
267  const void *internal,
268  const afw_pool_t *p,
269  afw_xctx_t *xctx)
270 {
272 
273  if (!ctx->object_type_id_value)
274  {
275  ctx->object_type_id_value =
276  ctx->model_object_type->mapped_object_type_id_value;
277  }
278 
279  return ctx->object_type_id_value;
280 }
281 
282 /* Value accessor afw_model_internal_get_current_propertyName. */
284 afw_model_internal_get_current_propertyName(
286  const void *internal,
287  const afw_pool_t *p,
288  afw_xctx_t *xctx)
289 {
291 
292  if (!ctx->property_level.property_name_value &&
293  ctx->property_level.model_property_type)
294  {
295  ctx->property_level.property_name_value =
296  ctx->property_level.model_property_type->property_name_value;
297  }
298 
299  return ctx->property_level.property_name_value;
300 }
301 
302 /* Value accessor afw_model_internal_get_current_queryCriteria. */
304 afw_model_internal_get_current_queryCriteria(
306  const void *internal,
307  const afw_pool_t *p,
308  afw_xctx_t *xctx)
309 {
311  const afw_object_t *query_object;
312 
313  if (!ctx->queryCriteria_value && ctx->criteria) {
315  ctx->criteria, ctx->p, xctx);
316  ctx->queryCriteria_value = afw_value_create_object(query_object,
317  ctx->p, xctx);
318  }
319 
320  return ctx->queryCriteria_value;
321 }
322 
323 /* Value accessor afw_model_internal_get_current_returnObject. */
325 afw_model_internal_get_current_returnObject(
327  const void *internal,
328  const afw_pool_t *p,
329  afw_xctx_t *xctx)
330 {
332 
333  return ctx->returnObject_value;
334 }
335 
336 /* Value accessor afw_model_internal_get_current_useDefaultProcessing. */
338 afw_model_internal_get_current_useDefaultProcessing(
340  const void *internal,
341  const afw_pool_t *p,
342  afw_xctx_t *xctx)
343 {
345 
346  return ctx->useDefaultProcessing_value;
347 }
348 
349 /* Value accessor afw_model_internal_get_current_value. */
351 afw_model_internal_get_current_value(
353  const void *internal,
354  const afw_pool_t *p,
355  afw_xctx_t *xctx)
356 {
358 
359  return ctx->property_level.value;
360 }
361 
362 
363 static const afw_value_t *
364 impl_custom_variable_get_cb(
366  const afw_utf8_t *name,
367  afw_xctx_t *xctx);
368 
369 
370 static const afw_value_t *
371 impl_mappedAdaptorId_from_mapped_cb(
373  const afw_utf8_t *name,
374  afw_xctx_t *xctx)
375 {
376  afw_model_internal_context_t *ctx = entry->data;
377 
378  return ctx->session_self->adaptor->mappedAdaptorId_value;
379 }
380 
381 
382 static const afw_value_t *
383 impl_mappedObject_from_mapped_cb(
385  const afw_utf8_t *name,
386  afw_xctx_t *xctx)
387 {
388  afw_model_internal_context_t *ctx = entry->data;
389 
390  if (!ctx->mapped_object_value && ctx->mapped_object) {
391  ctx->mapped_object_value = afw_value_create_object(
392  ctx->mapped_object, ctx->p, xctx);
393  }
394 
395  return ctx->mapped_object_value;
396 }
397 
398 
399 static const afw_value_t *
400 impl_mappedObjectId_from_mapped_cb(
402  const afw_utf8_t *name,
403  afw_xctx_t *xctx)
404 {
405  afw_model_internal_context_t *ctx = entry->data;
406 
407  if (!ctx->mapped_object_id_value && ctx->mapped_object) {
408  ctx->mapped_object_id_value =
410  ctx->mapped_object->meta.id, ctx->p, xctx);
411  }
412 
413  return ctx->mapped_object_id_value;
414 }
415 
416 
417 static const afw_value_t *
418 impl_mappedObjectType_from_mapped_cb(
420  const afw_utf8_t *name,
421  afw_xctx_t *xctx)
422 {
423  afw_model_internal_context_t *ctx = entry->data;
424 
425  if (!ctx->mapped_object_type_id_value && ctx->mapped_object) {
426  ctx->mapped_object_type_id_value =
428  afw_object_meta_get_object_type_id(ctx->mapped_object, xctx),
429  ctx->p, xctx);
430  }
431 
432  return ctx->mapped_object_type_id_value;
433 }
434 
435 
436 static const afw_value_t *
437 impl_mappedPropertyName_from_mapped_cb(
439  const afw_utf8_t *name,
440  afw_xctx_t *xctx)
441 {
442  afw_model_internal_context_t *ctx = entry->data;
443 
444  if (!ctx->property_level.mapped_property_name_value &&
445  ctx->property_level.model_property_type)
446  {
447  ctx->property_level.mapped_property_name_value =
448  ctx->property_level.model_property_type->mapped_property_name_value;
449  }
450 
451  return ctx->property_level.mapped_property_name_value;
452 }
453 
454 
455 static const afw_value_t *
456 impl_mappedValue_from_mapped_cb(
458  const afw_utf8_t *name,
459  afw_xctx_t *xctx)
460 {
461  afw_model_internal_context_t *ctx = entry->data;
462 
463  return ctx->property_level.mapped_value;
464 }
465 
466 
467 static const afw_value_t *
468 impl_adaptorId_to_mapped_cb(
470  const afw_utf8_t *name,
471  afw_xctx_t *xctx)
472 {
473  afw_model_internal_context_t *ctx = entry->data;
474 
475  if (!ctx->adaptor_id_value) {
476  ctx->adaptor_id_value =
478  &ctx->session_self->adaptor->pub.adaptor_id,
479  ctx->p, xctx);
480  }
481 
482  return ctx->adaptor_id_value;
483 }
484 
485 
486 static const afw_value_t *
487 impl_modifyEntries_to_mapped_cb(
489  const afw_utf8_t *name,
490  afw_xctx_t *xctx)
491 {
492  afw_model_internal_context_t *ctx = entry->data;
493 
494  return ctx->modify_entries_value;
495 }
496 
497 
498 static const afw_value_t *
499 impl_object_to_mapped_cb(
501  const afw_utf8_t *name,
502  afw_xctx_t *xctx)
503 {
504  afw_model_internal_context_t *ctx = entry->data;
505 
506  if (!ctx->object_value && ctx->object) {
507  ctx->object_value = afw_value_create_object(
508  ctx->object, ctx->p, xctx);
509  }
510 
511  return ctx->object_value;
512 }
513 
514 
515 static const afw_value_t *
516 impl_objectId_to_mapped_cb(
518  const afw_utf8_t *name,
519  afw_xctx_t *xctx)
520 {
521  afw_model_internal_context_t *ctx = entry->data;
522 
523  if (!ctx->object_id_value && ctx->object_id) {
524  ctx->object_id_value =
526  ctx->object_id, ctx->p, xctx);
527  }
528 
529  return ctx->object_id_value;
530 }
531 
532 
533 static const afw_value_t *
534 impl_objectType_to_mapped_cb(
536  const afw_utf8_t *name,
537  afw_xctx_t *xctx)
538 {
539  afw_model_internal_context_t *ctx = entry->data;
540 
541  if (!ctx->object_type_id_value)
542  {
543  ctx->object_type_id_value =
544  ctx->model_object_type->mapped_object_type_id_value;
545  }
546 
547  return ctx->object_type_id_value;
548 }
549 
550 
551 static const afw_value_t *
552 impl_propertyName_to_mapped_cb(
554  const afw_utf8_t *name,
555  afw_xctx_t *xctx)
556 {
557  afw_model_internal_context_t *ctx = entry->data;
558 
559  if (!ctx->property_level.property_name_value &&
560  ctx->property_level.model_property_type)
561  {
562  ctx->property_level.property_name_value =
563  ctx->property_level.model_property_type->property_name_value;
564  }
565 
566  return ctx->property_level.property_name_value;
567 }
568 
569 
570 static const afw_value_t *
571 impl_adaptorTypeSpecific_cb(
573  const afw_utf8_t *name,
574  afw_xctx_t *xctx)
575 {
576  afw_model_internal_context_t *ctx = entry->data;
577 
578  if (!ctx->adaptorTypeSpecific_value && ctx->adaptorTypeSpecific) {
579  ctx->adaptorTypeSpecific_value =
581  ctx->adaptorTypeSpecific, ctx->p, xctx);
582  }
583 
584  return ctx->adaptorTypeSpecific_value;
585 }
586 
587 
588 static const afw_value_t *
589 impl_queryCriteria_cb(
591  const afw_utf8_t *name,
592  afw_xctx_t *xctx)
593 {
594  afw_model_internal_context_t *ctx = entry->data;
595  const afw_object_t *query_object;
596 
597  if (!ctx->queryCriteria_value && ctx->criteria) {
599  ctx->criteria, ctx->p, xctx);
600  ctx->queryCriteria_value = afw_value_create_object(query_object,
601  ctx->p, xctx);
602  }
603 
604  return ctx->queryCriteria_value;
605 }
606 
607 
608 static const afw_value_t *
609 impl_mapBackObject_cb(
611  const afw_utf8_t *name,
612  afw_xctx_t *xctx)
613 {
614  afw_model_internal_context_t *ctx = entry->data;
615 
616  return ctx->mapBackObject_value;
617 }
618 
619 
620 
621 static const afw_value_t *
622 impl_returnObject_cb(
624  const afw_utf8_t *name,
625  afw_xctx_t *xctx)
626 {
627  afw_model_internal_context_t *ctx = entry->data;
628 
629  return ctx->returnObject_value;
630 }
631 
632 
633 static const afw_value_t *
634 impl_useDefaultProcessing_cb(
636  const afw_utf8_t *name,
637  afw_xctx_t *xctx)
638 {
639  afw_model_internal_context_t *ctx = entry->data;
640 
641  return ctx->useDefaultProcessing_value;
642 }
643 
644 
645 static const afw_value_t *
646 impl_value_to_mapped_cb(
648  const afw_utf8_t *name,
649  afw_xctx_t *xctx)
650 {
651  afw_model_internal_context_t *ctx = entry->data;
652 
653  return ctx->property_level.value;
654 }
655 
656 
657 
658 static const
660 impl_current_variable_meta_adaptorId =
661 {
662  &afw_s_adaptorId,
665  "Adaptor Id"
666 };
667 
668 
669 static const
671 impl_current_variable_meta_adaptorTypeSpecific =
672 {
673  &afw_s_adaptorTypeSpecific,
676  "Adaptor Specific"
677 };
678 
679 
680 static const
682 impl_current_variable_meta_mapBackObject =
683 {
684  &afw_s_mapBackObject,
687  "Function to map back an object",
688  "object (object object)",
689  "object /* Mapped back object */ ( */ (\n"
690  " object mappedObject /* Object to map back. */ )\n"
691 };
692 
693 
694 static const
696 impl_current_variable_meta_modifyEntries =
697 {
698  &afw_s_modifyEntries,
701  "Modify Entries",
702  "of list"
703 };
704 
705 
706 static const
708 impl_current_variable_meta_object =
709 {
710  &afw_s_object,
713  "Object",
714  "_AdaptiveValueMeta_"
715 };
716 
717 
718 static const
720 impl_current_variable_meta_objectId =
721 {
722  &afw_s_objectId,
725  "ObjectId"
726 };
727 
728 
729 static const
731 impl_current_variable_meta_objectType =
732 {
733  &afw_s_objectType,
736  "ObjectType"
737 };
738 
739 
740 static const
742 impl_current_variable_meta_propertyName =
743 {
744  &afw_s_propertyName,
747  "Property Name"
748 };
749 
750 
751 static const
753 impl_current_variable_meta_returnObject =
754 {
755  &afw_s_returnObject,
758  "Function to call to return an object",
759  "boolean (object object, boolean mapBack? /* true will mapback object */ )",
760  "boolean /* true if no more objects can be returned. */ ( */ (\n"
761  " object object /* The object to return. */ )\n"
762 };
763 
764 
765 static const
767 impl_current_variable_meta_value =
768 {
769  &afw_s_value,
770  NULL,
771  NULL,
772  "Value"
773 };
774 
775 
776 static const
778 impl_current_variable_meta_mappedAdaptorId =
779 {
780  &afw_s_mappedAdaptorId,
783  "Mapped Adaptor Id"
784 };
785 
786 
787 static const
789 impl_current_variable_meta_mappedObject =
790 {
791  &afw_s_mappedObject,
794  "Mapped Object"
795 };
796 
797 
798 static const
800 impl_current_variable_meta_mappedObjectId =
801 {
802  &afw_s_mappedObjectId,
805  "Mapped Object Id"
806 };
807 
808 
809 static const
811 impl_current_variable_meta_mappedObjectType =
812 {
813  &afw_s_mappedObjectType,
816  "Mapped Object Type"
817 };
818 
819 
820 static const
822 impl_current_variable_meta_mappedPropertyName =
823 {
824  &afw_s_mappedPropertyName,
827  "Mapped Property Name"
828 };
829 
830 
831 static const
833 impl_current_variable_meta_mappedValue =
834 {
835  &afw_s_mappedValue,
836  NULL,
837  NULL,
838  "Mapped Value"
839 };
840 
841 
842 static const
844 impl_current_variable_meta_queryCriteria =
845 {
846  &afw_s_queryCriteria,
849  "Query Criteria",
850  "_AdaptiveQueryCriteria_"
851 };
852 
853 
854 static const
856 impl_current_variable_meta_useDefaultProcessing =
857 {
858  &afw_s_useDefaultProcessing,
859  NULL,
860  NULL,
861  "Use Default Processing"
862 };
863 
864 
865 static const
867 impl_current_variable_adaptorId = {
868  &impl_current_variable_meta_adaptorId,
869  "The adaptor id of the object being converted to mapped object.",
870  impl_adaptorId_to_mapped_cb,
871  IMPL_INCLUDE_MASK_OBJECT_LEVEL
872 };
873 
874 
875 static const
877 impl_current_variable_adaptorTypeSpecific = {
878  &impl_current_variable_meta_adaptorTypeSpecific,
879  "This is the adaptorTypeSpecific parameter value.",
880  impl_adaptorTypeSpecific_cb,
881  IMPL_INCLUDE_MASK_OBJECT_LEVEL
882 };
883 
884 
885 static const
887 impl_current_variable_mapBackObject = {
888  &impl_current_variable_meta_mapBackObject,
889  "The function to map back an object.",
890  impl_mapBackObject_cb,
891  IMPL_INCLUDE_MASK_OBJECT_LEVEL
892 };
893 
894 
895 static const
897 impl_current_variable_modifyEntries = {
898  &impl_current_variable_meta_modifyEntries,
899  "The modify entries.",
900  impl_modifyEntries_to_mapped_cb,
901  IMPL_INCLUDE_MASK_OBJECT_LEVEL
902 };
903 
904 
905 static const
907 impl_current_variable_object = {
908  &impl_current_variable_meta_object,
909  "This is object being converted to mapped object.",
910  impl_object_to_mapped_cb,
911  IMPL_INCLUDE_MASK_OBJECT_LEVEL
912 };
913 
914 
915 static const
917 impl_current_variable_objectId = {
918  &impl_current_variable_meta_objectId,
919  "The object id of the object being converted to mapped object.",
920  impl_objectId_to_mapped_cb,
921  IMPL_INCLUDE_MASK_OBJECT_LEVEL
922 };
923 
924 
925 static const
927 impl_current_variable_objectType = {
928  &impl_current_variable_meta_objectType,
929  "The object type of the object being converted to mapped object.",
930  impl_objectType_to_mapped_cb,
931  IMPL_INCLUDE_MASK_OBJECT_LEVEL
932 };
933 
934 
935 static const
937 impl_current_variable_propertyName = {
938  &impl_current_variable_meta_propertyName,
939  "The property name in current::object of this property.",
940  impl_propertyName_to_mapped_cb,
941  IMPL_INCLUDE_MASK_PROPERTY_LEVEL
942 };
943 
944 
945 static const
947 impl_current_variable_queryCriteria = {
948  &impl_current_variable_meta_queryCriteria,
949  "The queryCriteria object.",
950  impl_queryCriteria_cb,
951  IMPL_INCLUDE_MASK_OBJECT_LEVEL
952 };
953 
954 
955 static const
957 impl_current_variable_returnObject = {
958  &impl_current_variable_meta_returnObject,
959  "The function to call to return an object.",
960  impl_returnObject_cb,
961  IMPL_INCLUDE_MASK_OBJECT_LEVEL
962 };
963 
964 
965 static const
967 impl_current_variable_value = {
968  &impl_current_variable_meta_value,
969  "The value of this property from current::object.",
970  impl_value_to_mapped_cb,
971  IMPL_INCLUDE_MASK_PROPERTY_LEVEL
972 };
973 
974 
975 static const
977 impl_current_variable_mappedAdaptorId = {
978  &impl_current_variable_meta_mappedAdaptorId,
979  "The adaptor id of the object being converted to object.",
980  impl_mappedAdaptorId_from_mapped_cb,
981  IMPL_INCLUDE_MASK_OBJECT_LEVEL
982 };
983 
984 
985 static const
987 impl_current_variable_mappedObject = {
988  &impl_current_variable_meta_mappedObject,
989  "This is object being converted to object.",
990  impl_mappedObject_from_mapped_cb,
991  IMPL_INCLUDE_MASK_OBJECT_LEVEL
992 };
993 
994 
995 static const
997 impl_current_variable_mappedObjectId = {
998  &impl_current_variable_meta_mappedObjectId,
999  "The object id of the object being converted to object.",
1000  impl_mappedObjectId_from_mapped_cb,
1001  IMPL_INCLUDE_MASK_OBJECT_LEVEL
1002 };
1003 
1004 
1005 static const
1007 impl_current_variable_mappedObjectType = {
1008  &impl_current_variable_meta_mappedObjectType,
1009  "The object type of the object being converted to object.",
1010  impl_mappedObjectType_from_mapped_cb,
1011  IMPL_INCLUDE_MASK_OBJECT_LEVEL
1012 };
1013 
1014 
1015 static const
1017 impl_current_variable_mappedPropertyName = {
1018  &impl_current_variable_meta_mappedPropertyName,
1019  "The property name in current::mappedObject of this property.",
1020  impl_mappedPropertyName_from_mapped_cb,
1021  IMPL_INCLUDE_MASK_PROPERTY_LEVEL
1022 };
1023 
1024 
1025 static const
1027 impl_current_variable_mappedValue = {
1028  &impl_current_variable_meta_mappedValue,
1029  "The value of this property from current::mappedObject.",
1030  impl_mappedValue_from_mapped_cb,
1031  IMPL_INCLUDE_MASK_PROPERTY_LEVEL
1032 };
1033 
1034 
1035 static const
1037 impl_current_variable_useDefaultProcessing = {
1038  &impl_current_variable_meta_useDefaultProcessing,
1039  "Return this value to cause default processing to occur.",
1040  impl_useDefaultProcessing_cb,
1041  IMPL_INCLUDE_MASK_OBJECT_LEVEL
1042 };
1043 
1044 
1046 afw_model_internal_context_current_property_to_mapped[] = {
1047  &impl_current_variable_adaptorId,
1048  &impl_current_variable_object,
1049  &impl_current_variable_objectId,
1050  &impl_current_variable_objectType,
1051  &impl_current_variable_propertyName,
1052  &impl_current_variable_value,
1053  NULL
1054 };
1055 
1056 
1058 afw_model_internal_context_current_add_object[] = {
1059  &impl_current_variable_adaptorId,
1060  &impl_current_variable_object,
1061  &impl_current_variable_objectId,
1062  &impl_current_variable_objectType,
1063  &impl_current_variable_useDefaultProcessing,
1064  NULL
1065 };
1066 
1067 
1069 afw_model_internal_context_current_delete_object[] = {
1070  &impl_current_variable_adaptorId,
1071  &impl_current_variable_objectId,
1072  &impl_current_variable_objectType,
1073  &impl_current_variable_useDefaultProcessing,
1074  NULL
1075 };
1076 
1077 
1079 afw_model_internal_context_current_get_object[] = {
1080  &impl_current_variable_adaptorId,
1081  &impl_current_variable_adaptorTypeSpecific,
1082  &impl_current_variable_mapBackObject,
1083  &impl_current_variable_objectId,
1084  &impl_current_variable_objectType,
1085  &impl_current_variable_useDefaultProcessing,
1086  &impl_current_variable_mappedAdaptorId,
1087  &impl_current_variable_mappedObjectType,
1088  NULL
1089 };
1090 
1091 
1093 afw_model_internal_context_current_modify_object[] = {
1094  &impl_current_variable_modifyEntries,
1095  &impl_current_variable_adaptorId,
1096  &impl_current_variable_object,
1097  &impl_current_variable_objectId,
1098  &impl_current_variable_objectType,
1099  &impl_current_variable_useDefaultProcessing,
1100  NULL
1101 };
1102 
1103 
1105 afw_model_internal_context_current_replace_object[] = {
1106  &impl_current_variable_adaptorId,
1107  &impl_current_variable_object,
1108  &impl_current_variable_objectId,
1109  &impl_current_variable_objectType,
1110  &impl_current_variable_useDefaultProcessing,
1111  NULL
1112 };
1113 
1114 
1116 afw_model_internal_context_current_retrieve_objects[] = {
1117  &impl_current_variable_adaptorId,
1118  &impl_current_variable_adaptorTypeSpecific,
1119  &impl_current_variable_returnObject,
1120  &impl_current_variable_mapBackObject,
1121  &impl_current_variable_objectType,
1122  &impl_current_variable_queryCriteria,
1123  &impl_current_variable_useDefaultProcessing,
1124  &impl_current_variable_mappedAdaptorId,
1125  &impl_current_variable_mappedObjectType,
1126  NULL
1127 };
1128 
1129 
1131 afw_model_internal_context_current_property_from_mapped[] = {
1132  &impl_current_variable_mappedAdaptorId,
1133  &impl_current_variable_mappedObject,
1134  &impl_current_variable_mappedObjectId,
1135  &impl_current_variable_mappedObjectType,
1136  &impl_current_variable_mappedPropertyName,
1137  &impl_current_variable_mappedValue,
1138  NULL
1139 };
1140 
1141 
1143 afw_model_internal_context_current_for_initial_object_id[] = {
1144  &impl_current_variable_mappedAdaptorId,
1145  &impl_current_variable_mappedObject,
1146  &impl_current_variable_mappedObjectId,
1147  &impl_current_variable_mappedObjectType,
1148  &impl_current_variable_mappedPropertyName,
1149  &impl_current_variable_mappedValue,
1150  &impl_current_variable_adaptorId,
1151  &impl_current_variable_object,
1152  &impl_current_variable_objectId,
1153  &impl_current_variable_objectType,
1154  &impl_current_variable_propertyName,
1155  &impl_current_variable_value,
1156  NULL
1157 };
1158 
1160 afw_model_internal_context_current_runtime_ctx[] = {
1161  &impl_current_variable_mappedAdaptorId,
1162  &impl_current_variable_mappedObject,
1163  &impl_current_variable_mappedObjectId,
1164  &impl_current_variable_mappedObjectType,
1165  &impl_current_variable_mappedPropertyName,
1166  &impl_current_variable_mappedValue,
1167  &impl_current_variable_adaptorId,
1168  &impl_current_variable_object,
1169  &impl_current_variable_objectId,
1170  &impl_current_variable_objectType,
1171  &impl_current_variable_propertyName,
1172  &impl_current_variable_value,
1173  NULL
1174 };
1175 
1176 
1177 void
1178 afw_model_internal_register_context_type_model(afw_xctx_t *xctx)
1179 {
1181  &afw_s_modelGetObject,
1182  &afw_s_current,
1183  "Qualified variables available during onGetObject processing",
1184  &afw_model_internal_context_current_get_object[0],
1185  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1186 
1188  &afw_s_modelRetrieveObjects,
1189  &afw_s_current,
1190  "Qualified variables available during onRetrieveObjects processing",
1191  &afw_model_internal_context_current_retrieve_objects[0],
1192  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1193 
1195  &afw_s_modelAddObject,
1196  &afw_s_current,
1197  "Qualified variables available during onAddObject processing",
1198  &afw_model_internal_context_current_add_object[0],
1199  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1200 
1202  &afw_s_modelDeleteObject,
1203  &afw_s_current,
1204  "Qualified variables available during onDeleteObject processing",
1205  &afw_model_internal_context_current_delete_object[0],
1206  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1207 
1209  &afw_s_modelModifyObject,
1210  &afw_s_current,
1211  "Qualified variables available during onModifyObject processing",
1212  &afw_model_internal_context_current_modify_object[0],
1213  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1214 
1216  &afw_s_modelReplaceObject,
1217  &afw_s_current,
1218  "Qualified variables available during onReplaceObject processing",
1219  &afw_model_internal_context_current_replace_object[0],
1220  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1221 
1223  &afw_s_modelGetProperty,
1224  &afw_s_current,
1225  "Qualified variables available during model onGetProperty processing",
1226  &afw_model_internal_context_current_property_from_mapped[0],
1227  IMPL_INCLUDE_MASK_EITHER,
1228  xctx);
1229 
1231  &afw_s_modelSetProperty,
1232  &afw_s_current,
1233  "Qualified variables available during model onSetProperty processing",
1234  &afw_model_internal_context_current_property_to_mapped[0],
1235  IMPL_INCLUDE_MASK_EITHER, xctx);
1236 
1238  &afw_s_modelInitialObjectId,
1239  &afw_s_current,
1240  "Qualified variables available during onGetInitialObjectId processing",
1241  &afw_model_internal_context_current_for_initial_object_id[0],
1242  IMPL_INCLUDE_MASK_OBJECT_LEVEL, xctx);
1243 
1244 }
1245 
1246 
1247 
1248 static const afw_value_t *
1249 impl_custom_variable_get_cb(
1250  const afw_xctx_qualifier_stack_entry_t *entry,
1251  const afw_utf8_t *name,
1252  afw_xctx_t *xctx)
1253 {
1254  afw_model_internal_context_t *ctx = entry->data;
1255  const afw_value_t *result;
1256 
1257  result = NULL;
1258 
1259  if (ctx->property_level.model_property_type &&
1260  ctx->property_level.model_property_type->custom_variables) {
1261  result = afw_object_get_property(
1262  ctx->property_level.model_property_type->custom_variables,
1263  name, xctx);
1264  }
1265 
1266  if (!result && ctx->model_object_type->custom_variables) {
1267  result = afw_object_get_property(
1268  ctx->model_object_type->custom_variables,
1269  name, xctx);
1270  }
1271 
1272  if (!result && ctx->model_object_type->model->custom_variables) {
1273  result = afw_object_get_property(
1274  ctx->model_object_type->model->custom_variables,
1275  name, xctx);
1276  }
1277 
1278  return result;
1279 }
1280 
1281 
1282 
1283 /*
1284  * Create a skeleton context used by many adaptor functions and push
1285  * qualifies.
1286  */
1288 afw_model_internal_create_skeleton_context(
1289  afw_runtime_object_indirect_t *runtime_object_level_skeleton,
1290  const afw_context_cb_variable_t * const* current_variables,
1292  const afw_adaptor_impl_request_t *impl_request,
1293  const afw_model_object_type_t *model_object_type,
1294  const afw_pool_t *p,
1295  afw_xctx_t *xctx)
1296 {
1298 
1299  /* Initialize ctx. */
1301  ctx->p = p;
1302  ctx->impl_request = impl_request;
1303  ctx->session_self = session_self;
1304  ctx->current_variables = current_variables;
1305  ctx->model_object_type = model_object_type;
1306  ctx->mapped_object_type_id = ctx->model_object_type->mapped_object_type_id;
1307  ctx->useDefaultProcessing_value =
1308  (const afw_value_t *)&impl_useDefaultProcessing;
1309 
1310  /* Push qualifiers. */
1312  (const afw_adaptor_t *)session_self->adaptor, xctx);
1313  afw_xctx_push_qualifier(&afw_s_custom, NULL, true,
1314  impl_custom_variable_get_cb, ctx, p, xctx);
1315 
1316  /* Create and push current object level object. */
1317  afw_memory_copy(&ctx->runtime_object_level,
1318  runtime_object_level_skeleton);
1319  ctx->runtime_object_level.internal = ctx;
1320  ctx->runtime_object_level.pub.p = p;
1321  afw_xctx_push_qualifier_object(&afw_s_current,
1322  (const afw_object_t *)&ctx->runtime_object_level,
1323  true, p, xctx);
1324 
1325 #ifdef _AFW_WORKING_ON___
1326  /* Push model custom variables. (First one push is last one checked) */
1327  if (ctx->model_object_type->model->custom_variables) {
1328  afw_xctx_push_qualifier_object(&afw_s_custom,
1329  ctx->model_object_type->model->custom_variables,
1330  true, p, xctx);
1331  }
1332 
1333  /* Push model object type custom variables */
1334  if (ctx->model_object_type->custom_variables) {
1335  afw_xctx_push_qualifier_object(&afw_s_custom,
1336  ctx->model_object_type->custom_variables,
1337  true, p, xctx);
1338  }
1339 
1340  /* Push model property type custom variables */
1341  if (ctx->property_level.model_property_type &&
1342  ctx->property_level.model_property_type->custom_variables)
1343  {
1344  afw_xctx_push_qualifier_object(&afw_s_custom,
1345  ctx->property_level.model_property_type->custom_variables,
1346  true, p, xctx);
1347  }
1348 #endif
1349 
1350  return ctx;
1351 }
1352 
1353 
1354 
1356 afw_model_internal_create_to_adaptor_skeleton_context(
1358  afw_runtime_object_indirect_t *runtime_object_level_skeleton,
1359  const afw_model_t *model,
1360  const afw_adaptor_impl_request_t *impl_request,
1361  const afw_utf8_t *object_type_id,
1362  const afw_utf8_t *object_id,
1363  afw_xctx_t *xctx)
1364 {
1366  const afw_model_object_type_t *model_object_type;
1367 
1368  model_object_type = afw_model_get_object_type(model,
1369  object_type_id, xctx);
1370  if (!model_object_type) {
1371  AFW_THROW_ERROR_FZ(not_found, xctx,
1372  "Object type %" AFW_UTF8_FMT " not found",
1373  AFW_UTF8_FMT_ARG(object_type_id));
1374  }
1375 
1376  ctx = afw_model_internal_create_skeleton_context(
1377  runtime_object_level_skeleton,
1378  afw_model_internal_context_current_runtime_ctx,
1379  self, impl_request, model_object_type, xctx->p, xctx);
1380  ctx->object_id = object_id;
1381  ctx->mapped_object_id = object_id;
1382 
1383  return ctx;
1384 }
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
#define AFW_DEFINE_INTERNAL_CONST_DATA(type)
Define an internal variable for /src/afw/ source*.c files.
Adaptive Framework Core Internal.
afw_adaptor_impl_push_qualifiers(const afw_adaptor_t *adaptor, afw_xctx_t *xctx)
Push adaptor qualifiers to xctx.
afw_data_type_function_direct
extern for data type function struct.
afw_value_evaluated_function_inf
Unmanaged evaluated value inf for data type function.
afw_value_evaluated_list_inf
Unmanaged evaluated value inf for data type list.
afw_data_type_list_direct
extern for data type list struct.
afw_value_evaluated_null_inf
Unmanaged evaluated value inf for data type null.
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_data_type_object_direct
extern for data type object struct.
afw_value_evaluated_object_inf
Unmanaged evaluated value inf for data type object.
afw_data_type_string_direct
extern for data type string struct.
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.
afw_value_evaluated_string_inf
Unmanaged evaluated value inf for data type string.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
struct afw_model_internal_s afw_model_t
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
afw_context_type_register_cb_variables(const afw_utf8_t *context_type_id, const afw_utf8_t *qualifier_id, const afw_utf8_octet_t *description_z, const afw_context_cb_variable_t *const *variables, int include_mask, afw_xctx_t *xctx)
Register context type id for array of current variable callbacks.
Definition: afw_context.c:135
#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_memory_copy(to, from)
Copy to preallocated memory of same type.
Definition: afw_memory.h:39
afw_model_get_object_type(const afw_model_t *model, const afw_utf8_t *object_type_id, afw_xctx_t *xctx)
Get the model object type for an object type id from model.
Definition: afw_model.c:21
#define afw_object_get_property(instance, property_name, xctx)
Call method get_property of interface afw_object.
#define afw_object_meta_get_object_type_id(instance, xctx)
Get object's object_type_id.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
afw_query_criteria_to_AdaptiveQueryCriteria_object(const afw_query_criteria_t *criteria, const afw_pool_t *p, afw_xctx_t *xctx)
Convert query criteria to a AdaptiveQueryCriteria object.
afw_xctx_push_qualifier_object(const afw_utf8_t *qualifier_name, const afw_object_t *qualifier_object, afw_boolean_t secure, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier object on to stack.
Definition: afw_xctx.c:406
afw_xctx_push_qualifier(const afw_utf8_t *qualifier, const afw_object_t *qualifier_object, afw_boolean_t secure, afw_xctx_get_variable_t get, void *data, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier on to stack.
Definition: afw_xctx.c:359
Internal request info used by afw_adaptor_impl*() functions.
Interface afw_adaptor public struct.
Struct used in afw_context_cb_variable_s.
Definition: afw_context.h:31
Struct passed to afw_context_type_register_cb_variables()
Definition: afw_context.h:43
Internal struct used by afw_model* functions.
const afw_value_t * modify_entries_value
Original entries for modify as list value.
Struct for afw_model_object_type_t property_type_other member.
const afw_model_t * model
Model containing this object type.
const afw_value_t * mapped_object_type_id_value
mappedObjectType value.
const afw_object_t * custom_variables
Custom variables.
const afw_utf8_t * mapped_object_type_id
mapped object type.
const afw_value_t * property_name_value
Property name as adaptive value.
const afw_object_t * custom_variables
constraint.
const afw_value_t * mapped_property_name_value
Mapped property name as adaptive value.
const afw_utf8_t * id
Object id or property name.
Definition: afw_common.h:782
Interface afw_object public struct.
Interface afw_pool public struct.
Struct for runtime objects.
Definition: afw_runtime.h:174
Struct for runtime object map property.
Definition: afw_runtime.h:99
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type null values.
Interface afw_value public struct.
Definition: afw_xctx.h:352
void * data
Data that will be passed to get/set.
Definition: afw_xctx.h:367
Interface afw_xctx public struct.