00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _H_factmngr
00026
00027 #define _H_factmngr
00028
00029 struct fact;
00030
00031 #ifndef _H_facthsh
00032 #include "facthsh.h"
00033 #endif
00034 #ifndef _H_conscomp
00035 #include "conscomp.h"
00036 #endif
00037 #ifndef _H_pattern
00038 #include "pattern.h"
00039 #endif
00040 #include "multifld.h"
00041 #ifndef _H_evaluatn
00042 #include "evaluatn.h"
00043 #endif
00044 #ifndef _H_tmpltdef
00045 #include "tmpltdef.h"
00046 #endif
00047
00048 struct fact
00049 {
00050 struct patternEntity factHeader;
00051 struct deftemplate *whichDeftemplate;
00052 void *list;
00053 long long factIndex;
00054 unsigned long hashValue;
00055 unsigned int depth : 15;
00056 unsigned int garbage : 1;
00057 struct fact *previousFact;
00058 struct fact *nextFact;
00059 struct fact *previousTemplateFact;
00060 struct fact *nextTemplateFact;
00061 struct multifield theProposition;
00062 };
00063
00064 #define FACTS_DATA 3
00065
00066 struct factsData
00067 {
00068 int ChangeToFactList;
00069 #if DEBUGGING_FUNCTIONS
00070 unsigned WatchFacts;
00071 #endif
00072 struct fact DummyFact;
00073 struct fact *GarbageFacts;
00074 struct fact *LastFact;
00075 struct fact *FactList;
00076 long long NextFactIndex;
00077 unsigned long NumberOfFacts;
00078 struct patternEntityRecord FactInfo;
00079 #if (! RUN_TIME) && (! BLOAD_ONLY)
00080 struct deftemplate *CurrentDeftemplate;
00081 #endif
00082 #if DEFRULE_CONSTRUCT && (! RUN_TIME) && DEFTEMPLATE_CONSTRUCT && CONSTRUCT_COMPILER
00083 struct CodeGeneratorItem *FactCodeItem;
00084 #endif
00085 struct factHashEntry **FactHashTable;
00086 unsigned long FactHashTableSize;
00087 intBool FactDuplication;
00088 #if DEFRULE_CONSTRUCT
00089 struct fact *CurrentPatternFact;
00090 struct multifieldMarker *CurrentPatternMarks;
00091 #endif
00092 long LastModuleIndex;
00093 };
00094
00095 #define FactData(theEnv) ((struct factsData *) GetEnvironmentData(theEnv,FACTS_DATA))
00096
00097 #ifdef LOCALE
00098 #undef LOCALE
00099 #endif
00100 #ifdef _FACTMNGR_SOURCE_
00101 #define LOCALE
00102 #else
00103 #define LOCALE extern
00104 #endif
00105
00106 #define Assert(a) EnvAssert(GetCurrentEnvironment(),a)
00107 #define AssertString(a) EnvAssertString(GetCurrentEnvironment(),a)
00108 #define AssignFactSlotDefaults(a) EnvAssignFactSlotDefaults(GetCurrentEnvironment(),a)
00109 #define CreateFact(a) EnvCreateFact(GetCurrentEnvironment(),a)
00110 #define DecrementFactCount(a) EnvDecrementFactCount(GetCurrentEnvironment(),a)
00111 #define GetFactListChanged() EnvGetFactListChanged(GetCurrentEnvironment())
00112 #define GetFactPPForm(a,b,c) EnvGetFactPPForm(GetCurrentEnvironment(),a,b,c)
00113 #define GetNextFact(a) EnvGetNextFact(GetCurrentEnvironment(),a)
00114 #define IncrementFactCount(a) EnvIncrementFactCount(GetCurrentEnvironment(),a)
00115 #define PutFactSlot(a,b,c) EnvPutFactSlot(GetCurrentEnvironment(),a,b,c)
00116 #define Retract(a) EnvRetract(GetCurrentEnvironment(),a)
00117 #define SetFactListChanged(a) EnvSetFactListChanged(GetCurrentEnvironment(),a)
00118
00119 #if ALLOW_ENVIRONMENT_GLOBALS
00120 LOCALE intBool GetFactSlot(void *,char *,DATA_OBJECT *);
00121 LOCALE long long FactIndex(void *);
00122 #endif
00123
00124 LOCALE void *EnvAssert(void *,void *);
00125 LOCALE void *EnvAssertString(void *,char *);
00126 LOCALE struct fact *EnvCreateFact(void *,void *);
00127 LOCALE void EnvDecrementFactCount(void *,void *);
00128 LOCALE long long EnvFactIndex(void *,void *);
00129 LOCALE intBool EnvGetFactSlot(void *,void *,char *,DATA_OBJECT *);
00130 LOCALE void PrintFactWithIdentifier(void *,char *,struct fact *);
00131 LOCALE void PrintFact(void *,char *,struct fact *,int,int);
00132 LOCALE void PrintFactIdentifierInLongForm(void *,char *,void *);
00133 LOCALE intBool EnvRetract(void *,void *);
00134 LOCALE void RemoveAllFacts(void *);
00135 LOCALE struct fact *CreateFactBySize(void *,unsigned);
00136 LOCALE void FactInstall(void *,struct fact *);
00137 LOCALE void FactDeinstall(void *,struct fact *);
00138 LOCALE void *EnvGetNextFact(void *,void *);
00139 LOCALE void *GetNextFactInScope(void *theEnv,void *);
00140 LOCALE void EnvGetFactPPForm(void *,char *,unsigned,void *);
00141 LOCALE int EnvGetFactListChanged(void *);
00142 LOCALE void EnvSetFactListChanged(void *,int);
00143 LOCALE unsigned long GetNumberOfFacts(void *);
00144 LOCALE void InitializeFacts(void *);
00145 LOCALE struct fact *FindIndexedFact(void *,long long);
00146 LOCALE void EnvIncrementFactCount(void *,void *);
00147 LOCALE void PrintFactIdentifier(void *,char *,void *);
00148 LOCALE void DecrementFactBasisCount(void *,void *);
00149 LOCALE void IncrementFactBasisCount(void *,void *);
00150 LOCALE void ReturnFact(void *,struct fact *);
00151 LOCALE void MatchFactFunction(void *,void *);
00152 LOCALE intBool EnvPutFactSlot(void *,void *,char *,DATA_OBJECT *);
00153 LOCALE intBool EnvAssignFactSlotDefaults(void *,void *);
00154 LOCALE intBool CopyFactSlotValues(void *,void *,void *);
00155 LOCALE intBool DeftemplateSlotDefault(void *,struct deftemplate *,
00156 struct templateSlot *,DATA_OBJECT *,int);
00157
00158 #ifndef _FACTMNGR_SOURCE_
00159 extern int ChangeToFactList;
00160 extern struct fact DummyFact;
00161 #if DEBUGGING_FUNCTIONS
00162 extern unsigned WatchFacts;
00163 #endif
00164 #endif
00165
00166 #endif
00167
00168
00169
00170
00171