2024-08-15 21:57:17 +03:00
|
|
|
#include "module_registry.h"
|
|
|
|
|
2024-08-18 15:44:39 +03:00
|
|
|
static GraphNodeSpecificationRegistry registry;
|
2024-08-15 21:57:17 +03:00
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
static void
|
|
|
|
ensure_initialized()
|
|
|
|
{
|
|
|
|
if (!initialized) {
|
|
|
|
hash_table_init(®istry, NULL);
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_graph_node_specification(GraphNodeSpecification * spec)
|
|
|
|
{
|
|
|
|
ensure_initialized();
|
|
|
|
if (!spec->name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hash_table_insert(®istry, hash_table_key_from_cstr(spec->name), &spec);
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphNodeSpecification *
|
|
|
|
lookup_graph_node_specification(const char * name)
|
|
|
|
{
|
|
|
|
ensure_initialized();
|
|
|
|
HashTableIndex idx = hash_table_find(®istry, hash_table_key_from_cstr(name));
|
|
|
|
if (idx < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return registry.value_array[idx];
|
|
|
|
}
|
|
|
|
|
2024-08-18 15:44:39 +03:00
|
|
|
const GraphNodeSpecificationRegistry *
|
|
|
|
get_graph_node_specification_registy()
|
|
|
|
{
|
|
|
|
ensure_initialized();
|
|
|
|
return ®istry;
|
|
|
|
}
|
|
|
|
|
2024-08-18 15:43:19 +03:00
|
|
|
__attribute__((destructor)) void
|
2024-08-15 21:57:17 +03:00
|
|
|
destroy_graph_node_specification_registry()
|
|
|
|
{
|
|
|
|
ensure_initialized();
|
|
|
|
hash_table_deinit(®istry);
|
|
|
|
initialized = false;
|
|
|
|
}
|