00001
00026 #ifndef MESSAGING_H_
00027 #define MESSAGING_H_
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #include <stdlib.h>
00034 #include <stdint.h>
00035
00036 struct array;
00037 struct datum;
00038
00041 typedef enum {
00042 NULL_CONTENT = 0,
00043 BYTE_CONTENT = 1,
00044 INT8_CONTENT = 2,
00045 UINT8_CONTENT = 3,
00046 INT16_CONTENT = 4,
00047 UINT16_CONTENT = 5,
00048 INT32_CONTENT = 6,
00049 UINT32_CONTENT = 7,
00050 INT64_CONTENT = 8,
00051 UINT64_CONTENT = 9,
00052 FLOAT_CONTENT = 10,
00053 DOUBLE_CONTENT = 11
00055 } Message_content_type;
00056
00062 typedef struct connection Connection;
00063
00073 typedef struct channel Channel;
00074
00076 typedef struct data {
00077
00079 int length;
00080
00082 Message_content_type type;
00083
00085 void const *content;
00086 } Data;
00087
00090 typedef struct message {
00092 int length;
00093
00095 Data *fields;
00096 } Message;
00097
00108 typedef struct messaging_controller {
00109
00122 void (*poll)(Connection *connection[], int count, int timeout);
00123
00125 void (*send_immediate)(Channel *channel, Message *message);
00126
00137 int (*process_messages)(Connection *connection, short limit);
00138 } Messaging_Controller;
00139
00146 typedef void (*callback)(Channel *channel, Message *mesg, void *state);
00147
00155 typedef struct messaging {
00156
00162 Connection *(*open_connection)(void);
00163
00168 Channel *(*open_channel)(Connection *connection, const char * channel_name);
00169
00173 void (*close_connection)(Connection *connection);
00174
00178 void (*close_channel)(Channel *channel);
00179
00184 void (*send)(Channel *channel, Message *message);
00185
00187 void (*unsubscribe)(Channel *channel);
00188
00190 void (*subscribe)(Channel *channel, callback fp, void *state);
00191
00198 Messaging_Controller *(*get_controller)();
00199
00200 } Messaging;
00201
00210 #ifdef __cplusplus
00211 }
00212 #endif
00213
00214 #endif