⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clipsmfc_old.h

📁 clips专家系统内核打包类,很有参考性.
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef	_CLIPSWrap
	#define _CLIPSWrap
/////////////////////////////////////////////////////////////////////////////
// CCLIPSWrap defintion 

//CLIPS core code version
#define CLIPS_BUILD_VER 610
//define number of routes to handle
#define NUMROUTES		100
//define number of user routes to handle
// #define NUM_U_ROUTES	100
//define the maximum length of a fact string
#define MAX_FACT_LEN	640
//define max length of an item
#define MAX_ITEM_SIZE	640
//define max length of a list
#define MAX_LIST_SIZE	32000
//define number of iterations between msg pump calls
#define MAX_MSG_PUMP	1
//size of temp buffer variable
#define MBUFSIZE		1024

#ifndef __AFX_H__
	#include <afx.h>
#endif
#ifndef __AFXCOLL_H__
	#include <afxcoll.h>
#endif

#include <dynclips.h>
#include <dynaload.h>

#define DllExport	__declspec( dllexport )

//set this to 1 if you want ODBC support...
//remember to include rsvarcol.cpp into yor project as well
#define USE_ODBC 0
 #ifdef USE_ODBC
	#ifndef __AFXDB_H__
		#include <afxdb.h>
	#endif
	#ifndef _RSVARCOL_H_
		#include <rsvarcol.h>
	#endif
#endif

//prototype for route ordinal function
int GetRouteNum(int start, const char far* route);
//default router check function
bool IsDefaultRouter(const char *route);

//prototype for message pump callback
extern "C"	{
void DllExport MsgLoopProc(void);
}
#ifndef __defc
extern int Defcount;
#endif

//a handy macro to check for CLIPSInit and return something on fail
#define INITCHK(p)	if(!m_fClipsInit)	 {	\
						return p;}
//macro to clear the temp buffer
#define CLEARMBUF	memset(m_buf,0,MBUFSIZE);
#define SETMBUF(s)  CLEARMBUF strcpy(m_buf,s);
#define BOOLCHK(s)  (s) ? true : false

// just in case the CLIPS headers are not in 
// the preprocessor stack for this pass
#ifndef FACT_ADDRESS
	#define FACT_ADDRESS		6	
#endif
#ifndef INSTANCE_ADDRESS
	#define INSTANCE_ADDRESS	7
#endif

//the wrapper class
class CCLIPSWrap
{
	//declarations for the FN pointers to CLIPS functions
	FORM_02		dl_ExitCLIPS;
	FORM_01		dl_Reset;
	FORM_04		dl_GetFactPPForm;
	FORM_30		dl_GetNextFact;
	FORM_40		dl_Run;
	FORM_11		dl_Load;
	FORM_41		dl_GetNumberOfFacts;
	FORM_01		dl_Clear;
	FORM_11		dl_BatchStar;
	FORM_11		dl_Bsave;
	FORM_11		dl_Bload;
	FORM_11     dl_Build;
	FORM_14		dl_Retract;
	FORM_11		dl_Watch;
	FORM_11		dl_Unwatch;
	FORM_34		dl_Matches;
	FORM_12		dl_SaveFacts;
	FORM_11		dl_LoadFacts;
	FORM_10		dl_SetFactDuplication;
	FORM_13		dl_GetFactDuplication;
	FORM_13		dl_DribbleOff;
	FORM_11		dl_DribbleOn;
	FORM_32		dl_AssertString;
	FORM_30		dl_Assert;
	FORM_03		dl_IncrementFactCount;
	FORM_03		dl_DecrementFactCount;
	FORM_13		dl_GetFactListChanged;
	FORM_02		dl_SetFactListChanged;
	FORM_33		dl_GetNextInstanceInClass;
	FORM_30		dl_GetNextInstanceInScope;
	FORM_30		dl_GetNextInstance;
	FORM_30		dl_GetInstanceClass;
	FORM_50		dl_GetInstanceName;
	FORM_04		dl_GetInstancePPForm;
	FORM_34		dl_CreateRawInstance;
	FORM_14		dl_ValidInstanceAddress;
	FORM_42		dl_SaveInstances;
	FORM_43		dl_LoadInstances;
	FORM_10		dl_SetStrategy;
	FORM_13		dl_GetStrategy;
	FORM_32		dl_AddSymbol;
	FORM_37		dl_AddLong;
	FORM_38		dl_AddDouble;
	FORM_41		dl_MemUsed;
	FORM_41		dl_MemRequests;
	FORM_35		dl_WRGetFocus;
	FORM_01		dl_RemoveAllFacts; 
	FORM_04		dl_GetDefglobalValueForm;
	FORM_32		dl_FindDefglobal;
	FORM_17		dl_GetDefglobalValue;
	FORM_30		dl_GetNextDefglobal;
	FORM_14		dl_Undefglobal;
	FORM_11		dl_CloseStringSource;
	FORM_11		dl_LoadConstructsFromLogicalName;
	FORM_15		dl_OpenStringSource;
	FORM_11		dl_Batch;
	FORM_44		dl_ReleaseMem;
	FORM_01		dl_FreeAtomicValueStorage;
	FORM_02		dl_SetHaltExecution;
	FORM_32		dl_MakeInstance;
	FORM_36		dl_FindInstance;
	FORM_14		dl_DeleteInstance; 
	FORM_60		dl_GetGlobalNumberOfInstances;
	FORM_06		dl_DirectGetSlot;
	FORM_16		dl_DirectPutSlot;
	FORM_21		dl_RouteCommand;
	FORM_16		dl_GetFactSlot;
	FORM_16		dl_PutFactSlot;
	FORM_01		dl_InitializeCLIPS;
	FORM_18		dl_AddPeriodicFunction;
	FORM_31		dl_SetOutOfMemoryFunction;
	FORM_02		dl_SetPrintWhileLoading;
	FORM_100	dl_VERSION;
	FORM_14     dl_AssignFactSlotDefaults;
	FORM_30		dl_CreateFact;
	FORM_32     dl_FindDeftemplate;
	FORM_11     dl_ParseDefglobal;
	ADDROUTER	dl_AddRouter;
	FORM_05		dl_Agenda;
	FORM_35		dl_GetCurrentModule;
	FORM_30     dl_GetNextActivation;
	FORM_30		dl_GetNextDefclass;
	FORM_07		dl_Send;
	//new 2.0
	FORM_11		dl_DeleteRouter;
	FORM_61		dl_DefineFunction2;
	FORM_13		dl_RtnArgCount;
	FORM_19		dl_ArgCountCheck;
	FORM_19		dl_ArgRangeCheck;
	FORM_51		dl_RtnLexeme;
	FORM_70		dl_RtnDouble;
	FORM_45		dl_RtnLong;
	FORM_3A		dl_RtnUnknown;
	FORM_20		dl_ArgTypeCheck;
	FORM_39		dl_CreateMultifield;
	FORM_03		dl_SetMultifieldErrorValue;
	//new 3.0
	FORM_08		dl_PeriodicCleanup;
	FORM_18     dl_AddResetFunction;


