liboaa.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  *   File    : liboaa.h
00003  *   Author  : Adam Cheyer
00004  *   Updated : 5/21/97
00005  *
00006  *****************************************************************************/
00007 /*
00008  * Copyright (C) 2006  SRI International
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  * SRI International: 333 Ravenswood Ave, Menlo Park, CA 94025
00025  */
00026 #ifndef _AGENTLIB_H_INCLUDED
00027 #define _AGENTLIB_H_INCLUDED
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #ifdef IS_DLL
00034 #define EXTERN __declspec(dllexport)
00035 #else
00036 #define EXTERN extern
00037 #endif
00038 
00039 #ifndef FALSE
00040 #define FALSE 0
00041 #define TRUE  1
00042 #endif
00043 
00044 #ifndef _WINDOWS
00045 #include <unistd.h>
00046 #else
00047 #include "oaa-windows.h"
00048 #endif
00049 
00050 #include <libtrigger.h>
00051 #include <libutils.h>
00052 
00053   /*****************************************************************************
00054    * Initialization and connection functions
00055    *****************************************************************************/
00056 
00057   EXTERN int  oaa_Register(char *ConnectionId, char *AgentName,
00058                            ICLTerm *Solvables);
00059   EXTERN void oaa_Ready(int ShouldPrint);
00060 
00061 
00062   /*****************************************************************************
00063    * Classifying and Manipulating ICL expressions
00064    *****************************************************************************/
00065 
00066   EXTERN int  icl_Builtin(ICLTerm *goal);
00067   EXTERN int  icl_BasicGoal(ICLTerm *goal);
00068   EXTERN int  icl_GetParamValue(ICLTerm *Param, ICLTerm *ParamList, ICLTerm **Result);
00069   EXTERN int  icl_GetPermValue(ICLTerm *Perm, ICLTerm *PermList, ICLTerm **Result);
00070   EXTERN int  icl_ConvertSolvables(int toStandard,
00071                                    ICLTerm *ShorthandSolvables, ICLTerm **StandardSolvables);
00072 
00073 
00074   /* **************************************************************************
00075    * Retrieving and managing events
00076    * *************************************************************************/
00077 
00078   EXTERN int oaa_Init(int argc, char* argv[]);
00079   EXTERN void oaa_MainLoop(int ShouldPrint);
00080   EXTERN void oaa_ProcessAllEvents();
00081 
00082   EXTERN void oaa_ProcessEvent(ICLTerm *Event, ICLTerm *Params);
00083   EXTERN void oaa_SetTimeout(double NSecs);
00084   EXTERN void oaa_GetEvent(ICLTerm **Event, ICLTerm **Params, int LowestPriority);
00085   EXTERN int oaa_ValidateEvent(ICLTerm *E, ICLTerm **OkEvent);
00086   EXTERN int oaa_Interpret(ICLTerm *goal, ICLTerm *params, ICLTerm **solutions);
00087   EXTERN int oaa_DelaySolution(ICLTerm *id);
00088   EXTERN int oaa_ReturnDelayedSolutions(ICLTerm *id, ICLTerm *solution_list);
00089   EXTERN int oaa_AddDelayedContextParams(ICLTerm *id, ICLTerm *params,
00090                                          ICLTerm **new_params);
00091   EXTERN int oaa_PostEvent(ICLTerm *contents, ICLTerm *params);
00092   EXTERN int oaa_Version(ICLTerm *agent_id, ICLTerm **language,
00093                          ICLTerm **version);
00094   EXTERN int oaa_CanSolve(ICLTerm *goal, ICLTerm **kslist);
00095   EXTERN int oaa_Ping(ICLTerm *agent_addr, double time_limit,
00096                       double *total_response_time);
00097   EXTERN int oaa_Declare(ICLTerm *solvable, ICLTerm *initial_common_perms,
00098                          ICLTerm *initial_common_params, ICLTerm *initial_params,
00099                          ICLTerm **declared_solvables);
00100   EXTERN int oaa_DeclareData(ICLTerm *solv, ICLTerm *params,
00101                              ICLTerm **declared_solvs);
00102   EXTERN int oaa_Undeclare(ICLTerm *solvable, ICLTerm *initial_params,
00103                            ICLTerm **undeclared_solvables);
00104   EXTERN int oaa_Redeclare(ICLTerm *initial_solvable,
00105                            ICLTerm *initial_new_solvable,
00106                            ICLTerm *initial_params);
00107   EXTERN int oaa_AddData(ICLTerm *clause, ICLTerm *in_params,
00108                          ICLTerm **out_params);
00109 
00110   EXTERN int oaa_RemoveData(ICLTerm *clause, ICLTerm *in_params,
00111                             ICLTerm **out_params);
00112 
00113   EXTERN int oaa_ReplaceData(ICLTerm *clause1, ICLTerm *clause2,
00114                              ICLTerm *in_params, ICLTerm **out_params);
00115 
00116   EXTERN int oaa_Id(ICLTerm **my_id);
00117   EXTERN int oaa_Name(ICLTerm **my_name);
00118   EXTERN int oaa_Address(char* connectionId, ICLTerm* Type, ICLTerm **myAddress);
00119   EXTERN int oaa_PrimaryAddress(ICLTerm** primaryAddress);
00120   EXTERN int oaa_PrimaryId(ICLTerm** primaryId);
00121   EXTERN int oaa_Solve(ICLTerm *goal, ICLTerm *initial_params,
00122                        ICLTerm **out_params, ICLTerm **solutions);
00123   EXTERN int oaa_InCache(ICLTerm *goal, ICLTerm **solutions);
00124   EXTERN int oaa_AddToCache(ICLTerm *goal, ICLTerm *solutions);
00125   EXTERN int oaa_ClearCache();
00126   EXTERN int oaa_RegisterCallback(char *callback_id,
00127                                   int (*callback_proc)(ICLTerm*, ICLTerm*, ICLTerm*));
00128   EXTERN int oaa_GetCallback(char* callback_id,
00129                              int (**callback_proc)(ICLTerm*, ICLTerm*, ICLTerm*));
00130   EXTERN int oaa_TraceMsg(char *format_string, ...);
00131   EXTERN char *oaa_name_string(void);
00132 
00133 
00134   EXTERN int memberchk(ICLTerm *Param, ICLTerm *ParamList);
00135   EXTERN int oaa_Connect(char *ConnectionId, ICLTerm *Address,
00136                          char *InitialAgentName, ICLTerm *Params);
00137   EXTERN int oaa_Disconnect(char* ConnectionId, ICLTerm *Params);
00138   EXTERN int oaa_SetupCommunication(char *InitialAgentName);
00139   EXTERN int oaa_LibraryVersion(ICLTerm** versionCopy);
00140   EXTERN int oaa_SupportsSequenceNumbers(char* connectionId);
00141 
00145   EXTERN char const* oaa_library_version_str;
00146 
00147   /****************************************************************************
00148    * Macros
00149    ****************************************************************************/
00150 
00154 #define OAA_LIBRARY_VERSION oaa_library_version_str;
00155 
00156 #ifndef STREQ
00157 #define STREQ(str1, str2) (strcmp((str1), (str2)) == 0)
00158 #endif
00159 
00160 // Function which sleeps a specified number of milliseconds
00161 
00162 #ifdef _WINDOWS
00163 #define sleep_millis(n) Sleep(n)
00164 #else
00165 #define sleep_millis(n) usleep((n)*1000L)
00166 #endif
00167 
00168 #ifdef __cplusplus
00169 }
00170 #endif
00171 
00172 #endif
00173 
00174 

Generated on Wed May 23 17:20:12 2007 using doxygen 1.5.2