-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added classes and methods prototypes
- Loading branch information
1 parent
c72b47d
commit 9ef9705
Showing
14 changed files
with
464 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ client ] | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: install cppcheck | ||
run: sudo apt-get install -y cppcheck | ||
|
||
- name: install valgrind | ||
run: sudo apt install valgrind | ||
|
||
- name: install gcovr and lcov | ||
run: | | ||
sudo apt install gcovr | ||
sudo apt install lcov | ||
- name: run cppcheck | ||
run: cd src && cppcheck *.cpp | ||
|
||
- name: build | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
- name: test client lib | ||
run: | | ||
cd build | ||
valgrind --leak-check=full ./test/client_tests | ||
- name: coverage | ||
run: | | ||
cd build | ||
make gcov | ||
make lcov | ||
- name: archive code coverage results | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: code-coverage-report_linear | ||
path: build/test/lcoverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16.3) | ||
|
||
project(link_share) | ||
|
||
add_subdirectory(src) | ||
|
||
#enable_testing() | ||
#add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
#include "client.hpp" | ||
#include <memory> | ||
#include <list> | ||
|
||
|
||
class UserInfo{ | ||
public: | ||
UserInfo(); | ||
UserInfo(std::string nm, std::string psw); | ||
~UserInfo(); | ||
|
||
private: | ||
std::string name; | ||
std::string password; | ||
}; | ||
|
||
|
||
class Room{ | ||
public: | ||
Room(std::string roomName); | ||
void addLink(std::string newLink); | ||
void removeLink(std::string linkName); | ||
void addParticipant(std::string newPart); | ||
void removeParticipant(std::string partName); | ||
std::string saveMask(std::string linkName); | ||
private: | ||
std::string roomName; | ||
std::string roomHost; | ||
std::vector<std::string> participants; | ||
std::vector<std::string> links; | ||
}; | ||
|
||
|
||
class Link { | ||
public: | ||
Link(std::string name, std::string url, std::string tag); | ||
~Link(); | ||
std::string addSnapshot(); | ||
|
||
private: | ||
std::string linkname; | ||
std::string url; | ||
std::vector<std::string> tags; | ||
std::vector<std::string> snapshotPaths; | ||
}; | ||
|
||
|
||
|
||
class Application { | ||
public: | ||
Application(); | ||
~Application(); | ||
/* void logIn(UserInfo inf); | ||
void logOut(); | ||
void createRoom(std::vector<std::string> participants); | ||
void addLink(std::string newLink); | ||
void removeLink(std::string linkName); | ||
*/ | ||
private: | ||
Client client; | ||
UserInfo info; | ||
std::vector<Room> rooms; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#include "socket.hpp" | ||
|
||
#include <netinet/in.h> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
class Client { | ||
public: | ||
Client(); | ||
~Client(); | ||
void connect(const std::string& host, int port); | ||
void writeToServer(std::string req); | ||
std::string readFromServer(); | ||
void closeCon(); | ||
|
||
private: | ||
Socket sock; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
class Request { | ||
public: | ||
virtual void buildRequestFromInput(std::istream s) = 0; | ||
virtual std::string RequestToString() = 0; | ||
}; | ||
|
||
class LogInReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string name; | ||
std::string password; | ||
}; | ||
|
||
class LogOutReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
}; | ||
|
||
class CreateRoomReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string roomName; | ||
std::string roomHost; | ||
std::vector<std::string> participants; | ||
}; | ||
|
||
class RemoveRoomReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string name; | ||
}; | ||
|
||
class AddLinkReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string linkName; | ||
std::string url; | ||
std::string tag; | ||
}; | ||
|
||
class RemoveLinkReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string linkName; | ||
}; | ||
|
||
class ArchiveLinkReq : public Request { | ||
public: | ||
void buildRequestFromInput(std::istream s) override; | ||
std::string RequestToString() override; | ||
private: | ||
std::string linkName; | ||
}; | ||
|
||
|
||
using requestPtr = std::shared_ptr<Request>; | ||
|
||
class RequestHandler { | ||
public: | ||
RequestHandler(); | ||
requestPtr HandleInput(std::string which); | ||
private: | ||
requestPtr _LogInReq; | ||
requestPtr _LogOutReq; | ||
requestPtr _CreateRoomReq; | ||
requestPtr _RemoveRoomReq; | ||
requestPtr _AddLinkReq; | ||
requestPtr _RemoveLinkReq; | ||
requestPtr _LinkReq; | ||
requestPtr _ArchiveLinkReq; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <memory> | ||
#include <vector> | ||
#include <application.hpp> | ||
#include <request.hpp> | ||
|
||
class Response { | ||
public: | ||
virtual void buildResponse(std::string responseBody) = 0; | ||
virtual void doLogic(const Request& req, Application& app) = 0; | ||
}; | ||
|
||
class LogInResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class LogOutResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class CreateRoomResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class RemoveRoomResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class AddLinkResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class RemoveLinkResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
}; | ||
|
||
class ArchiveLinkResp : public Response{ | ||
public: | ||
void buildResponse(std::string responseBody) override; | ||
void doLogic(const Request& req, Application& app) override; | ||
private: | ||
std::string body; | ||
}; | ||
|
||
|
||
using responsePtr = std::shared_ptr<Response>; | ||
|
||
class ResponseHandler { | ||
public: | ||
ResponseHandler(); | ||
responsePtr HandleInput(std::string resposeBody); | ||
private: | ||
responsePtr _LogInResp; | ||
responsePtr _LogOutResp; | ||
responsePtr _CreateRoomResp; | ||
responsePtr _RemoveRoomResp; | ||
responsePtr _AddLinkResp; | ||
responsePtr _RemoveLinkResp; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <unistd.h> // close() | ||
#include <memory> | ||
#include <string> | ||
|
||
class Socket | ||
{ | ||
public: | ||
Socket(); | ||
Socket(int sd); | ||
~Socket(); | ||
|
||
void connect(const std::string& host, int port); | ||
void send(const std::string& str); | ||
std::string recv(); | ||
void close(); | ||
private: | ||
int sd; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
add_library(client STATIC application.src client.cpp request.cpp response.cpp socket.src) | ||
target_include_directories(client PUBLIC "${PROJECT_SOURCE_DIR}/include") | ||
|
||
add_definitions(-Wall -Werror -Wpedantic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "application.hpp" | ||
|
||
|
||
UserInfo::UserInfo() {} | ||
UserInfo::UserInfo(std::string nm, std::string psw) {} | ||
UserInfo::~UserInfo() {} | ||
|
||
|
||
Room::Room(std::string roomName) {} | ||
void Room::addLink(std::string newLink) {} | ||
void Room::removeLink(std::string linkName) {} | ||
void Room::addParticipant(std::string newPart) {} | ||
void Room::removeParticipant(std::string partName) {} | ||
std::string Room::saveMask(std::string linkName) {} | ||
|
||
|
||
|
||
Link::Link(std::string name, std::string url, std::string tag) {} | ||
Link::~Link() {} | ||
std::string Link::addSnapshot() {} | ||
|
||
|
||
Application::Application() {} | ||
Application::~Application() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "client.hpp" | ||
|
||
Client::Client() {} | ||
|
||
Client::~Client() {} | ||
|
||
void Client::connect(const std::string& host, int port) {} | ||
|
||
std::string Client::readFromServer() { return "we"; } | ||
|
||
void Client::writeToServer(std::string req) {} | ||
|
||
void Client::closeCon() {} | ||
|
||
|
Oops, something went wrong.