00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLANG_DATABASE_H
00021 #define PLANG_DATABASE_H
00022
00023 #include <plang/term.h>
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029 typedef enum {
00030 P_OP_NONE,
00031 P_OP_XF,
00032 P_OP_YF,
00033 P_OP_XFX,
00034 P_OP_XFY,
00035 P_OP_YFX,
00036 P_OP_FX,
00037 P_OP_FY
00038 } p_op_specifier;
00039
00040 typedef enum {
00041 P_PREDICATE_NONE = 0x00,
00042 P_PREDICATE_COMPILED = 0x01,
00043 P_PREDICATE_DYNAMIC = 0x02,
00044 P_PREDICATE_BUILTIN = 0x04
00045 } p_predicate_flags;
00046
00047 p_op_specifier p_db_operator_info(const p_term *name, int arity, int *priority);
00048 void p_db_set_operator_info(p_term *name, p_op_specifier specifier, int priority);
00049
00050 typedef p_goal_result (*p_db_builtin)(p_context *context, p_term **args, p_term **error);
00051 p_db_builtin p_db_builtin_predicate(const p_term *name, int arity);
00052 void p_db_set_builtin_predicate(p_term *name, int arity, p_db_builtin builtin);
00053
00055 typedef struct {
00056 int type;
00057 union {
00058 int integer_value;
00059 double real_value;
00060 p_term *string_value;
00061 };
00062 } p_arith_value;
00065 typedef p_goal_result (*p_db_arith)(p_context *context, p_arith_value *result, const p_arith_value *values, p_term **args, p_term **error);
00066 p_db_arith p_db_builtin_arith(const p_term *name, int arity);
00067 void p_db_set_builtin_arith(p_term *name, int arity, p_db_arith builtin);
00068
00069 int p_db_clause_assert_first(p_context *context, p_term *clause);
00070 int p_db_clause_assert_last(p_context *context, p_term *clause);
00071 int p_db_clause_retract(p_context *context, p_term *clause);
00072 int p_db_clause_abolish(p_context *context, const p_term *name, int arity);
00073
00074 int p_db_local_clause_assert_first(p_context *context, p_term *database, p_term *clause);
00075 int p_db_local_clause_assert_last(p_context *context, p_term *database, p_term *clause);
00076 int p_db_local_clause_retract(p_context *context, p_term *database, p_term *clause);
00077 int p_db_local_clause_abolish(p_context *context, p_term *database, const p_term *name, int arity);
00078
00079 p_predicate_flags p_db_predicate_flags(p_context *context, const p_term *name, int arity);
00080 void p_db_set_predicate_flag(p_context *context, p_term *name, int arity, p_predicate_flags flag, int value);
00081
00082 #ifdef __cplusplus
00083 };
00084 #endif
00085
00086 #endif