Skip to content

Commit

Permalink
comm: identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 17, 2024
1 parent 28aaa49 commit ff8d562
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class comm
comm();
virtual ~comm();

virtual std::string get_identifier() const = 0;

virtual bool is_connected() = 0;

virtual bool has_data() = 0;
Expand Down
5 changes: 4 additions & 1 deletion comm_posix_tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
class comm_posix_tty: public comm
{
private:
int fd { -1 };
std::string dev;
int fd { -1 };

public:
comm_posix_tty(const std::string & dev, const int bitrate);
virtual ~comm_posix_tty();

std::string get_identifier() const override { return dev; }

bool is_connected() override;

bool has_data() override;
Expand Down
2 changes: 2 additions & 0 deletions comm_tcp_socket_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class comm_tcp_socket_client: public comm
comm_tcp_socket_client(const std::string & host, const int port);
virtual ~comm_tcp_socket_client();

std::string get_identifier() const override { host + format(":%d", port) + " (client)"; }

bool is_connected() override;

bool has_data() override;
Expand Down
2 changes: 2 additions & 0 deletions comm_tcp_socket_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class comm_tcp_socket_server: public comm
comm_tcp_socket_server(const int port);
virtual ~comm_tcp_socket_server();

std::string get_identifier() const override { format(":%d", port) + " (server)"; }

bool is_connected() override;

bool has_data() override;
Expand Down

0 comments on commit ff8d562

Please sign in to comment.