From f079d926b7b34c0d770c3641be946a6f6c2459f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Mon, 23 Jul 2018 17:35:46 +0200 Subject: [PATCH] Adding more interfaces to be implemented. --- include/neocomm/channel.hpp | 47 ++++++++++++++++++++++++++++++++++++ include/neocomm/identity.hpp | 34 ++++++++++++++++++++++++++ include/neocomm/message.hpp | 38 +++++++++++++++++++++++++++++ include/neocomm/node.hpp | 26 ++++++++++++++++++++ src/channel.cpp | 0 src/message.cpp | 0 src/node.cpp | 2 ++ 7 files changed, 147 insertions(+) create mode 100644 include/neocomm/identity.hpp delete mode 100644 src/channel.cpp delete mode 100644 src/message.cpp diff --git a/include/neocomm/channel.hpp b/include/neocomm/channel.hpp index e69de29..f5346f9 100644 --- a/include/neocomm/channel.hpp +++ b/include/neocomm/channel.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#include "identity.hpp" + +namespace neocomm { + +/** + * @brief Container class of all data and basic functions pertaining to + * channel functionality. + */ +class channel { +public: + /** + * @brief Initialize the channel class and start receiving messages + * for the given ID. + * + * @param chan_id The ID of the channel. + */ + channel(const std::string &chan_id); // TODO + ~channel(); // TODO +private: + const std::string chan_id; + std::vector identities; // users currently known to be in the channel + std::vector msgs; // messages to and from the channel +}; + +} diff --git a/include/neocomm/identity.hpp b/include/neocomm/identity.hpp new file mode 100644 index 0000000..92079f7 --- /dev/null +++ b/include/neocomm/identity.hpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +namespace neocomm { + +/** + * @brief Container class for data pertaining to a user. + */ +class identity { +public: +private: + const std::string id; + std::string nick; + std::string client_info; +}; + +} diff --git a/include/neocomm/message.hpp b/include/neocomm/message.hpp index e69de29..aaafbbd 100644 --- a/include/neocomm/message.hpp +++ b/include/neocomm/message.hpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2018 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include + +#include "identity.hpp" + +namespace neocomm { + +/** + * @brief Container for data of a user message. + */ +class message { +private: + const std::string text; + const struct tm time_stamp; + const identity from; +}; + +} diff --git a/include/neocomm/node.hpp b/include/neocomm/node.hpp index 00d50f9..9535f5b 100644 --- a/include/neocomm/node.hpp +++ b/include/neocomm/node.hpp @@ -18,6 +18,9 @@ #pragma once +#include "channel.hpp" + +#include #include #include @@ -70,7 +73,30 @@ public: */ void export_nodes(const std::string &node_file); + /** + * @brief Join and receive messages from a channel. + * + * @param chan_id The ID of the channel. + */ + void join_channel(const std::string &chan_id); // TODO + /** + * @brief Retrieve the channel object. + * + * @param chan_id The ID of the channel. + * + * @return The channel object. + */ + channel* get_channel(const std::string &chan_id); // TODO + /** + * @brief Leave a channel. + * + * @param chan_id The ID of the channel. + */ + void leave_channel(const std::string &chan_id); // TODO + private: + std::vector channels; dht::DhtRunner dht_node; }; + } diff --git a/src/channel.cpp b/src/channel.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/message.cpp b/src/message.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/node.cpp b/src/node.cpp index aaaa369..98ce772 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -51,6 +51,8 @@ neocomm::node::node(const std::string &node_file, // rethrow exception throw e; } + + import_nodes(node_file); } neocomm::node::~node() {