This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-maat/src/inc_internal/maat_ex_data.h

94 lines
3.2 KiB
C
Raw Normal View History

2022-11-17 05:05:35 +08:00
/*
**********************************************************************************************
* File: maat_ex_data.h
* Description: ex data
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_EX_DATA_H_
#define _MAAT_EX_DATA_H_
#ifdef __cpluscplus
extern "C"
{
#endif
2023-01-30 21:59:35 +08:00
#include "maat/maat.h"
2022-11-25 16:32:29 +08:00
#include "rcu_hash.h"
2022-12-09 17:12:18 +08:00
struct ex_data_container {
void *ex_data;
void *custom_data;
};
2023-01-30 21:59:35 +08:00
struct ex_container_ctx {
int table_id;
void (*custom_data_free)(void *custom_data);
struct ex_data_schema *ex_schema;
};
2022-11-17 05:05:35 +08:00
struct ex_data_runtime;
2022-11-25 16:32:29 +08:00
/* ex_data_runtime API */
struct ex_data_runtime *ex_data_runtime_new(int table_id, rcu_hash_data_free_fn *data_free_fn);
2022-11-17 05:05:35 +08:00
void ex_data_runtime_free(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
void ex_data_runtime_commit(struct ex_data_runtime *ex_data_rt);
/* ex_data_runtime cache row API */
void ex_data_runtime_cache_row_put(struct ex_data_runtime *ex_data_rt, const char *row);
const char *ex_data_runtime_cached_row_get(struct ex_data_runtime *ex_data_rt, size_t index);
size_t ex_data_runtime_cached_row_count(struct ex_data_runtime *ex_data_rt);
void ex_data_runtime_clear_row_cache(struct ex_data_runtime *ex_data_rt);
/* set schema API */
2023-01-30 21:59:35 +08:00
struct ex_data_schema *ex_data_schema_new(maat_plugin_ex_new_func_t *new_func,
maat_plugin_ex_free_func_t *free_func,
maat_plugin_ex_dup_func_t *dup_func,
long argl, void *argp);
void ex_data_schema_free(struct ex_data_schema *ex_schema);
2022-11-25 16:32:29 +08:00
void ex_data_runtime_set_schema(struct ex_data_runtime *ex_data_rt, struct ex_data_schema *schema);
/* set user_ctx API */
2022-12-09 17:12:18 +08:00
void ex_data_runtime_set_ex_container_ctx(struct ex_data_runtime *ex_data_rt, struct ex_container_ctx *container_ctx);
struct ex_container_ctx *ex_data_runtime_get_ex_container_ctx(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
2023-01-30 21:59:35 +08:00
struct ex_data_container *ex_data_container_new(void *ex_data, void *custom_data);
void ex_data_container_free(void *ctx, void *data);
2022-11-25 16:32:29 +08:00
/* ex_data_runtime ex data API */
2023-01-30 21:59:35 +08:00
void *ex_data_runtime_row2ex_data(struct ex_data_runtime *ex_data_rt,
const char *row, const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
2023-01-30 21:59:35 +08:00
int ex_data_runtime_add_ex_container(struct ex_data_runtime *ex_data_rt,
const char *key, size_t key_len,
struct ex_data_container *ex_container);
2022-12-09 17:12:18 +08:00
2023-01-30 21:59:35 +08:00
int ex_data_runtime_del_ex_container(struct ex_data_runtime *ex_data_rt,
const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
2023-01-30 21:59:35 +08:00
size_t ex_data_runtime_list_updating_ex_container(struct ex_data_runtime *ex_data_rt,
struct ex_data_container ***ex_container);
2022-11-25 16:32:29 +08:00
2023-01-30 21:59:35 +08:00
void *ex_data_runtime_get_ex_data(struct ex_data_runtime *ex_data_rt, const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
2022-12-09 17:12:18 +08:00
void *ex_data_runtime_get_custom_data(struct ex_data_runtime *ex_data_rt, const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
2022-12-09 17:12:18 +08:00
size_t ex_data_runtime_ex_container_count(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
int ex_data_runtime_updating_flag(struct ex_data_runtime *ex_data_rt);
2022-11-17 05:05:35 +08:00
#ifdef __cpluscplus
}
#endif
#endif