Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_object_meta.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework afw_object Interface Meta Helpers
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_OBJECT_META_H
10 #define __AFW_OBJECT_META_H
11 
12 #include "afw_interface.h"
13 
28 
29 /* Struct for meta object self. */
31  afw_object_t pub;
32  afw_object_setter_t setter;
33 
34  /* Object type or NULL if not available. */
35  const afw_object_type_t *object_type;
36 
37  /*
38  * Delta from object type of current instance. This is often
39  * otherProperties.
40  */
41  const afw_object_t *delta;
42 };
43 
44 
50 #define afw_object_meta_object(instance) \
51  (const afw_object_t *)((instance)->meta.meta_object)
52 
53 
54 
61 AFW_DECLARE(void)
63  const afw_object_t *instance,
64  const afw_utf8_t *message,
65  afw_xctx_t *xctx);
66 
67 
68 
75 #define afw_object_meta_add_error_z(instance, \
76  message_z, xctx) \
77 afw_object_meta_add_error(instance, \
78  afw_utf8_create(message_z, AFW_UTF8_Z_LEN, (instance)->p, xctx), \
79  xctx)
80 
81 
82 
90 #define afw_object_meta_add_error_fz(instance, \
91  xctx, format_z, ...) \
92 afw_object_meta_add_error(instance, \
93  afw_utf8_printf((instance)->p, xctx, format_z, __VA_ARGS__), \
94  xctx)
95 
96 
97 
109 AFW_DECLARE(void)
111  const afw_object_t *instance,
112  const afw_object_t *object_type,
113  afw_xctx_t *xctx);
114 
115 
122 AFW_DECLARE(void)
124  const afw_object_t *instance,
125  const afw_error_t *error,
126  afw_xctx_t *xctx);
127 
128 
129 
137 AFW_DECLARE(void)
139  const afw_object_t *instance,
140  const afw_utf8_t *property_name,
141  const afw_utf8_t *message,
142  afw_xctx_t *xctx);
143 
144 
145 
153 #define afw_object_meta_add_property_error_z(instance, \
154  property_name, message_z, xctx) \
155 afw_object_meta_add_property_error(instance, property_name, \
156  afw_utf8_create(message_z, AFW_UTF8_Z_LEN, (instance)->p, xctx), \
157  xctx)
158 
159 
160 
169 #define afw_object_meta_add_property_error_fz(instance, \
170  property_name, xctx, format_z, ...) \
171 afw_object_meta_add_property_error(instance, property_name, \
172  afw_utf8_printf((instance)->p, xctx, format_z, __VA_ARGS__), \
173  xctx)
174 
175 
176 
187 AFW_DECLARE(void)
189  const afw_object_t *instance,
190  const afw_utf8_t *property_name,
191  afw_integer_t index,
192  const afw_error_t *error,
193  afw_xctx_t *xctx);
194 
195 
196 
205  const afw_object_t *instance,
206  afw_xctx_t *xctx);
207 
208 
215 AFW_DECLARE(void)
217  const afw_object_t *instance,
218  const afw_utf8_t *source_location,
219  afw_xctx_t *xctx);
220 
221 
239 AFW_DECLARE(const afw_object_t *)
241  const afw_object_t *instance,
242  const afw_object_options_t *options,
243  const afw_pool_t *p,
244  afw_xctx_t *xctx);
245 
246 
256  const afw_object_t *instance,
257  afw_xctx_t *xctx);
258 
259 
260 
268 AFW_DECLARE(const afw_object_t *)
270  const afw_object_t *instance,
271  afw_xctx_t *xctx);
272 
273 
274 
282 #define afw_object_meta_get_property(instance, property_name, xctx) \
283 (instance->meta.meta_object) \
284  ? afw_object_get_property(afw_object_meta_object(instance), \
285  property_name, xctx) \
286  : NULL
287 
288 
289 
297 #define afw_object_meta_get_property_as_string(instance, \
298  property_name, xctx) \
299 (instance->meta.meta_object) \
300  ? afw_object_old_get_property_as_string( \
301  afw_object_meta_object(instance), \
302  property_name, xctx) \
303  : NULL
304 
305 
306 
313 #define afw_object_meta_get_embedding_object(instance, xctx) \
314 ((instance)->embedding_object)
315 
316 
317 
324 AFW_DECLARE(const afw_utf8_t *)
326  const afw_object_t *instance,
327  afw_xctx_t *xctx);
328 
329 
336 #define afw_object_meta_get_object_type_id(instance, xctx) \
337 ( \
338  (instance)->meta.object_type_uri && \
339  (instance)->meta.object_type_uri->len != 0 \
340 ) \
341 ? (instance)->meta.object_type_uri : NULL
342 
343 
344 
351 AFW_DECLARE(const afw_utf8_t *)
353  const afw_object_t *instance,
354  afw_xctx_t *xctx);
355 
356 
357 
366  const afw_object_t *instance,
367  afw_xctx_t *xctx);
368 
369 
370 
379 AFW_DECLARE(void)
381  const afw_object_t *instance,
382  const afw_utf8_t *parent_path,
383  afw_xctx_t *xctx);
384 
385 
386 
395  const afw_object_t *instance,
396  afw_xctx_t *xctx);
397 
398 
399 
414 AFW_DECLARE(const afw_utf8_t *)
416  const afw_object_t *instance,
417  afw_xctx_t *xctx);
418 
419 
420 
428 AFW_DECLARE(const afw_object_t *)
430  const afw_object_t *instance,
431  const afw_utf8_t *property_name,
432  afw_xctx_t *xctx);
433 
434 
435 
448 AFW_DEFINE(void)
450  const afw_object_t *instance,
451  const afw_object_t *meta,
452  afw_xctx_t *xctx);
453 
454 
455 
465 AFW_DECLARE(const afw_object_t *)
467  const afw_object_t *instance,
468  afw_xctx_t *xctx);
469 
470 
471 
484 AFW_DECLARE(void)
486  const afw_object_t *instance,
487  const afw_utf8_t *adaptor_id,
488  const afw_utf8_t *object_type_id,
489  const afw_utf8_t *object_id,
490  afw_xctx_t *xctx);
491 
492 
493 
504 AFW_DECLARE(void)
506  const afw_object_t *instance,
507  const afw_utf8_t *path,
508  afw_xctx_t *xctx);
509 
510 
511 
519 AFW_DECLARE(void)
521  const afw_object_t *instance,
522  afw_xctx_t *xctx);
523 
524 
525 
534 AFW_DECLARE(void)
536  const afw_object_t *instance,
537  const afw_object_type_t *object_type,
538  afw_xctx_t *xctx);
539 
540 
541 
550 AFW_DECLARE(void)
552  const afw_object_t *instance,
553  const afw_utf8_t *object_type_id,
554  afw_xctx_t *xctx);
555 
556 
557 
564 AFW_DECLARE(void)
566  const afw_object_t *instance,
567  const afw_value_list_t *parent_paths,
568  afw_xctx_t *xctx);
569 
570 
571 
579 #define afw_object_meta_set_property(instance, property_name, value, xctx) \
580 afw_object_set_property( \
581  afw_object_meta_get_nonempty_delta(instance, xctx), property_name, value, xctx)
582 
583 
584 
592 #define afw_object_meta_set_property_from_utf8_z(instance, \
593  property_name, string_z, xctx) \
594 afw_object_set_property_as_string_from_utf8_z( \
595  afw_object_meta_get_nonempty_delta(instance, xctx), \
596  property_name, string_z, xctx)
597 
598 
599 
608 #define afw_object_meta_set_property_as(instance, property_name, \
609  data_type, value, xctx) \
610 afw_object_set_property_as_ ## data_type( \
611  afw_object_meta_get_nonempty_delta(instance, xctx), \
612  property_name, value, xctx)
613 
614 
615 
624 #define afw_object_meta_set_property_type_property(instance, \
625  property_name, property_type_property_name, value, xctx) \
626 afw_object_set_property( \
627  afw_object_meta_get_property_type(instance, property_name, xctx), \
628  property_type_property_name, value, xctx)
629 
630 
631 
641 #define afw_object_meta_set_property_type_property_from_utf8_z(instance, \
642  property_name, property_type_property_name, string_z, xctx) \
643 afw_object_set_property_as_string_from_utf8_z( \
644  afw_object_meta_get_property_type(instance, property_name, xctx), \
645  property_type_property_name, string_z, xctx)
646 
647 
648 
659 #define afw_object_meta_set_property_type_property_as(instance, \
660  property_name, property_type_property_name, \
661  data_type, value, xctx) \
662 afw_object_set_property_as_ ## data_type( \
663  afw_object_meta_get_property_type(instance, property_name, xctx), \
664  property_type_property_name, value, xctx)
665 
666 
667 
678 AFW_DECLARE(void)
680  const afw_object_t *instance,
681  const afw_object_t *from,
682  afw_xctx_t *xctx);
683 
684 
685 
686 AFW_END_DECLARES
687 
690 #endif /* __AFW_OBJECT_META_H */
AFW_DEFINE(const afw_object_t *)
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
_Bool afw_boolean_t
Definition: afw_common.h:373
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
const afw_value_string_t * afw_object_meta_get_object_id_value(const afw_object_t *instance, afw_xctx_t *xctx)
Get entity object's object id value.
void afw_object_meta_set_object_type(const afw_object_t *instance, const afw_object_type_t *object_type, afw_xctx_t *xctx)
Set object's object type id.
void afw_object_meta_add_thrown_error(const afw_object_t *instance, const afw_error_t *error, afw_xctx_t *xctx)
Add a thrown error to instance's meta.
const afw_object_t * afw_object_meta_get_property_type(const afw_object_t *instance, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Get the property type object for an object's property from the meta of an object, creating it if need...
void afw_object_meta_set_ids_using_path(const afw_object_t *instance, const afw_utf8_t *path, afw_xctx_t *xctx)
Set object's ids using path.
void afw_object_meta_add_parent_path(const afw_object_t *instance, const afw_utf8_t *parent_path, afw_xctx_t *xctx)
Add a parent path to instance's meta.
void 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.
const afw_utf8_t * afw_object_meta_get_property_name(const afw_object_t *instance, afw_xctx_t *xctx)
Get object's property name in embedding object.
const afw_utf8_t * afw_object_meta_get_path(const afw_object_t *instance, afw_xctx_t *xctx)
Get an object's path.
const afw_object_meta_object_t * afw_object_meta_get_nonempty_meta_object(const afw_object_t *instance, afw_xctx_t *xctx)
Return meta object for an object creating an empty one if needed.
void afw_object_meta_set_object_type_id(const afw_object_t *instance, const afw_utf8_t *object_type_id, afw_xctx_t *xctx)
Set object's object type id.
const afw_object_t * 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.
void afw_object_meta_set_read_only(const afw_object_t *instance, afw_xctx_t *xctx)
Set object's meta to indicate object is read-only.
void afw_object_meta_add_error(const afw_object_t *instance, const afw_utf8_t *message, afw_xctx_t *xctx)
Add an error message to instance's meta.
const afw_object_t * afw_object_meta_create_accessor_with_options(const afw_object_t *instance, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Create an object instance to access an object's meta with options.
void afw_object_meta_clone_and_set(const afw_object_t *instance, const afw_object_t *from, afw_xctx_t *xctx)
Set object's meta using a clone of the meta of another object.
const afw_value_list_t * afw_object_meta_get_parent_paths_value(const afw_object_t *instance, afw_xctx_t *xctx)
Get meta parentPaths property value.
void afw_object_meta_add_property_error(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_t *message, afw_xctx_t *xctx)
Add an error message for a property to instance's meta.
void afw_object_meta_add_needed_object_type(const afw_object_t *instance, const afw_object_t *object_type, afw_xctx_t *xctx)
Add a needed object type object.
afw_object_meta_set_meta_object(const afw_object_t *instance, const afw_object_t *meta, afw_xctx_t *xctx)
Set an object's meta from a meta object.
const afw_object_t * afw_object_meta_set_empty(const afw_object_t *instance, afw_xctx_t *xctx)
Create and set object's meta to an empty object and return delta.
afw_boolean_t afw_object_meta_has_errors(const afw_object_t *instance, afw_xctx_t *xctx)
Check if object flagged for errors.
void afw_object_meta_log_errors(const afw_object_t *instance, const afw_utf8_t *source_location, afw_xctx_t *xctx)
Log meta errors.
void afw_object_meta_add_thrown_property_error(const afw_object_t *instance, const afw_utf8_t *property_name, afw_integer_t index, const afw_error_t *error, afw_xctx_t *xctx)
Add a thrown error for a property to instance's meta.
void afw_object_meta_set_ids(const afw_object_t *instance, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Set object's ids.
const afw_utf8_t * afw_object_meta_get_object_id(const afw_object_t *instance, afw_xctx_t *xctx)
Get entity object's object id.
Adaptive Framework Error.
Definition: afw_error.h:65
Struct for object processing options.
Interface afw_object public struct.
Interface afw_object_setter public struct.
Struct for afw_object_type_t.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type list values.
struct for data type string values.
Interface afw_xctx public struct.