Simple ports map onto an object-like C struct
with a
data()
and read()
or write()
function
members. The data()
function takes no parameter and returns a
pointer on the current port data. Input ports may refresh their data
by invoking the read()
method, while output ports may publish
new data by invoking the write()
method. Both read()
and
write()
return genom_ok
on success, or a
genom_event
exception representing an error code.
Ports defined with the multiple
flag map onto a similar
struct
, with the difference that data()
, read()
and write()
methods take an additional string (const char
*
) parameter representing the port element name. Multiple output
ports have two additional open()
and close()
members
(also accepting a single string parameter) that dynamically create or
destroy ports.
For instance, the following IDL:
port in double in_port; port multiple in double multi_in_port; port out double out_port; port multiple out double multi_out_port;
would map into
typedef struct { double * (*data)(); genom_event (*read)(void); } in_port; typedef struct { double * (*data)(const char *id); genom_event (*read)(const char *id); } multi_in_port; typedef struct { double * (*data)(); genom_event (*write)(void); } out_port; typedef struct { double * (*data)(const char *id); genom_event (*write)(const char *id); genom_event (*open)(const char *id); genom_event (*close)(const char *id); } multi_out_port;