1 #ifndef SCD_CHAN_WRAPPER_H
2 #define SCD_CHAN_WRAPPER_H
7 using sc_core::sc_prim_channel;
9 #include "scd_sock_poller.h"
10 #include "scd_socket.h"
11 #include "scd_simulator.h"
12 #include "scd_rem_chan_if.h"
16 * Size of the input buffer. Limits the ammount of data that
17 * can be read from the socket in one system call.
19 static const size_t SCD_CHAN_BUFLEN = 512;
21 /* forward declaration */
26 * Wrapper for a remote channel. Writes data from the output buffer
27 * of the channel to the socket. Receives data from the socket and
28 * writes it to the input buffer of the channel.
30 class scd_chan_wrapper : public scd_sock_ev_handler_if
35 * \param sim the simulation environment
36 * \param name the name of the channel
37 * \param chan the SystemC channel implementing
38 * remote channel interface(s)
40 scd_chan_wrapper(scd_simulator& sim, const std::string& name,
41 sc_prim_channel& chan);
43 virtual ~scd_chan_wrapper();
46 * Indicates if a socket has been set for this channel.
47 * \return true if a socket has been set
49 bool is_initialized() const;
52 * Returns the name of the channel.
54 const std::string& get_name() const;
57 * Sets the socket of the channel.
59 void connect(scd_socket* sock);
62 * Checks if data has to be send or can be received again and activates
63 * transmission if necessary. Call this function after every simulation
69 * Closes the connection to the peer.
74 /* scd_sock_ev_handler_if */
75 void handle_sock_ev(sock_ev events);
76 const scd_socket &get_sock();
84 scd_rem_chan_in_if* _chan_in;
85 scd_rem_chan_out_if* _chan_out;
86 char _buf[SCD_CHAN_BUFLEN];
90 /* member functions */