-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmlnmq.cpp
66 lines (49 loc) · 1.81 KB
/
smlnmq.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <nmq.hpp>
typedef void * smlnmq_context_t;
typedef void * smlnmq_node_t;
extern "C"
{
smlnmq_context_t sml_nmq_context (const char *fname) {
nmq::context_t *ctx = new nmq::context_t(fname);
return (smlnmq_context_t)ctx;
}
smlnmq_context_t sml_nmq_create (smlnmq_context_t ctx, unsigned int nodes, unsigned int size, unsigned int msg_size) {
if(!((nmq::context_t*)ctx)->create(nodes,size,msg_size))
return NULL;
return ctx;
}
smlnmq_context_t sml_nmq_open (smlnmq_context_t ctx, unsigned int nodes, unsigned int size, unsigned int msg_size) {
if(!((nmq::context_t*)ctx)->open(nodes,size,msg_size))
return NULL;
return ctx;
}
void sml_nmq_print (smlnmq_context_t ctx) {
((nmq::context_t*)ctx)->print();
}
void sml_nmq_close (smlnmq_context_t ctx) {
// Could consider deleting the file here...
delete (nmq::context_t*)ctx;
}
smlnmq_node_t sml_nmq_node(smlnmq_context_t ctx, unsigned int nodeid) {
nmq::node_t *node = new nmq::node_t(*((nmq::context_t*)ctx),nodeid);
return (smlnmq_node_t)node;
}
int sml_nmq_send(smlnmq_node_t node, unsigned int to, void *msg, unsigned int len) {
return ((nmq::node_t*)node)->send(to,msg,len);
}
int sml_nmq_sendnb(smlnmq_node_t node, unsigned int to, void *msg, unsigned int len) {
return ((nmq::node_t*)node)->sendnb(to,msg,len);
}
int sml_nmq_recvfrom(smlnmq_node_t node, unsigned int from, void *msg, size_t *len) {
return ((nmq::node_t*)node)->recv(from,msg,len);
}
int sml_nmq_recvfromnb(smlnmq_node_t node, unsigned int from, void *msg, size_t *len) {
return ((nmq::node_t*)node)->recvnb(from,msg,len);
}
int sml_nmq_recv(smlnmq_node_t node, void *msg, size_t *len) {
return ((nmq::node_t*)node)->recv(msg,len);
}
int sml_nmq_recvnb(smlnmq_node_t node, void *msg, size_t *len) {
return ((nmq::node_t*)node)->recvnb(msg,len);
}
}