Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_lmdb_metadata.c
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework LMDB Adaptor Metadata
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #include "afw.h"
10 #include "afw_lmdb_internal.h"
11 #include "afw_lmdb_metadata.h"
12 
13 const afw_list_t * impl_get_schema_columns(
15  const afw_pool_t *p, afw_xctx_t *xctx);
16 
17 const afw_list_t * impl_get_schema_tables(
19  const afw_pool_t *p, afw_xctx_t *xctx);
20 
21 
22 /* Called by afw_lmdb_adaptor_session() to get a metadata object. */
25  const afw_utf8_t * object_type_id,
26  const afw_utf8_t * id,
27  const afw_query_criteria_t * criteria,
28  afw_xctx_t *xctx)
29 {
30  /* ObjectType. */
32  }
33 
34  AFW_THROW_ERROR_Z(not_found, "Not found.", xctx);
35 }
36 
38  afw_lmdb_adaptor_t *adaptor,
39  afw_xctx_t *xctx)
40 {
41  afw_lmdb_metadata_t *new_metadata;
42  afw_lmdb_metadata_t *old_metadata;
43  const afw_pool_t *p;
44 
45  /* Create a subpool for metadata in adaptor's pool. */
46  p = afw_pool_create(adaptor->pub.p, xctx);
47 
48  /* Allocate new afw_lmdb_metadata_t in subpool. */
49  new_metadata = afw_pool_calloc_type(p, afw_lmdb_metadata_t, xctx);
50  new_metadata->p = p;
51 
52  /* Start using new metadata. */
53  old_metadata = adaptor->metadata;
54  adaptor->metadata = new_metadata;
55  if (old_metadata) {
56  afw_pool_release(old_metadata->p, xctx);
57  }
58 
59  return;
60 }
61 
62 /* Used by afw_lmdb_adaptor_session() to retrieve metadata objects. */
65  const afw_utf8_t * object_type_id,
66  const afw_query_criteria_t * criteria,
67  afw_xctx_t *xctx)
68 {
69  /* ObjectType. */
71  }
72 
73  /* PropertyType. */
75  }
76 
77  /* If none of above, return empty list. */
78  return afw_list_create_generic(xctx->p, xctx);
79 }
80 
81 /* Determine if afw_lmdb_metadata.c handles an ObjectType. */
82 afw_boolean_t afw_lmdb_metadata_handles(const afw_utf8_t *object_type_id)
83 {
84  if (object_type_id && (
85  afw_utf8_starts_with_z(object_type_id,
87  ))
88  {
89  return AFW_TRUE;
90  }
91 
92  return AFW_FALSE;
93 }
Adaptive Framework Core API.
Adaptive Framework LMDB Adaptor Internal Header.
Adaptive Framework LMDB Adaptor Metadata handler.
const afw_list_t * afw_lmdb_metadata_retrieve_objects(afw_lmdb_adaptor_session_t *self, const afw_utf8_t *object_type_id, const afw_query_criteria_t *criteria, afw_xctx_t *xctx)
Called by afw_lmdb_adaptor_session() to retrieve metadata objects.
const afw_object_t * afw_lmdb_metadata_get_object(afw_lmdb_adaptor_session_t *self, const afw_utf8_t *object_type_id, const afw_utf8_t *id, const afw_query_criteria_t *criteria, afw_xctx_t *xctx)
Called by afw_lmdb_adaptor_session() to get a metadata object.
void afw_lmdb_metadata_refresh(afw_lmdb_adaptor_t *adaptor, afw_xctx_t *xctx)
Refreshes LMDB adaptors Metadata.
#define AFW_FALSE
Definition: afw_common.h:392
#define AFW_TRUE
Definition: afw_common.h:383
_Bool afw_boolean_t
Definition: afw_common.h:373
#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_create_generic(p, xctx)
Create an value list in memory.
Definition: afw_list.h:81
#define AFW_LMDB_Q_OBJECT_TYPE_SYNTHETIC_PREFIX
Definition: afw_lmdb.h:43
#define AFW_OBJECT_S_OBJECT_TYPE_ID_VALUE_META
String object type id for Property Type object.
Definition: afw_object.h:51
#define AFW_OBJECT_S_OBJECT_TYPE_ID_OBJECT_TYPE
String object type id for Object Type object.
Definition: afw_object.h:45
#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.
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.
Interface afw_list public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
Parsed query criteria.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_xctx public struct.