Simple ports map onto a pure virtual struct
providing a
data()
and read()
or write()
methods. The
data()
method takes no parameter and returns a constant
reference 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 no value (void
).
Ports defined with the multiple
flag map onto a similar
pure virtual 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.
All these method may throw a genom::exception
representing an
error code.
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
struct in_port { virtual const double &data(void) const = 0; virtual void read(void) = 0; }; struct multi_in_port { virtual const double &data(const char *id) const = 0; virtual void read(const char *id) = 0; }; struct out_port { virtual double &data(void) const = 0; virtual void write(void) = 0; }; struct multi_out_port { virtual double &data(const char *id) const = 0; virtual void write(const char *id) = 0; virtual void open(const char *id) = 0; virtual void close(const char *id) = 0; };