aboutsummaryrefslogtreecommitdiff
path: root/include/common.h
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
commit6b1444aa3918382aba127c16c671f045a3586e53 (patch)
tree08b6b1e55383d63ba4e5824071620a35f737925c /include/common.h
parent2250b4db92bd272dbb1fd717eb791e293c17e37a (diff)
Common pipe replaced with sender/receiver functors.
[#27] C library now only takes care of relaying data to/from functors, which must be provided by the wrapping application (in this case, a new python module named 'common.py').
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/include/common.h b/include/common.h
index 7386a34..50ac563 100644
--- a/include/common.h
+++ b/include/common.h
@@ -2,17 +2,34 @@
* @file common.h
* @author Paul Oliver
*
-* This module controls the 'common pipe', which is the FIFO file through which
+* This module controls the common sender and receiver functors, through which
* communication between different simulations can occur. By calling SEND,
-* processes may output local instructions through the pipe. These instructions
-* may then be read by processes running on a different simulation instance.
+* processes may output local instructions through a network. These instructions
+* may then be read by processes running on a different simulation somewhere
+* else.
*/
#ifndef SALIS_COMMON_H
#define SALIS_COMMON_H
-void _sal_comm_init(string pipe);
-void _sal_comm_quit(void);
+/* Typedef sender functor type for easy python parsing.
+*/
+typedef void (*Sender)(uint8 inst);
+
+/* Typedef receiver functor type for easy python parsing.
+*/
+typedef uint8 (*Receiver)(void);
+
+/* Set sender functor. When unset, SEND instruction does nothing.
+* @param sender Sender functor
+*/
+SALIS_API void sal_comm_set_sender(Sender sender);
+
+/* Set receiver functor. When unset, RCVE instruction does nothing.
+* @param receiver Receiver functor
+*/
+SALIS_API void sal_comm_set_receiver(Receiver receiver);
+
void _sal_comm_send(uint8 inst);
uint8 _sal_comm_receive(void);