📄 classcom.c
字号:
return(RemoveAllUserClasses()); return(DeleteClassUAG(cls));#endif }#if DEBUGGING_FUNCTIONS/********************************************************* NAME : PPDefclassCommand DESCRIPTION : Displays the pretty print form of a class to the wdialog router. INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : None NOTES : Syntax : CLIPS> (ppdefclass <class-name>) *********************************************************/globle VOID PPDefclassCommand() { PPConstructCommand("ppdefclass",DefclassConstruct); } /*************************************************** NAME : ListDefclassesCommand DESCRIPTION : Displays all defclass names INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Defclass names printed NOTES : CLIPS Interface ***************************************************/globle VOID ListDefclassesCommand() { ListConstructCommand("list-defclasses",DefclassConstruct); }/*************************************************** NAME : ListDefclasses DESCRIPTION : Displays all defclass names INPUTS : 1) The logical name of the output 2) The module RETURNS : Nothing useful SIDE EFFECTS : Defclass names printed NOTES : C Interface ***************************************************/globle VOID ListDefclasses(logicalName,theModule) char *logicalName; struct defmodule *theModule; { ListConstruct(DefclassConstruct,logicalName,theModule); }/********************************************************* NAME : GetDefclassWatchInstances DESCRIPTION : Determines if deletions/creations of instances of this class will generate trace messages or not INPUTS : A pointer to the class RETURNS : CLIPS_TRUE if a trace is active, CLIPS_FALSE otherwise SIDE EFFECTS : None NOTES : None *********************************************************/globle BOOLEAN GetDefclassWatchInstances(theClass) VOID *theClass; { return(((DEFCLASS *) theClass)->traceInstances); } /********************************************************* NAME : SetDefclassWatchInstances DESCRIPTION : Sets the trace to ON/OFF for the creation/deletion of instances of the class INPUTS : 1) CLIPS_TRUE to set the trace on, CLIPS_FALSE to set it off 2) A pointer to the class RETURNS : Nothing useful SIDE EFFECTS : Watch flag for the class set NOTES : None *********************************************************/globle VOID SetDefclassWatchInstances(newState,theClass) int newState; VOID *theClass; { if (((DEFCLASS *) theClass)->abstract) return; ((DEFCLASS *) theClass)->traceInstances = newState; } /********************************************************* NAME : GetDefclassWatchSlots DESCRIPTION : Determines if changes to slots of instances of this class will generate trace messages or not INPUTS : A pointer to the class RETURNS : CLIPS_TRUE if a trace is active, CLIPS_FALSE otherwise SIDE EFFECTS : None NOTES : None *********************************************************/globle BOOLEAN GetDefclassWatchSlots(theClass) VOID *theClass; { return(((DEFCLASS *) theClass)->traceSlots); } /********************************************************** NAME : SetDefclassWatchSlots DESCRIPTION : Sets the trace to ON/OFF for the changes to slots of instances of the class INPUTS : 1) CLIPS_TRUE to set the trace on, CLIPS_FALSE to set it off 2) A pointer to the class RETURNS : Nothing useful SIDE EFFECTS : Watch flag for the class set NOTES : None **********************************************************/globle VOID SetDefclassWatchSlots(newState,theClass) int newState; VOID *theClass; { ((DEFCLASS *) theClass)->traceSlots = newState; } /****************************************************************** NAME : DefclassWatchAccess DESCRIPTION : Parses a list of class names passed by AddWatchItem() and sets the traces accordingly INPUTS : 1) A code indicating which trace flag is to be set 0 - Watch instance creation/deletion 1 - Watch slot changes to instances 2) The value to which to set the trace flags 3) A list of expressions containing the names of the classes for which to set traces RETURNS : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Watch flags set in specified classes NOTES : Accessory function for AddWatchItem() ******************************************************************/globle BOOLEAN DefclassWatchAccess(code,newState,argExprs) int code,newState; EXPRESSION *argExprs; { if (code) return(ConstructSetWatchAccess(DefclassConstruct,newState,argExprs, GetDefclassWatchSlots,SetDefclassWatchSlots)); else return(ConstructSetWatchAccess(DefclassConstruct,newState,argExprs, GetDefclassWatchInstances,SetDefclassWatchInstances)); } /*********************************************************************** NAME : DefclassWatchPrint DESCRIPTION : Parses a list of class names passed by AddWatchItem() and displays the traces accordingly INPUTS : 1) The logical name of the output 2) A code indicating which trace flag is to be examined 0 - Watch instance creation/deletion 1 - Watch slot changes to instances 3) A list of expressions containing the names of the classes for which to examine traces RETURNS : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise SIDE EFFECTS : Watch flags displayed for specified classes NOTES : Accessory function for AddWatchItem() ***********************************************************************/globle BOOLEAN DefclassWatchPrint(log,code,argExprs) char *log; int code; EXPRESSION *argExprs; { if (code) return(ConstructPrintWatchAccess(DefclassConstruct,log,argExprs, GetDefclassWatchSlots,SetDefclassWatchSlots)); else return(ConstructPrintWatchAccess(DefclassConstruct,log,argExprs, GetDefclassWatchInstances,SetDefclassWatchInstances)); } #endif/********************************************************* NAME : GetDefclassListFunction DESCRIPTION : Groups names of all defclasses into a multifield variable INPUTS : A data object buffer RETURNS : Nothing useful SIDE EFFECTS : Multifield set to list of classes NOTES : None *********************************************************/globle VOID GetDefclassListFunction(returnValue) DATA_OBJECT_PTR returnValue; { GetConstructListFunction("get-defclass-list",returnValue,DefclassConstruct); } /*************************************************************** NAME : GetDefclassList DESCRIPTION : Groups all defclass names into a multifield list INPUTS : 1) A data object buffer to hold the multifield result 2) The module from which to obtain defclasses RETURNS : Nothing useful SIDE EFFECTS : Multifield allocated and filled NOTES : External C access ***************************************************************/globle VOID GetDefclassList(returnValue,theModule) DATA_OBJECT *returnValue; struct defmodule *theModule; { GetConstructList(returnValue,DefclassConstruct,theModule); } /***************************************************** NAME : HasSuperclass DESCRIPTION : Determines if class-2 is a superclass of class-1 INPUTS : 1) Class-1 2) Class-2 RETURNS : CLIPS_TRUE if class-2 is a superclass of class-1, CLIPS_FALSE otherwise SIDE EFFECTS : None NOTES : None *****************************************************/globle int HasSuperclass(c1,c2) DEFCLASS *c1,*c2; { register unsigned i; for (i = 1 ; i < c1->allSuperclasses.classCount ; i++) if (c1->allSuperclasses.classArray[i] == c2) return(CLIPS_TRUE); return(CLIPS_FALSE); } /******************************************************************** NAME : CheckClassAndSlot DESCRIPTION : Checks class and slot argument for various functions INPUTS : 1) Name of the calling function 2) Buffer for class address RETURNS : Slot symbol, NULL on errors SIDE EFFECTS : None NOTES : None ********************************************************************/globle SYMBOL_HN *CheckClassAndSlot(func,cls) char *func; DEFCLASS **cls; { DATA_OBJECT temp; if (ArgTypeCheck(func,1,SYMBOL,&temp) == CLIPS_FALSE) return(NULL); *cls = LookupDefclassByMdlOrScope(DOToString(temp)); if (*cls == NULL) { ClassExistError(func,DOToString(temp)); return(NULL); } if (ArgTypeCheck(func,2,SYMBOL,&temp) == CLIPS_FALSE) return(NULL); return((SYMBOL_HN *) GetValue(temp)); } #if (! BLOAD_ONLY) && (! RUN_TIME)/*************************************************** NAME : SaveDefclasses DESCRIPTION : Prints pretty print form of defclasses to specified output INPUTS : The logical name of the output RETURNS : Nothing useful SIDE EFFECTS : None NOTES : None ***************************************************/globle VOID SaveDefclasses(logName) char *logName; {#if DEBUGGING_FUNCTIONS DoForAllConstructs(SaveDefclass,DefclassModuleIndex,CLIPS_FALSE,(VOID *) logName);#endif } #endif/* ========================================= ***************************************** INTERNALLY VISIBLE FUNCTIONS ========================================= ***************************************** */#if (! BLOAD_ONLY) && (! RUN_TIME) && DEBUGGING_FUNCTIONS/*************************************************** NAME : SaveDefclass DESCRIPTION : Writes out the pretty-print forms of a class and all its handlers INPUTS : 1) The class 2) The logical name of the output RETURNS : Nothing useful SIDE EFFECTS : Class and handlers written NOTES : None ***************************************************/static VOID SaveDefclass(theDefclass,userBuffer) struct constructHeader *theDefclass; VOID *userBuffer; { char *logName = (char *) userBuffer; unsigned hnd; char *ppForm; ppForm = GetDefclassPPForm((VOID *) theDefclass); if (ppForm != NULL) { PrintInChunks(logName,ppForm); PrintCLIPS(logName,"\n"); hnd = GetNextDefmessageHandler((VOID *) theDefclass,0); while (hnd != 0) { ppForm = GetDefmessageHandlerPPForm((VOID *) theDefclass,hnd); if (ppForm != NULL) { PrintInChunks(logName,ppForm); PrintCLIPS(logName,"\n"); } hnd = GetNextDefmessageHandler((VOID *) theDefclass,hnd); } } }#endif#endif /*************************************************** NAME : DESCRIPTION : INPUTS : RETURNS : SIDE EFFECTS : NOTES : ***************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -