1 #ifndef SCD_COMMAND_WRITER_H
2 #define SCD_COMMAND_WRITER_H
6 #include "scd_command.h"
7 #include "scd_socket.h"
11 * Queues multiple commands and writes then to a socket continuously.
13 class scd_command_writer
18 virtual ~scd_command_writer();
21 * Sets the socket to write to. Do not try to write before
24 void set_socket(scd_socket& sock);
27 * Indicates if the writer is currently sending a command.
28 * \return true if the writer is busy sending commands
30 bool is_writing() const;
33 * Queues a command to be sent. Commands will be sent out in FIFO
34 * manner. Sending is not initiated by this call.
35 * \param message to send
36 * \return false if the message is longet than SCD_CM_MAXLEN. In this
37 * case the message is destroyed.
39 bool queue_command(scd_command* cmd);
42 * Write commands or part of commands to the socket. As many queued
43 * commands as possible are sent but none has to be finished.
44 * \exception scd_exception if unexpected errors occured
52 std::list<scd_command*>_commands;
53 char _buf[SCD_CM_HEADER + SCD_CM_MAXLEN];
57 inline bool _send_cmd();