	HINSTANCE	m_hLib;
	
	//CLIPS exception object
	class CLIPSException	{
		CString	Why;
	public:	//construction & destruction
		CLIPSException() {
			Why = "UnKnown";
		}
		CLIPSException(CString &Text)	{
			Why = Text;
		}
		CLIPSException(const char *szText)	{
			Why = szText;
		}
		virtual ~CLIPSException() {}

	public:	//methods
		void SetWhy(const char *szText)	{
			Why = szText;
		}
		void SetWhy(CString &Text)	{
			Why = Text;
		}
		const char *GetWhy()	{
			return (LPCSTR)Why;
		}
	};

public:
	//constructor and destructor are public
	CCLIPSWrap(int count = -1);
	virtual ~CCLIPSWrap(void);

//UserFunction return types
enum UDF_ReturnValues 
{
UDFReturn_External_Address = (unsigned) 'a',
UDFReturn_Boolean = (unsigned) 'b',
UDFReturn_Character = (unsigned) 'c',
UDFReturn_Double_Prec_Float = (unsigned) 'd',
UDFReturn_Single_Prec_Float = (unsigned) 'f',
UDFReturn_Integer = (unsigned) 'i',
UDFReturn_Symbol_String_or_InstanceName = (unsigned) 'j',
UDFReturn_Symbol_or_String = (unsigned) 'k',
UDFReturn_Long_Integer = (unsigned) 'l',
UDFReturn_Multifield = (unsigned) 'm',
UDFReturn_Integer_or_Float = (unsigned) 'n',
UDFReturn_Instance_Name = (unsigned) 'o',
UDFReturn_String = (unsigned) 's',
UDFReturn_Any = (unsigned) 'u',
UDFReturn_Void = (unsigned) 'v',
UDFReturn_Symbol = (unsigned) 'w',
UDFReturn_Instance_Address = (unsigned) 'x'
};

//Load file return codes
enum LoadStatus	{
	READ_FAIL,
	PARSE_FAIL,
	READ_OK,
	BAD_LOAD_NAME,
	READ_NOT_INIT,
	};

//Save file return codes
enum SaveStatus	{
	SAVE_FAIL,
	SAVE_OK,
	BAD_SAVE_NAME,
	SAVE_NOT_INIT,
	};

//class instance cases
enum InstanceCase	{
	I_PERIOD,
	I_SCOPE,
	I_CLASS
	};

// Attributes
protected:
	//CLIPS struct pointers
	//these are now (3.0) explicitly declared as the
	//correct pointer types rather than void *
	struct fact			*factPtr;
	struct defmodule	*modulePtr;
	struct defrule		*rulePtr;
	struct defglobal	*globalPtr;
	struct instance		*instancePtr;
	struct defclass		*classPtr;
	struct activation	*activationPtr;
	struct deftemplate	*templatePtr;
	struct instanceSlot *insSlotPtr;
	struct templateSlot *tempSlotPtr;
	//other internal stuff

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -