#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/time.h>
#include <stdarg.h>
#include "libicl_private.h"
#include "libicl.h"
#include "libdb.h"
#include "libcom_tcp.h"
#include "liboaa.h"
#include "dictionary.h"
#include "testers.h"
Go to the source code of this file.
Defines | |
| #define | EXPORT_BORLAND |
| #define | EXPORT_MSCPP |
| #define | MAXHOSTNAMELEN 256 |
Functions | |
| int | oaa_SeqNumLessThan (int a, int b) |
| EXTERN int | oaa_Init (int argc, char *argv[]) |
| Must be called to init oaa parameters, such as argv and agrc. | |
| int | oaa_compare_terms (void *t1, void *t2) |
| Use unification to compare 2 terms, returning 0 for success and 1 for failure. | |
| int | oaa_assert_current_contexts (ICLTerm *id, ICLTerm *contexts) |
| Record current contexts associated with a particular id. | |
| int | oaa_retrieve_current_contexts (ICLTerm *id, ICLTerm **contexts) |
| Retrieve the context associated with id without removing the entry from the table. | |
| int | oaa_retrieve_nth_current_contexts (ICLTerm **id, ICLTerm **contexts, int n) |
| Retrieve the nth id and contexts from the current_context table. | |
| int | oaa_retractall_current_contexts (ICLTerm *id) |
| Retract all current contexts associated with a particular id. | |
| int | oaa_assert_delay (ICLTerm *id, ICLTerm *user_id) |
| Assert the fact that the user has requested a delayed solution to a particular goal. | |
| int | oaa_retract_delay (ICLTerm *id, ICLTerm **user_id) |
| Retract the fact that the user has requested a delayed solution to a particular goal and return the user id. | |
| int | oaa_assert_delay_table (ICLTerm *goal_id, ICLTerm *user_id, ICLTerm *full_goal, ICLTerm *solve_params, ICLTerm *all_params) |
| Store the solution to a delayed goal. | |
| int | oaa_retract_delay_table (ICLTerm **goal_id, ICLTerm *user_id, ICLTerm **full_goal, ICLTerm **solve_params, ICLTerm **all_params) |
| Remove and return the first solution found that has been stored with the key, user_id. | |
| int | oaa_assert_callback (ICLTerm *id, int(*user_callback)(ICLTerm *, ICLTerm *, ICLTerm *)) |
| Store a callback procedure associated with a particular id. | |
| int | oaa_retrieve_callback (ICLTerm *id, int(**user_callback)(ICLTerm *, ICLTerm *, ICLTerm *)) |
| Retrieves the callback procedure without retracting it. | |
| int | oaa_retract_callback (ICLTerm *id, int(*user_callback)(ICLTerm *, ICLTerm *, ICLTerm *)) |
| Retract the first callback associated with this id. | |
| int | oaa_retractall_callback (ICLTerm *id, ICLTerm **proc) |
| Retract all callbacks associated with this id. | |
| int | oaa_assert_cache (ICLTerm *goal, ICLTerm *solutions) |
| Store cached solutionsin the oaa_cache table. | |
| int | oaa_retrieve_cache (ICLTerm *goal, ICLTerm **solutions) |
| Retrieves the cached solutions without retracting them. | |
| int | oaa_retractall_cache (ICLTerm *goal) |
| Retract all cached solutions with goals that unify with the parameter. | |
| int | oaa_retrieve_all_cache (ICLTerm *goal, ICLTerm **solutions) |
| Retrieves all the cached solutions without retracting them. | |
| int | oaa_retract_cache (ICLTerm *goal, ICLTerm **solutions) |
| Retract the first cached solutions associated with this goal. | |
| int | oaa_assert_waiting_for (ICLTerm *id, ICLTerm *event_list) |
| Store a list of events with an associated id. | |
| int | oaa_retrieve_waiting_for (ICLTerm *id, ICLTerm **event_list) |
| Retrieves the event list for a particular id without retracting it. | |
| int | oaa_retrieve_all_waiting_for (ICLTerm *id, ICLTerm **event_list) |
| Retrieves all event lists for a particular id term. | |
| int | oaa_retract_waiting_for (ICLTerm *id, ICLTerm **event_list) |
| Retract the first event list associated with this id. | |
| int | oaa_assert_waiting_event (ICLTerm *event) |
| Store an event. | |
| int | oaa_retrieve_all_waiting_events (ICLTerm **event_list) |
| Retrieves all waiting events. | |
| int | oaa_retract_waiting_event (ICLTerm *event) |
| Retract the first event list associated with this id. | |
| ICLTerm * | oaa_built_in_solvables () |
| Initializes and returns value for oaa_built_in_solvables_term. | |
| EXTERN void | icl_param_standard_form (ICLTerm *param, ICLListType **SList) |
| Returns a copy of parameter in standard parameter form. | |
| EXTERN int | icl_param_default (ICLTerm *param, ICLTerm **result) |
| Returns true if param unifies with a default parameter. | |
| EXTERN void | icl_perm_standard_form (ICLTerm *perm, ICLTerm **Standard) |
| Returns a copy of perm in standard permission form. | |
| EXTERN int | icl_perm_default (ICLTerm *perm, ICLTerm **result) |
| Returns true if perm unifies with a default permission. | |
| EXTERN int | icl_address_to_id (ICLTerm *inFullAddress, ICLTerm **result) |
| EXTERN int | icl_standardize_address (ICLTerm *Addr, ICLTerm **StandardAddr) |
| Standardizes an address or address list, Can only be used after oaa_Register() because of the reliance on com_GetInfo(). | |
| EXTERN int | icl_standardize_solvables (ICLTerm *ShorthandSolvables, ICLTerm **StandardSolvables) |
| Renders solvables in canonical form. | |
| EXTERN int | icl_readable_solvables (ICLTerm *StandardSolvables, ICLTerm **ShorthandSolvables) |
| This is provided for use in "pretty-printing" solvables, in trace messages, etc. | |
| EXTERN int | icl_readable_solvable (ICLTerm *StandardSolvable, ICLTerm **ShorthandSolvable) |
| Convert a single solvable into shorthand notation. | |
| EXTERN int | oaa_goal_in_solvables (ICLTerm *Goal, ICLTerm *Solvables, ICLTerm **MatchedSolvable) |
| Determine whether Goal appears in Solvables, with appropriate Params and Perms for it to be called. | |
| EXTERN int | oaa_call_callback (char *callback_id, ICLTerm *goal, ICLTerm *params, ICLTerm *solutions) |
| EXTERN int | oaa_sort_and_get_event (ICLTerm *EventList, int LowestPriority, ICLTerm **Event, ICLTerm **Params) |
| Sort raw events by priority, choose the highest priority event or FirstIn if equal priority, extract event data and sender, and store the rest of events. | |
| EXTERN int | oaa_extract_event (ICLTerm *raw_event, ICLTerm **content, ICLTerm **params) |
| Extract the content and parameters from an event term. | |
| EXTERN int | oaa_class (char *class) |
| Return the class (leaf, node, or root) of the current agent. | |
| EXTERN char * | oaa_name_string (void) |
| EXTERN int | oaa_Id (ICLTerm **my_id) |
| Return the Id of the current agent. | |
| EXTERN ICLTerm * | perm_default_list () |
| Returns the list of default permissions. | |
| EXTERN ICLTerm * | param_default_list () |
| Returns the list of default parameters. | |
| EXTERN int | oaa_priority_compare (ICLTerm *Elt1, ICLTerm *Elt2) |
| Returns true if Elt1 and Elt2 should swap according to priority. | |
| EXTERN int | oaa_extract_event_param (ICLTerm *event, char *param, ICLTerm **result) |
| Extract the content and a parameter value from an event term. | |
| EXTERN int | oaa_choose_event (int LowestPriority, ICLTerm *EventList, ICLTerm **Event) |
| Extracts the first event from a list which has a HIGHER priority than the required lowest. | |
| EXTERN int | oaa_read_all_events (double TimeOut, ICLListType **Events, int *FlushPriority) |
| Flush the communication event queue, reading ALL available events and returning a list of them, or empty list if none available. | |
| EXTERN int | oaa_select_event (double timeout, ICLTerm **event) |
| If a positive timeout is defined, wait N seconds for an event to arrive. | |
| EXTERN int | oaa_flush_events (ICLTerm **original_events, int flush_priority) |
| Flushes any events with a lower priority than the FlushPriority. | |
| EXTERN int | oaa_data_in_solvables (ICLTerm *Clause, ICLTerm *Solvables, ICLTerm *Perm, ICLTerm **MatchedSolvable) |
| Determine whether (the Head of) Clause appears in Solvables, with appropriate Params and Perms for it to be read or written. | |
| EXTERN int | oaa_distribute_perms (ICLTerm *solvables, ICLTerm *common_perms, ICLTerm **new_solvables) |
| EXTERN int | oaa_distribute_params (ICLTerm *solvables, ICLTerm *common_params, ICLTerm **new_solvables) |
| Add common_params (CommonPerms) to the Params (Permissions) list of each solvable in solvables. | |
| EXTERN int | oaa_declare_aux (char *mode, ICLTerm *solvables, ICLTerm *params, ICLTerm **declared_solvables) |
| EXTERN int | icl_standardize_addressee (ICLTerm *Addr, ICLTerm **StandardAddr) |
| Standardizes an addressee. | |
| EXTERN int | oaa_address_to_comm_id (ICLTerm *inAddress, char **commId) |
| EXTERN char * | new_goal_id () |
| EXTERN char * | new_trigger_id () |
| EXTERN int | select_elements (ICLTerm *list, int(*test_function)(ICLTerm *), ICLTerm **result) |
| Selects all List elements for which Selector(element) succeeds. | |
| EXTERN int | oaa_handle_user_event (ICLTerm *event, ICLTerm *params, ICLTerm **solutions) |
| EXTERN int | oaa_exec_event (ICLTerm *goal, ICLTerm *params, ICLTerm **solutions) |
| Defines execution of events built into all agents. | |
| EXTERN int | oaa_cont_solve (ICLTerm *goal_id, ICLTerm *goal, ICLTerm *global_params, ICLTerm **solutions, ICLTerm **out_params) |
| Post request for solutions, and if appropriate, poll until results are returned. | |
| EXTERN ICLTerm * | remove_element (ICLTerm *elt, ICLTerm *list, ICLTerm **rest) |
| Creates a copy of the incoming list, where the first element that unifies with elt is missing. | |
| EXTERN int | oaa_cont_poll_until_all_events (ICLTerm *event_list, ICLTerm *event, ICLTerm *params, int priority, ICLTerm **solutions) |
| EXTERN int | oaa_handle_ev_update_data (ICLTerm *goal, ICLTerm *params) |
| EXTERN int | oaa_ComTraceMsg (char *format_string,...) |
| If com trace mode is on, display message and arguments. | |
| EXTERN int | oaa_flush_notification (ICLTerm *raw_event) |
| Given a raw event, grabs its real event and looks up whether a notification should be sent out regarding the event's cancellation due to a flush. | |
| EXTERN int | oaa_event_param (ICLTerm *event, ICLTerm *param) |
| Extract a parameter from an event term. | |
| EXTERN int | oaa_get_flush_notify (ICLTerm *event, ICLTerm **notify_event) |
| Records a list of events which require a return notification if the event is flushed. | |
| EXTERN int | oaa_translate_incoming_event (ICLTerm *raw_event_in, ICLTerm **raw_event_out) |
| EXTERN int | oaa_unwrap_event (ICLTerm *in_event, char **connection_id, ICLTerm **out_event) |
| Remove an event term from its communications wrapper (if any), and returns it in our standard internal form: 'timeout' OR event(Content, Params). | |
| EXTERN int | oaa_from_param (ICLTerm *event) |
| EXTERN int | oaa_content_fac_id (ICLTerm *content, ICLTerm **id) |
| EXTERN int | oaa_is_parent_fac_id (char *connection_id, ICLTerm **id) |
| EXTERN int | oaa_is_oaa_id (char *connection_id, ICLTerm **id) |
| EXTERN int | oaa_remove_data_owned_by (ICLTerm *id) |
| EXTERN int | oaa_handle_ev_update_trigger (ICLTerm *goal, ICLTerm *params) |
| EXTERN int | oaa_handle_ev_solve (ICLTerm *goal, ICLTerm *params, ICLTerm **solutions) |
| EXTERN int | oaa_handle_ev_solved (ICLTerm *goal, ICLTerm *params) |
| EXTERN int | oaa_add_data_local (ICLTerm *clause1, ICLTerm *params) |
| Assert a clause for an agent's solvable. | |
| EXTERN int | oaa_remove_data_local (ICLTerm *clause1, ICLTerm *params) |
| Retract a clause (or all clauses) from an agent's solvable. | |
| EXTERN int | oaa_replace_data_local (ICLTerm *clause1_in, ICLTerm *params) |
| Replace one or more clauses from an agent's solvable. | |
| EXTERN int | oaa_Inform (ICLTerm *type_info, char *format_string, ICLTerm *args) |
| Sends a typed message to interested agents. | |
| EXTERN int | oaa_solve_local (ICLTerm *full_goal, ICLTerm *params, ICLTerm **solutions) |
| EXTERN int | oaa_turn_on_debug () |
| EXTERN int | oaa_turn_off_debug () |
| EXTERN int | predicate_skeleton (ICLTerm *goal, ICLTerm **skeleton) |
| EXTERN int | oaa_is_waiting_for (ICLTerm *event) |
| Check to see if the current event is something we are waiting for on a higher recursive level. | |
| EXTERN int | oaa_translate_outgoing_event (ICLTerm *event, ICLTerm *dest_id, char *commId, ICLTerm **new_event) |
| Provides backwards compatibility by calling a hook (user:oaa_event_translation/7) that translates outgoing events to agents of other versions. | |
| EXTERN int | oaa_poll_until_event (ICLTerm *event, ICLTerm **solution) |
| Block until requested event arrives in oaa_GetEvent(). | |
| EXTERN int | oaa_declare_local (char *mode, ICLTerm *solvable0, ICLTerm *params, ICLTerm **returned_solvables) |
| EXTERN int | solvables_to_be_added (ICLTerm *solvables, ICLTerm *current, ICLTerm **ok_solvables) |
| Checks a list of solvables, to make sure they can legally be declared. | |
| EXTERN int | solvables_to_be_removed (ICLTerm *solvables, ICLTerm *current, ICLTerm **ok_solvables) |
| Checks a list of solvables, to make sure they can legally be UNdeclared. | |
| EXTERN int | oaa_remove_solvables_data (ICLTerm *solvables) |
| For each data solvable, remove all clauses belonging to it. | |
| EXTERN int | icl_subtract (ICLTerm *list1, ICLTerm *list2, ICLTerm **result) |
| Implement the prolog predicate subtract/3. | |
| EXTERN int | replace_element (ICLTerm *elt, ICLTerm *old_list, ICLTerm *new_elt, ICLTerm **new_list) |
| Replaces the element elt, if present in old_list, with the element new_elt. | |
| EXTERN int | oaa_update (char *mode, ICLTerm *clause, ICLTerm *initial_params, ICLTerm **out_params) |
| Common code for oaa_AddData(), oaaRemoveData(), and oaa_ReplaceData(). | |
| EXTERN int | oaa_retractall (ICLTerm *clause, ICLTerm *owner, ICLTerm *callback) |
| EXTERN int | retract_all (ICLTerm *clause) |
| Remove all clauses matching Clause1 Always succeeds. | |
| EXTERN int | oaa_data_owner (ICLTerm *params, ICLTerm **owner) |
| Determine data ownership from the available params. | |
| EXTERN int | oaa_asserta (ICLTerm *clause, ICLTerm *owner, ICLTerm *callback) |
| EXTERN int | oaa_assertz (ICLTerm *clause, ICLTerm *owner, ICLTerm *callback) |
| EXTERN int | oaa_retract (ICLTerm *clause, ICLTerm *owner, ICLTerm *callback) |
| EXTERN int | oaa_replace_all (ICLTerm *clause1, ICLTerm *clause2, ICLTerm *owner, ICLTerm *callback) |
| EXTERN int | oaa_poll_until_event_priority (ICLTerm *event, int priority, ICLTerm **solutions) |
| EXTERN int | oaa_poll_until_all_events (ICLTerm *event_list, int priority, ICLTerm **solutions) |
| Block until all requested events arrive. | |
| EXTERN int | oaa_grab_waiting_event (ICLTerm *event_list, ICLTerm **event) |
| If one of the delayed events is in the EventList that we are waiting for, return this event and remove from delayed list. | |
| EXTERN int | replace_all (ICLTerm *clause1, ICLTerm *clause2) |
| Replaces all clauses matching clause1 with clause2. | |
| char * | getlocalhostname (void) |
| * Retrieve local host name. | |
| EXPORT_MSCPP int EXPORT_BORLAND | oaa_Register (char *ConnectionId, char *AgentName, ICLTerm *Solvables) |
| Once a comm link is established, either as a client to a Facilitator or as a server for other agents, oaa_Register will setup and registration information for this agent. | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_Ready (int ShouldPrint) |
| Changes the agent's 'open' status to 'ready', indicating that the agent is now ready to receive message. | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_BuiltIn (ICLTerm *goal) |
| Test whether an expression is an ICL built-in goal. | |
| int | icl_compound_goal (ICLTerm *goal) |
| Test whether an expression is an ICL compound goal. | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_BasicGoal (ICLTerm *goal) |
| Test whether an expression is an ICL basic (non-compound) goal; that is, just a functor with 0 or more arguments. | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_GoalComponents (ICLTerm *fullgoal, ICLTerm **address, ICLTerm **goal, ICLTerm **param) |
| Assemble, disassemble, or match against the top-level components of an ICL goal. | |
| int | icl_standardize_perms (ICLTerm *Perms, int KeepDefaults, ICLTerm **Standardized) |
| Standardizes a permissions list, removing defaults if requested. | |
| int | icl_standardize_params (ICLTerm *Params, int KeepDefaults, ICLTerm **Standardized) |
| Standardizes a permissions list, removing defaults if requested. | |
| int | icl_param_arg (char *param, ICLTerm *value, ICLTerm *paramlist, ICLTerm **result) |
| Searches for a parameter in a parameter list. | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_GetParamValue (ICLTerm *Param, ICLTerm *ParamList, ICLTerm **Result) |
| To get or test the value of a parameter that has a default, it is best to call icl_GetParamValue(). | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_GetPermValue (ICLTerm *Perm, ICLTerm *PermList, ICLTerm **Result) |
| To get or test the value of a parameter that has a default, it is best to call icl_GetPermValue(). | |
| int | icl_name (ICLTerm *term) |
| Returns TRUE if Term is a valid address name Any atom except for "parent", "self" or "facilitator" may be a name. | |
| int | icl_true_id (ICLTerm *term, ICLTerm **Id) |
| Returns canonical term for a lowest-level id. | |
| EXPORT_MSCPP int EXPORT_BORLAND | icl_ConvertSolvables (int toStandard, ICLTerm *ShorthandSolvables, ICLTerm **StandardSolvables) |
| Convert between shorthand and standard forms of solvables list. | |
| int | icl_standardize_solvable (ICLTerm *Shorthand, ICLTerm **Standard) |
| int | icl_minimally_instantiate_solvable (ICLTerm *Shorthand, ICLTerm **Minimal) |
| Convert from shorthand (or standard form) to minimally instantiated solvables list. | |
| int | icl_minimally_instantiate_solvables (ICLTerm *ShorthandSolvables, ICLTerm **MinimalSolvables) |
| Loop to call minimally_instantiate_solvable. | |
| int | oaa_goal_matches_solvables (ICLTerm *Goal, ICLTerm *Solvables, ICLTerm **RealGoal, ICLTerm **RealMatched) |
| Determine whether a call to Goal is handled by the agent with these Solvables. | |
| int | oaa_data_matches_solvables (ICLTerm *Clause, ICLTerm *Solvables, ICLTerm *Perm, ICLTerm **RealClause, ICLTerm **RealMatched) |
| Determine whether Clause can be read or written by the agent with these Solvables, and return the "real" form of the clause that takes synonyms into account. | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_MainLoop (int ShouldPrint) |
| The main event loop for the application. | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_ProcessAllEvents () |
| To be called when the application that uses OAA has its own event loop. | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_ProcessEvent (ICLTerm *Event, ICLTerm *Params) |
| Interprets an incoming event. | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_SetTimeout (double NSecs) |
| Sets the timeout value used by oaa_GetEvent(). | |
| EXPORT_MSCPP void EXPORT_BORLAND | oaa_GetEvent (ICLTerm **Event, ICLTerm **Params, int LowestPriority) |
| Return the next event to execute. | |
| int | oaa_ValidateEvent (ICLTerm *E, ICLTerm **OkEvent) |
| Check that an incoming lowlevel event should be processed. | |
| int | oaa_Interpret (ICLTerm *goal, ICLTerm *params, ICLTerm **solutions) |
| Executes an incoming event Implements a simple meta-interpreter for executing complex goals. | |
| int | oaa_find_all_contexts (ICLTerm *params, ICLTerm **contexts) |
| ICLTerm * | valid_oaa_solvables () |
| int | passes_tests (ICLTerm *params) |
| int | oaa_DelaySolution (ICLTerm *id) |
| Requests that the current AppDoEvent not return solutions to the current goal until a later time. | |
| int | oaa_ReturnDelayedSolutions (ICLTerm *id, ICLTerm *solution_list) |
| Returns the list of solutions for a delayed request. | |
| int | oaa_AddDelayedContextParams (ICLTerm *id, ICLTerm *params, ICLTerm **new_params) |
| When a goal is delayed using oaa_DelaySolution(), incoming context parameters from the original request can not be automatically concatenated to outgoing oaa_Solve() requests. | |
| int | oaa_PostEvent (ICLTerm *contents, ICLTerm *params) |
| Sends a low-level event to another agent. | |
| int | oaa_convert_id_to_comm_id (ICLTerm *id, ICLTerm **cid) |
| int | oaa_LibraryVersion (ICLTerm **version) |
| int | oaa_Version (ICLTerm *agent_id, ICLTerm **language, ICLTerm **version) |
| Lookup the language and library version number for an agent. | |
| int | oaa_CanSolve (ICLTerm *goal, ICLTerm **kslist) |
| Asks the Facilitator for a list of agents which could solve a Goal. | |
| int | oaa_Ping (ICLTerm *agent_addr, double time_limit, double *total_response_time) |
| Tests whether a given agent is currently responding to requests. | |
| int | oaa_Declare (ICLTerm *solvable, ICLTerm *initial_common_perms, ICLTerm *initial_common_params, ICLTerm *initial_params, ICLTerm **declared_solvables) |
| Declare solvables for a client or facilitator, and inform the parent if appropriate. | |
| int | oaa_DeclareData (ICLTerm *solv, ICLTerm *params, ICLTerm **declared_solvs) |
| Declare data solvables for an agent. | |
| int | oaa_Undeclare (ICLTerm *solvable, ICLTerm *initial_params, ICLTerm **undeclared_solvables) |
| Remove solvables from a client or facilitator, and inform the parent if appropriate. | |
| int | oaa_Redeclare (ICLTerm *initial_solvable, ICLTerm *initial_new_solvable, ICLTerm *initial_params) |
| Replace a solvable on a client or facilitator, and inform the parent if appropriate. | |
| int | oaa_public_solvable (ICLTerm *solvable) |
| int | oaa_data_solvable (ICLTerm *solvable) |
| int | oaa_AddData (ICLTerm *clause, ICLTerm *in_params, ICLTerm **out_params) |
| Add a new clause for a DATA solvable (locally and/or remotely). | |
| int | oaa_RemoveData (ICLTerm *clause, ICLTerm *in_params, ICLTerm **out_params) |
| int | oaa_ReplaceData (ICLTerm *clause1, ICLTerm *clause2, ICLTerm *in_params, ICLTerm **out_params) |
| Change a predicate value to a new one. | |
| int | icl_replace_param_value (ICLTerm *param, ICLTerm *param_list) |
| If param unifies with an element of param list, replace the element with the unified result. | |
| int | asserta (ICLTerm *clause) |
| int | assertz (ICLTerm *clause) |
| int | retract (ICLTerm *clause) |
| int | asserta_ref (ICLTerm *clause, ICLTerm **ref) |
| int | assertz_ref (ICLTerm *clause, ICLTerm **ref) |
| int | ref_for_clause (ICLTerm *clause, ICLTerm **ref) |
| int | erase_ref (ICLTerm *clause, ICLTerm *ref) |
| int | oaa_Address (char *connectionId, ICLTerm *Type, ICLTerm **myAddress) |
| Returns (one of more) Addresses for this agent. | |
| int | oaa_PrimaryAddress (ICLTerm **primaryAddress) |
| Returns the primary address for this agent in new memory. | |
| int | oaa_PrimaryId (ICLTerm **primaryId) |
| Returns the primary id for this agent. | |
| int | oaa_Name (ICLTerm **my_name) |
| Return the name of the current agent. | |
| int | oaa_Solve (ICLTerm *goal, ICLTerm *initial_params, ICLTerm **out_params, ICLTerm **solutions) |
| Sends work or information requests to distributed agents, brokered by the Facilitator agent. | |
| int | oaa_InCache (ICLTerm *goal, ICLTerm **solutions) |
| Retrieve solutions from the cache if the goal we are asking for is properly contained in the cache (check subsumption). | |
| int | oaa_AddToCache (ICLTerm *goal, ICLTerm *solutions) |
| Add each solution to goal one at a time so we can retrieve solutions later using findall. | |
| int | oaa_ClearCache () |
| Clear the cache. | |
| int | oaa_RegisterCallback (char *callback_id, int(*callback_proc)(ICLTerm *, ICLTerm *, ICLTerm *)) |
| Declare what procedures should be used for callbacks. | |
| int | oaa_GetCallback (char *callback_id, int(**callback_proc)(ICLTerm *, ICLTerm *, ICLTerm *)) |
| int | oaa_TraceMsg (char *format_string,...) |
| If trace mode is on, display message and arguments. | |
| EXPORT_MSCPP int EXPORT_BORLAND | memberchk (ICLTerm *Param, ICLTerm *ParamList) |
| Searches for a parameter in a list. | |
| EXPORT_MSCPP int EXPORT_BORLAND | oaa_Connect (char *ConnectionId, ICLTerm *Address, char *InitialAgentName, ICLTerm *Params) |
| Connect and handshake with the agent listening on Address, or, if Address is a variable, allow com_Connect() to find the address. | |
| EXPORT_MSCPP int EXPORT_BORLAND | oaa_Disconnect (char *ConnectionId, ICLTerm *Params) |
| Disconnect from the given comm link, or from all links if the given CommunicationID is NULL. | |
| EXPORT_MSCPP int EXPORT_BORLAND | oaa_SetupCommunication (char *InitialAgentName) |
Convenience function for connecting to a facilitator and, if oaa_listen | |
| int | oaa_version_atleast (int major, int minor, int level, ICLTerm *toCheck) |
| Check if the given version list is at least [major,minor,level]. | |
| EXPORT_MSCPP int EXPORT_BORLAND | oaa_SupportsSequenceNumbers (char *connectionId) |
Variables | |
| char const * | oaa_library_version_str = "[2,3,2]" |
| ICLDatabase * | commdb |
| ICLTerm * | oaa_saved_events = NULL |
| int | oaa_argc = 0 |
| char ** | oaa_argv = NULL |
Definition in file liboaa.c.
| char* getlocalhostname | ( | void | ) |
| EXPORT_MSCPP int EXPORT_BORLAND icl_BasicGoal | ( | ICLTerm * | goal | ) |
Test whether an expression is an ICL basic (non-compound) goal; that is, just a functor with 0 or more arguments.
Remarks:
| EXPORT_MSCPP int EXPORT_BORLAND icl_BuiltIn | ( | ICLTerm * | goal | ) |
Test whether an expression is an ICL built-in goal.
Remarks:
| int icl_compound_goal | ( | ICLTerm * | goal | ) |
| EXPORT_MSCPP int EXPORT_BORLAND icl_ConvertSolvables | ( | int | toStandard, | |
| ICLTerm * | ShorthandSolvables, | |||
| ICLTerm ** | StandardSolvables | |||
| ) |
Convert between shorthand and standard forms of solvables list.
Remarks:
Note: in the C version, an additional arg (toStandard) is added to distinguish between the two calling conventions:
icl_ConvertSolvables(TRUE, +ShorthandSolvables, -StandardSolvables).
icl_ConvertSolvables(FALSE, +StandardSolvables, -ShorthandSolvables).
| EXPORT_MSCPP int EXPORT_BORLAND icl_GetParamValue | ( | ICLTerm * | Param, | |
| ICLTerm * | ParamList, | |||
| ICLTerm ** | Result | |||
| ) |
To get or test the value of a parameter that has a default, it is best to call icl_GetParamValue().
For a parameter that has no default, you can use icl_GetParamValue() OR memberchk().
Remarks:
| EXPORT_MSCPP int EXPORT_BORLAND icl_GetPermValue | ( | ICLTerm * | Perm, | |
| ICLTerm * | PermList, | |||
| ICLTerm ** | Result | |||
| ) |
To get or test the value of a parameter that has a default, it is best to call icl_GetPermValue().
For a parameter that has no default, you can use icl_GetPermValue() OR memberchk().
Remarks:
| EXPORT_MSCPP int EXPORT_BORLAND icl_GoalComponents | ( | ICLTerm * | fullgoal, | |
| ICLTerm ** | address, | |||
| ICLTerm ** | goal, | |||
| ICLTerm ** | param | |||
| ) |
Assemble, disassemble, or match against the top-level components of an ICL goal.
Remarks:
Note: This function allocates memory for the three return values.
Convert from shorthand (or standard form) to minimally instantiated solvables list.
Remarks:
| int icl_name | ( | ICLTerm * | term | ) |
Searches for a parameter in a parameter list.
Just like icl_ParamValue() except it returns the argument of the result instead of the whole unified term. Returns a newly allocated copy.
| void icl_param_standard_form | ( | ICLTerm * | param, | |
| ICLListType ** | SList | |||
| ) |
Standardizes an address or address list, Can only be used after oaa_Register() because of the reliance on com_GetInfo().
Standardizes an addressee.
Can only be used after oaa_Register() because of the reliance on com_GetInfo().
Standardizes a permissions list, removing defaults if requested.
Normally there's no need to keep the default value of a param, but there are exceptional situations. If KeepDefaults is true, default values are kept. Standardized is all newly allocated stuff.
Assert a clause for an agent's solvable.
This performs the local processing needed for calls to oaa_AddData(), and ev_update(add, ...) requests. Application code should not call oaa_add_data_local() directly, but rather oaa_AddData() with address(self).
Add a new clause for a DATA solvable (locally and/or remotely).
Params:
Remarks:
When a goal is delayed using oaa_DelaySolution(), incoming context parameters from the original request can not be automatically concatenated to outgoing oaa_Solve() requests.
Since an agent can manage multiple delayed goals at the same time, liboaa doesn't know the correct context for the outgoing oaa_Solve() without explicit direction from the programmer. Hence, an agent programmer who wants to call oaa_Solve() during a delayed goal is expected to use this function to add the saved contexts for the delayed goal to his/her outgoing oaa_Solve() parameters.
| id | an Id which will be used to later match solutions to request | |
| params | parameters for solve goal | |
| new_params | params augmented by saved contexts; points to newly allocated memory--remember to call icl_Free(*new_params) |
Returns (one of more) Addresses for this agent.
If ConnectionId is ground, returns a single Address, relative to that connection. If connection Id is not null, the function returns a single answer for this specific connection. If the connection bound to the incoming Id is not valid, (not actually connected), returns "no_address" and prints out a warning. If connection Id is null, returns all the addresses of the currently valid connections.
| int oaa_address_to_comm_id | ( | ICLTerm * | inAddress, | |
| char ** | commId | |||
| ) |
| int oaa_assert_waiting_event | ( | ICLTerm * | event | ) |
| ICLTerm* oaa_built_in_solvables | ( | ) |
| int oaa_class | ( | char * | class | ) |
| int oaa_compare_terms | ( | void * | t1, | |
| void * | t2 | |||
| ) |
| int oaa_ComTraceMsg | ( | char * | format_string, | |
| ... | ||||
| ) |
| EXPORT_MSCPP int EXPORT_BORLAND oaa_Connect | ( | char * | ConnectionId, | |
| ICLTerm * | Address, | |||
| char * | InitialAgentName, | |||
| ICLTerm * | Params | |||
| ) |
Connect and handshake with the agent listening on Address, or, if Address is a variable, allow com_Connect() to find the address.
| int oaa_data_in_solvables | ( | ICLTerm * | Clause, | |
| ICLTerm * | Solvables, | |||
| ICLTerm * | Perm, | |||
| ICLTerm ** | MatchedSolvable | |||
| ) |
Determine whether (the Head of) Clause appears in Solvables, with appropriate Params and Perms for it to be read or written.
Should not be called directly; only by oaa_data_matches_solvables.
| Clause | must be non-compound (basic) to match: no address, no params, no subClauses. | |
| Solvables | must be in standard form. |
| int oaa_data_matches_solvables | ( | ICLTerm * | Clause, | |
| ICLTerm * | Solvables, | |||
| ICLTerm * | Perm, | |||
| ICLTerm ** | RealClause, | |||
| ICLTerm ** | RealMatched | |||
| ) |
Determine whether Clause can be read or written by the agent with these Solvables, and return the "real" form of the clause that takes synonyms into account.
| Clause | must be non-compound (basic) to match: no address, no params, no subClauses. | |
| Solvables | must be in standard form. | |
| Perm | is 'read' or 'write'. | |
| RealClause | is what should actually be used (asserted, retracted, replaced). | |
| RealMatched | is the solvable record corresponding to RealClause. |
| int oaa_Declare | ( | ICLTerm * | solvable, | |
| ICLTerm * | initial_common_perms, | |||
| ICLTerm * | initial_common_params, | |||
| ICLTerm * | initial_params, | |||
| ICLTerm ** | declared_solvables | |||
| ) |
Declare solvables for a client or facilitator, and inform the parent if appropriate.
| solvable | a single solvable or a list of solvables, in shorthand or standard form | |
| initial_common_perms | permissions to be distributed to each solvable in solvable. This is purely for programming convenience. See comments for icl_ConvertSolvables() for possible values, and solvables documentation for their meanings. | |
| initial_common_params | params to be distributed to each solvable in Solvables. This is purely for programming convenience. See comments for icl_ConvertSolvables() for possible values, and solvables documentation for their meanings. | |
| declared_solvables | returns a list, in standard form, of all solvables successfully declared. |
Remarks
| int oaa_DelaySolution | ( | ICLTerm * | id | ) |
| EXPORT_MSCPP int EXPORT_BORLAND oaa_Disconnect | ( | char * | ConnectionId, | |
| ICLTerm * | Params | |||
| ) |
Disconnect from the given comm link, or from all links if the given CommunicationID is NULL.
| ConnectionId | the link to disconnect; if NULL, disconnect from all links | |
| Params | for future enhancements; currently ignored. |
Extract a parameter from an event term.
This FAILS if the parameter isn't present (unlike oaa_extract_event_param(). Does not look for default values, really behaves like memberchk() or icl_ParamValue().
| int oaa_flush_events | ( | ICLTerm ** | original_events, | |
| int | flush_priority | |||
| ) |
| int oaa_flush_notification | ( | ICLTerm * | raw_event | ) |
| EXPORT_MSCPP void EXPORT_BORLAND oaa_GetEvent | ( | ICLTerm ** | Event, | |
| ICLTerm ** | Params, | |||
| int | LowestPriority | |||
| ) |
Return the next event to execute.
Remarks:
Determine whether Goal appears in Solvables, with appropriate Params and Perms for it to be called.
| Goal | must be non-compound (basic) to match: no address, no params, no subgoals | |
| Solvables | must be in standard form |
| int oaa_goal_matches_solvables | ( | ICLTerm * | Goal, | |
| ICLTerm * | Solvables, | |||
| ICLTerm ** | RealGoal, | |||
| ICLTerm ** | RealMatched | |||
| ) |
Determine whether a call to Goal is handled by the agent with these Solvables.
| Goal | must be non-compound (basic) to match: no address, no params, no subgoals. | |
| Solvables | must be in standard form. | |
| RealGoal | is what should actually be called, after taking synonyms into account. (In short form) | |
| RealMatched | is the solvable record corresponding to RealGoal (In canonical form) |
| EXTERN int oaa_Id | ( | ICLTerm ** | Id | ) |
Return the Id of the current agent.
| EXTERN int oaa_Init | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Executes an incoming event Implements a simple meta-interpreter for executing complex goals.
Agent goals are interpreted by oaa_exec_event(). The contents of Params will vary depending on context. When oaa_Interpret is called on an incoming event, Params will (usually) include from(Sender). Calls generated internally may contain from(self). Additional params may accumulate through recursive calls to oaa_Interpret.
| int oaa_is_parent_fac_id | ( | char * | connection_id, | |
| ICLTerm ** | id | |||
| ) |
| int oaa_is_waiting_for | ( | ICLTerm * | event | ) |
| EXPORT_MSCPP void EXPORT_BORLAND oaa_MainLoop | ( | int | ShouldPrint | ) |
| int oaa_Name | ( | ICLTerm ** | my_name | ) |
| EXTERN char* oaa_name_string | ( | void | ) |
| int oaa_Ping | ( | ICLTerm * | agent_addr, | |
| double | time_limit, | |||
| double * | total_response_time | |||
| ) |
Tests whether a given agent is currently responding to requests.
Fails if a ping is not returned in TimeLimit amount of time.
| AgentAddr | the address of agent to test | |
| TimeLimit | the time limit (in seconds) for how long to wait for a response | |
| TotalResponseTime | the time for the round trip (in seconds) |
Block until requested event arrives in oaa_GetEvent().
oaa_poll_until_event() will allocate the memory for the solution, the task to free it is left to the caller. If the caller does not care about the solution, just use NULL as the third parameter and no memory allocation will be performed.
Sends a low-level event to another agent.
Should NOT be used before there's a connection established for the destination (such as when a client sends ev_connect to its facilitator). In such unusual cases, use com_SendData() directly. For application developers, this just means don't call oaa_PostEvent() until after you've called oaa_Register().
Parameters may include:
IMPORTANT: there may be a different address INSIDE the event; these should not be confused!
| int oaa_PrimaryAddress | ( | ICLTerm ** | primaryAddress | ) |
| int oaa_PrimaryId | ( | ICLTerm ** | primaryId | ) |
| EXPORT_MSCPP void EXPORT_BORLAND oaa_ProcessAllEvents | ( | ) |
| int oaa_read_all_events | ( | double | TimeOut, | |
| ICLListType ** | Events, | |||
| int * | FlushPriority | |||
| ) |
Flush the communication event queue, reading ALL available events and returning a list of them, or empty list if none available.
Remarks
| EXPORT_MSCPP void EXPORT_BORLAND oaa_Ready | ( | int | ShouldPrint | ) |
| int oaa_Redeclare | ( | ICLTerm * | initial_solvable, | |
| ICLTerm * | initial_new_solvable, | |||
| ICLTerm * | initial_params | |||
| ) |
Replace a solvable on a client or facilitator, and inform the parent if appropriate.
| initial_solvable | a single solvable, in shorthand or standard form. If in standard form, however, ONLY the goal is considered in selecting the solvable to be replaced (permissions and parameters are ignored). | |
| initial_new_solvable | a single solvable, in shorthand or standard form. |
Remarks:
| EXPORT_MSCPP int EXPORT_BORLAND oaa_Register | ( | char * | ConnectionId, | |
| char * | AgentName, | |||
| ICLTerm * | Solvables | |||
| ) |
Once a comm link is established, either as a client to a Facilitator or as a server for other agents, oaa_Register will setup and registration information for this agent.
The following information is stored about the current connection, accessible through com_GetInfo(ConnectionId, Info):
if connecting as client, this is also available:
In addition, the following predicates are written to parent Facilitator, or locally if the ConnectionId is a server connection:
Solvables are also written using oaa_Declare().
| ConnectionId | the symbolic connection Id (client or server connection) | |
| AgentName | the name of the agent | |
| Solvables | solvable list |
| int oaa_remove_solvables_data | ( | ICLTerm * | solvables | ) |
Replace one or more clauses from an agent's solvable.
This performs the local processing needed for calls to oaa_ReplaceData, and ev_update(replace, ...) requests. Clause1 is the thing to be replaced. The thing to replace it with must be present in Params, as with(Clause2).
| int oaa_ReplaceData | ( | ICLTerm * | clause1, | |
| ICLTerm * | clause2, | |||
| ICLTerm * | in_params, | |||
| ICLTerm ** | out_params | |||
| ) |
Change a predicate value to a new one.
| clause1 | must be a clause of a writable data solvable. | |
| clause2 | must be a clause of a writable data solvable. |
Remarks:
| int oaa_retract_waiting_event | ( | ICLTerm * | event | ) |
| int oaa_retractall_cache | ( | ICLTerm * | goal | ) |
| int oaa_retractall_current_contexts | ( | ICLTerm * | id | ) |
| int oaa_retrieve_all_waiting_events | ( | ICLTerm ** | event_list | ) |
| int oaa_select_event | ( | double | timeout, | |
| ICLTerm ** | event | |||
| ) |
If a positive timeout is defined, wait N seconds for an event to arrive.
Otherwise block-wait until an event arrives.
IMPORTANT: Connected/1 gets special handling, because we want the connection ID and oaa ID to be assigned immediately. Otherwise, oaa_translate_incoming_event() and oaa_unwrap_event() won't always work properly for subsequent events from the new connection (or would have to be more complicated).
| EXPORT_MSCPP void EXPORT_BORLAND oaa_SetTimeout | ( | double | NSecs | ) |
| EXPORT_MSCPP int EXPORT_BORLAND oaa_SetupCommunication | ( | char * | InitialAgentName | ) |
| int oaa_Solve | ( | ICLTerm * | goal, | |
| ICLTerm * | initial_params, | |||
| ICLTerm ** | out_params, | |||
| ICLTerm ** | solutions | |||
| ) |
Sends work or information requests to distributed agents, brokered by the Facilitator agent.
The default behavior (paramlist = []) is to act like the Prolog primitive call(Goal), blocking until Goal is finished, and unifying and backtracking over solutions for Goal.
This behavior may be modified by a parameter list, which may contain:
Note that certain combinations of parameters are inconsistent, and are handled as follows:
All of the above parameters may be used in the "global" parameter list (the second argument to oaa_Solve), when Goal is non-compound. Most can be used in the global list with compound goals also. Some of these parameters can also be used in the NESTED parameter lists of compound goals. Uses of these parameters with compound goals are documented elsewhere. When that documentation exists, this will go there: With many compound goals, however, the get_satisfier/1 parameter isn't really meaningful. Thus, with compound goals, it is often best to use this parameter in a nested parameter list.
| int oaa_sort_and_get_event | ( | ICLTerm * | EventList, | |
| int | LowestPriority, | |||
| ICLTerm ** | Event, | |||
| ICLTerm ** | Params | |||
| ) |
Sort raw events by priority, choose the highest priority event or FirstIn if equal priority, extract event data and sender, and store the rest of events.
The chosen event must be of HIGHER priority than LowestPriority, and oaa_sort_and_get_event() can fail if no appropriate event is found.
| EXPORT_MSCPP int EXPORT_BORLAND oaa_SupportsSequenceNumbers | ( | char * | connectionId | ) |
| int oaa_TraceMsg | ( | char * | format_string, | |
| ... | ||||
| ) |
| int oaa_translate_outgoing_event | ( | ICLTerm * | event, | |
| ICLTerm * | dest_id, | |||
| char * | commId, | |||
| ICLTerm ** | new_event | |||
| ) |
Provides backwards compatibility by calling a hook (user:oaa_event_translation/7) that translates outgoing events to agents of other versions.
Also allows for event differences based on language. user:oaa_event_translation/7 can be hard-coded, loaded at runtime, or whatever. If it's not present, we return the same event.
Remove solvables from a client or facilitator, and inform the parent if appropriate.
If called by a leaf or node agent, assumes agent it is already registered with a parent facilitator.
| solvable | a single solvable or a list of solvables, in shorthand or standard form. If a solvable is in standard form, however, ONLY the goal is considered in selecting the solvables to be removed (permissions and parameters are ignored). | |
| initial_params | address(X): Where the solvable exists. X may be either 'self' or 'parent' (or the appropriate local ids). Default: 'self'. | |
| undeclared_solvables | returns a list, in standard form, of all solvables successfully removed. |
Remove an event term from its communications wrapper (if any), and returns it in our standard internal form: 'timeout' OR event(Content, Params).
Note: First message from facilitator looks like:
term(event(ev_connected(LIST),[])) term/1 event/2Usually we get:
term(int, event(functor(LIST),[])) term/2 event/2For timeout:
timeout
| in_event,: | An event from another agent, which has already been translated for version compatibility, if necessary. | |
| connection_id | the CONNECTION of the immediate agent from which this message came (note that an agent's CONNECTION can be different than its ID). | |
| out_event | an event term in our standard internal format, as required by all other library procedures. |
Common code for oaa_AddData(), oaaRemoveData(), and oaa_ReplaceData().
| mode | add, remove, or replace. | |
| clause | may include whatever is appropriate for oaa_AddData(), oaaRemoveData(), or oaa_ReplaceData(). | |
| initial_params | may include whatever is appropriate for oaa_AddData(), oaaRemoveData(), or oaa_ReplaceData(). |
Check that an incoming lowlevel event should be processed.
This is the place to put security checks on events. The default behavior defined by the library can be made more stringent by individual agents using the callback oaa_AppValidateEvent(). oaa_ValidateEvent() has the right to modify the incoming event, or refuse it altogether by failing. This will return a newly allocated ICLTerm.
| int oaa_version_atleast | ( | int | major, | |
| int | minor, | |||
| int | level, | |||
| ICLTerm * | toCheck | |||
| ) |
Check if the given version list is at least [major,minor,level].
To indicate that portions of the version list are irrelevant, use -1.
| major | the minimum major value in the version, never -1 | |
| minor | the minimum minor value, or -1 to ignore minor and level values | |
| level | the minimum level value, or -1 to ignore | |
| toCheck | the version ICLTerm to check, must be a list |
| ICLTerm * param_default_list | ( | ) |
Returns the list of default parameters.
May be used with icl_ParamValue() to test or lookup an element
| ICLTerm * perm_default_list | ( | ) |
Returns the list of default permissions.
May be used with icl_ParamValue() to test or lookup an element
| int retract_all | ( | ICLTerm * | clause | ) |
Selects all List elements for which Selector(element) succeeds.
If there are multiple occurrences of Elt, only replaces the first teste_function is a pointer to a function of prototype : int func(ICLTerm* t) processed on each ICLTerm contained in the incoming list
Definition at line 90 of file libcom_tcp.c.
| char const* oaa_library_version_str = "[2,3,2]" |
| ICLTerm* oaa_saved_events = NULL |