dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hdsd / scd / scd_in_connector.h
diff --git a/dol/src/dol/visitor/hdsd/scd/scd_in_connector.h b/dol/src/dol/visitor/hdsd/scd/scd_in_connector.h
new file mode 100644 (file)
index 0000000..46e3c10
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef SCD_IN_CONNECTOR_H
+#define SCD_IN_CONNECTOR_H
+
+#include "scd_socket.h"
+#include "scd_sock_poller.h"
+#include "scd_simulator.h"
+#include "scd_command_reader.h"
+
+/**
+ * Reads a command from a socket handled over by scd_init_listener
+ * and dispatches the connection to either the control or channel manager.
+ * This is used during the initialization phase.
+ */
+class scd_in_connector : public scd_sock_ev_handler_if
+{
+public:
+    /**
+     * Constructor.
+     * \param sim the simulator
+     * \param sock the socket of the connection to read the command from
+     */
+    scd_in_connector(scd_simulator &sim, scd_socket* sock);
+
+    ~scd_in_connector();
+
+    /**
+     * Indicates if this in_connector is still reading the incomming command.
+     * It can be deconstructed when this indicates false.
+     * \return true if this in_connector is still working
+     */
+    bool is_connecting();
+
+    /* scd_sock_ev_handler_if */
+    void handle_sock_ev(sock_ev events);
+    const scd_socket& get_sock();
+
+private:
+    scd_socket* _socket;
+    scd_simulator &_sim;
+    bool _is_connecting;
+    scd_command_reader _reader;
+
+    void _cleanup();
+};
+
+#endif