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

📄 agenda.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
#pragma argsused#endifgloble char *EnvGetActivationName(  void *theEnv,  void *actPtr)  {#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif   return(ValueToString(((struct activation *) actPtr)->theRule->header.name));   }/**************************************//* EnvSetActivationSalience: Sets the *//*   salience value of an activation. *//**************************************/#if IBM_TBC#pragma argsused#endifgloble int EnvSetActivationSalience(  void *theEnv,  void *actPtr,  int value)  {   int temp;#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif   temp = ((struct activation *) actPtr)->salience;   ((struct activation *) actPtr)->salience = value;   return(temp);  }/**********************************************//* EnvGetActivationPPForm: Returns the pretty *//*   print representation of an activation.   *//**********************************************/globle void EnvGetActivationPPForm(  void *theEnv,  char *buffer,  unsigned bufferLength,  void *theActivation)  {   OpenStringDestination(theEnv,"ActPPForm",buffer,bufferLength);   PrintActivation(theEnv,"ActPPForm",(void *) theActivation);   CloseStringDestination(theEnv,"ActPPForm");  }/****************************************************//* EnvGetActivationBasisPPForm: Returns the pretty  *//*   print representation of an activation's basis. *//****************************************************/globle void EnvGetActivationBasisPPForm(  void *theEnv,  char *buffer,  unsigned bufferLength,  void *vTheActivation)  {   struct activation *theActivation = (struct activation *) vTheActivation;   OpenStringDestination(theEnv,"ActPPForm",buffer,bufferLength);   PrintPartialMatch(theEnv,"ActPPForm",theActivation->basis);   CloseStringDestination(theEnv,"ActPPForm");  }/********************************************//* MoveActivationToTop: Moves the specified *//*   activation to the top of the agenda.   *//********************************************/globle intBool MoveActivationToTop(  void *theEnv,  void *vtheActivation)  {   struct activation *prevPtr;   struct activation *theActivation = (struct activation *) vtheActivation;   struct defruleModule *theModuleItem;   /*====================================*/   /* Determine the module of the agenda */   /* in which the activation is stored. */   /*====================================*/   theModuleItem = (struct defruleModule *) theActivation->theRule->header.whichModule;   /*============================================*/   /* If the activation is already at the top of */   /* the agenda, then nothing needs to be done. */   /*============================================*/   if (theActivation == theModuleItem->agenda) return(FALSE);   /*=================================================*/   /* Update the pointers of the activation preceding */   /* and following the activation being moved.       */   /*=================================================*/   prevPtr = theActivation->prev;   prevPtr->next = theActivation->next;   if (theActivation->next != NULL) theActivation->next->prev = prevPtr;   /*=======================================================*/   /* Move the activation and then update its pointers, the */   /* pointers of the activation following it, and the      */   /* module pointer to the top activation on the agenda.   */   /*=======================================================*/   theActivation->next = theModuleItem->agenda;   theModuleItem->agenda->prev = theActivation;   theActivation->prev = NULL;   theModuleItem->agenda = theActivation;   /*=============================*/   /* Mark the agenda as changed. */   /*=============================*/   AgendaData(theEnv)->AgendaChanged = TRUE;   return(TRUE);  }/**********************************************//* EnvDeleteActivation: Removes the specified *//*   activation from the agenda.              *//**********************************************/globle intBool EnvDeleteActivation(  void *theEnv,  void *theActivation)  {   if (theActivation == NULL) RemoveAllActivations(theEnv);   else RemoveActivation(theEnv,(struct activation *) theActivation,TRUE,TRUE);   return(TRUE);  }/*******************************************************//* DetachActivation: Detaches the specified activation *//*   from the list of activations on the Agenda.       *//*******************************************************/globle intBool DetachActivation(  void *theEnv,  void *vTheActivation)  {   struct defruleModule *theModuleItem;   struct activation *theActivation = (struct activation *) vTheActivation;   /*============================*/   /* A NULL pointer is invalid. */   /*============================*/   if (theActivation == NULL) SystemError(theEnv,"AGENDA",1);   /*====================================*/   /* Determine the module of the agenda */   /* in which the activation is stored. */   /*====================================*/   theModuleItem = (struct defruleModule *) theActivation->theRule->header.whichModule;   RemoveActivationFromGroup(theEnv,theActivation,theModuleItem);   /*========================================================*/   /* If the activation is the top activation on the agenda, */   /* then update the module pointer to agenda.              */   /*========================================================*/   if (theActivation == theModuleItem->agenda)     { theModuleItem->agenda = theActivation->next; }   /*==================================================*/   /* Update the pointers in the preceding activation. */   /*==================================================*/   if (theActivation->prev != NULL)     { theActivation->prev->next = theActivation->next; }   /*==================================================*/   /* Update the pointers in the following activation. */   /*==================================================*/   if (theActivation->next != NULL)     { theActivation->next->prev = theActivation->prev; }   /*=================================================*/   /* Update the pointers in the detached activation. */   /*=================================================*/   theActivation->prev = NULL;   theActivation->next = NULL;   /*=============================*/   /* Mark the agenda as changed. */   /*=============================*/   AgendaData(theEnv)->AgendaChanged = TRUE;   return(TRUE);  }/****************************************************************************//* PrintActivation: Prints an activation in a "pretty" format. Salience,    *//*   rule name, and the partial match which activated the rule are printed. *//****************************************************************************/static void PrintActivation(  void *theEnv,  char *logicalName,  void *vTheActivation)  {   struct activation *theActivation = (struct activation *) vTheActivation;   char printSpace[20];   gensprintf(printSpace,"%-6d ",theActivation->salience);   EnvPrintRouter(theEnv,logicalName,printSpace);   EnvPrintRouter(theEnv,logicalName,ValueToString(theActivation->theRule->header.name));   EnvPrintRouter(theEnv,logicalName,": ");   PrintPartialMatch(theEnv,logicalName,theActivation->basis);  }/*******************************//* EnvAgenda: C access routine *//*   for the agenda command.   *//*******************************/globle void EnvAgenda(  void *theEnv,  char *logicalName,  void *vTheModule)  {   struct defmodule *theModule = (struct defmodule *) vTheModule;   ListItemsDriver(theEnv,logicalName,theModule,"activation","activations",                   EnvGetNextActivation,NULL,PrintActivation,NULL);  }/*******************************************************************//* RemoveActivation: Returns an activation and its associated data *//*   structures to the Memory Manager. Links to other activations  *//*   and partial matches may also be updated.                      *//*******************************************************************/globle void RemoveActivation(  void *theEnv,  void *vTheActivation,  int updateAgenda,  int updateLinks)  {   struct defruleModule *theModuleItem;   struct activation *theActivation = (struct activation *) vTheActivation;   /*====================================*/   /* Determine the module of the agenda */   /* in which the activation is stored. */   /*====================================*/   theModuleItem = (struct defruleModule *) theActivation->theRule->header.whichModule;   /*=================================*/   /* Update the agenda if necessary. */   /*=================================*/   if (updateAgenda == TRUE)     {      RemoveActivationFromGroup(theEnv,theActivation,theModuleItem);      /*===============================================*/      /* Update the pointer links between activations. */      /*===============================================*/      if (theActivation->prev == NULL)        {         theModuleItem->agenda = theModuleItem->agenda->next;         if (theModuleItem->agenda != NULL) theModuleItem->agenda->prev = NULL;        }      else        {         theActivation->prev->next = theActivation->next;         if (theActivation->next != NULL)           { theActivation->next->prev = theActivation->prev; }        }      /*===================================*/      /* Indicate removal of activation if */      /* activations are being watched.    */      /*===================================*/#if DEBUGGING_FUNCTIONS      if (theActivation->theRule->watchActivation)        {         EnvPrintRouter(theEnv,WTRACE,"<== Activation ");         PrintActivation(theEnv,WTRACE,(void *) theActivation);         EnvPrintRouter(theEnv,WTRACE,"\n");        }#endif      /*=============================*/      /* Mark the agenda as changed. */      /*=============================*/      AgendaData(theEnv)->AgendaChanged = TRUE;     }   /*============================================*/   /* Update join and agenda links if necessary. */   /*============================================*/   if ((updateLinks == TRUE) && (theActivation->basis != NULL))     { theActivation->basis->marker = NULL; }   /*================================================*/   /* Return the activation to the free memory pool. */   /*================================================*/   AgendaData(theEnv)->NumberOfActivations--;   rtn_struct(theEnv,activation,theActivation);  }/**************************************************************//* RemoveActivationFromGroup:      *//**************************************************************/static void RemoveActivationFromGroup(  void *theEnv,  struct activation *theActivation,  struct defruleModule *theRuleModule)  {   struct salienceGroup *theGroup;      theGroup = FindSalienceGroup(theRuleModule,theActivation->salience);   if (theGroup == NULL) return;      if (theActivation == theGroup->first)

⌨️ 快捷键说明

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