00001 #ifndef _FIPA_COMM_H_
00002 #define _FIPA_COMM_H_
00003
00004 #include <fipa_acl.h>
00005
00006 #ifndef true
00007 #define true 1
00008 #endif
00009
00010 #ifndef false
00011 #define false 0
00012 #endif
00013
00014 #define MC_NUM_PERFORMATIVES 23
00015
00016
00017 typedef int (*fipa_comm_callback)(char* received_content, char** reply_content);
00018 typedef int (*protocol_contract_net_callback)(int numBids, char** bids, char* winners);
00019
00020 enum fipa_comm_type_e {
00021 FIPA_COMM_ACTION,
00022 FIPA_COMM_CHECK,
00023 FIPA_COMM_REPLY,
00024 FIPA_COMM_CALLBACK,
00025 FIPA_COMM_END
00026 };
00027
00028 enum fipa_comm_logic_type_e {
00029 FIPA_COMM_LOGIC_ERROR = -1,
00030 FIPA_COMM_LOGIC_OR,
00031 FIPA_COMM_LOGIC_AND
00032 };
00033
00034 enum fipa_comm_check_type_e {
00035 FIPA_COMM_CHECK_ERROR = -1,
00036 FIPA_COMM_CHECK_SENDER_NAME,
00037 FIPA_COMM_CHECK_SENDER_ADDRESS,
00038 FIPA_COMM_CHECK_CONTENT,
00039 FIPA_COMM_CHECK_CONVERSATIONID,
00040 FIPA_COMM_CHECK_LANGUAGE,
00041 FIPA_COMM_CHECK_ONTOLOGY,
00042 FIPA_COMM_CHECK_ENCODING
00043 };
00044
00045 enum fipa_comm_action_type_e {
00046 FIPA_COMM_ACTION_ERROR = -1,
00047 FIPA_COMM_ACTION_BOTH,
00048 FIPA_COMM_ACTION_REPLY,
00049 FIPA_COMM_ACTION_CALLBACK,
00050 FIPA_COMM_ACTION_NONE
00051 };
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 struct fipa_comm_message_check_t
00073 {
00074 char* macro;
00075 enum fipa_comm_check_type_e type;
00076 struct fipa_comm_message_check_t* next;
00077 };
00078
00079 typedef struct fipa_comm_message_check_t fipa_comm_message_check_s;
00080 typedef struct fipa_comm_message_check_t* fipa_comm_message_check_p;
00081
00082
00083
00084
00085
00086 struct fipa_comm_reply_t
00087 {
00088 enum fipa_performative_e type;
00089 char* content;
00090 };
00091
00092 typedef struct fipa_comm_reply_t fipa_comm_reply_s;
00093 typedef struct fipa_comm_reply_t* fipa_comm_reply_p;
00094
00095
00096
00097
00098
00099 struct fipa_comm_action_t
00100 {
00101 enum fipa_comm_action_type_e type;
00102 fipa_comm_callback callback;
00103 fipa_comm_message_check_p check_list;
00104 fipa_comm_reply_p reply;
00105 struct fipa_comm_action_t* next;
00106 };
00107
00108 typedef struct fipa_comm_action_t fipa_comm_action_s;
00109 typedef struct fipa_comm_action_t* fipa_comm_action_p;
00110
00111
00112
00113
00114
00115 struct fipa_comm_performative_t
00116 {
00117 fipa_comm_action_p action_list;
00118 fipa_comm_reply_p default_reply;
00119 };
00120 typedef struct fipa_comm_performative_t fipa_comm_performative_s;
00121 typedef struct fipa_comm_performative_t* fipa_comm_performative_p;
00122
00123
00124
00125
00126
00127 enum fipa_comm_protocol_cn_state_e {
00128 FIPA_COMM_PROTOCOL_CN_ERROR = -1,
00129 FIPA_COMM_PROTOCOL_CN_START,
00130 FIPA_COMM_PROTOCOL_CN_CFP,
00131 FIPA_COMM_PROTOCOL_CN_BID,
00132 FIPA_COMM_PROTOCOL_CN_RESULT,
00133 FIPA_COMM_PROTOCOL_CN_DONE
00134 };
00135
00136 struct fipa_list_t {
00137 void* data;
00138 struct fipa_list_t* next;
00139 };
00140 typedef struct fipa_list_t fipa_list_s;
00141 typedef struct fipa_list_t* fipa_list_p;
00142
00143 struct fipa_comm_protocol_cn_t {
00144
00145 protocol_contract_net_callback contract_func;
00146 fipa_comm_callback proposal_func;
00147 char require_inform;
00148 int time_out;
00149 char* cfp_request;
00150
00151
00152 fipa_list_p replies;
00153 fipa_list_p queue;
00154 };
00155 typedef struct fipa_comm_protocol_cn_t fipa_comm_protocol_cn_s;
00156 typedef struct fipa_comm_protocol_cn_t* fipa_comm_protocol_cn_p;
00157
00158
00159
00160
00161
00162
00163 struct fipa_comm_protocol_t {
00164 char error;
00165 char state;
00166 char* conversation_id;
00167 char* network;
00168 enum fipa_protocol_e type;
00169 void* info;
00170 struct fipa_comm_protocol_t* next;
00171 };
00172 typedef struct fipa_comm_protocol_t* fipa_comm_protocol_p;
00173 typedef struct fipa_comm_protocol_t fipa_comm_protocol_s;
00174
00175
00176
00177
00178
00179 struct fipa_comm_t
00180 {
00181 int error;
00182 char* agent_name;
00183 char* agent_address;
00184 void* agent;
00185 char debug;
00186 fipa_comm_performative_p performative[MC_NUM_PERFORMATIVES];
00187 fipa_comm_reply_p default_reply;
00188 fipa_comm_protocol_p protocol[FIPA_PROTOCOL_END];
00189 fipa_comm_callback pCallbacks[FIPA_PROTOCOL_END];
00190
00191 };
00192 typedef struct fipa_comm_t fipa_comm_s;
00193 typedef struct fipa_comm_t* fipa_comm_p;
00194 typedef struct fipa_comm_t MCFIPAComm_s;
00195 typedef struct fipa_comm_t* MCFIPAComm_p;
00196
00197
00198
00199 fipa_comm_p mc_FIPAComm_New();
00200 int mc_FIPAComm_HandleMessage(
00201 fipa_comm_p fcomm,
00202 fipa_acl_message_p acl);
00203 int mc_FIPAComm_HandleMessageOnce(fipa_comm_p fcomm);
00204 int mc_FIPAComm_HandleMessageWait(fipa_comm_p fcomm);
00205 void mc_FIPAComm_Destroy(fipa_comm_p);
00206
00207
00208
00209
00210 int mc_FIPAComm_RegisterPerformative(
00211 fipa_comm_p fcomm,
00212 enum fipa_performative_e type);
00213
00214 int mc_FIPAComm_DeregisterPerformative(
00215 fipa_comm_p fcomm,
00216 enum fipa_performative_e type);
00217
00218 int mc_FIPAComm_SetDefaultReply(
00219 fipa_comm_p fcomm,
00220 enum fipa_performative_e type,
00221 char* content);
00222
00223 int mc_FIPAComm_SetPerformativeDefaultReply(
00224 fipa_comm_p fcomm,
00225 enum fipa_performative_e ptype,
00226 enum fipa_performative_e rtype,
00227 char* content);
00228
00229 int mc_FIPAComm_SetAgent(
00230 fipa_comm_p fcomm,
00231 void* agent,
00232 char* agent_name,
00233 char* agent_address);
00234
00235 int mc_FIPAComm_RegisterAction(
00236 fipa_comm_p fcomm,
00237 enum fipa_performative_e pType,
00238 enum fipa_comm_action_type_e aType, ...);
00239
00240 int mc_FIPAComm_RegisterActionS(
00241 fipa_performative_e type,
00242 fipa_comm_action_p act);
00243
00244
00245
00246
00247
00248 fipa_comm_protocol_p mc_FIPAProtocol_New();
00249
00250 int mc_FIPAComm_RegisterProtocolCallback(
00251 fipa_comm_p fcomm,
00252 enum fipa_protocol_e protocolType,
00253 fipa_comm_callback func);
00254
00255 int mc_FIPAComm_RegisterProtocol(
00256 fipa_comm_p fcomm,
00257 enum fipa_protocol_e protocolType,
00258 char* protocolID,
00259 void* info,
00260 char* network);
00261
00262 void fipa_comm_protocol_info_COPY(
00263 fipa_comm_protocol_p proto,
00264 void* info);
00265
00266 int fipa_list_Add(
00267 fipa_list_p* list,
00268 fipa_acl_message_p acl);
00269
00270 int mc_FIPAComm_StartProtocol(
00271 fipa_comm_p fcomm,
00272 enum fipa_protocol_e type,
00273 char* id);
00274
00275 int mc_FIPAComm_HandleProtocol(
00276 fipa_comm_p fcomm,
00277 fipa_acl_message_p acl);
00278
00279 fipa_comm_protocol_p mc_FIPAComm_AddNewProtocol(
00280 fipa_comm_p fcomm,
00281 enum fipa_protocol_e type,
00282 char* id);
00283
00284 int mc_FIPAComm_FSM_CN(
00285 fipa_comm_p fcomm,
00286 fipa_acl_message_p acl);
00287
00288 fipa_comm_protocol_p mc_FIPAComm_NewProtocol(
00289 enum fipa_protocol_e type,
00290 char* id);
00291
00292 int mc_FIPAComm_SetProtocolState(
00293 fipa_comm_protocol_p protocol,
00294 char state);
00295
00296
00297
00298 #pragma importf <fipa_comm.chf>
00299
00300 #endif