-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client #3
base: main
Are you sure you want to change the base?
Client #3
Changes from all commits
9ef9705
87ddd0e
37715c5
7fc3ae4
db999d7
82bde25
6531e16
ebfa8db
24227bb
076bc9e
b8fd891
225299d
6de03f0
985dd79
3339e88
8dc195d
f00d935
82043c9
f14559e
c099009
255bc0d
837acb2
5043f2d
8a30a02
d90ec82
20ed769
fe5ff7a
db3d341
c9caa36
d03341a
a4f47cf
2fb9365
7f9d74c
64cf698
f80127f
ea87c45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: CI_client | ||
|
||
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 client/src && cppcheck *.cpp | ||
|
||
- name: build | ||
run: | | ||
cd client | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
|
||
#- name: test socket | ||
# run: | | ||
# cd client/build | ||
# valgrind --leak-check=full ./test/socket_tests | ||
|
||
#- name: test response | ||
# run: | | ||
# cd client/build | ||
# valgrind --leak-check=full ./test/response_tests | ||
|
||
#- name: test request | ||
# run: | | ||
# cd client/build | ||
# valgrind --leak-check=full ./test/request_tests | ||
|
||
#- name: test client | ||
# run: | | ||
# cd client/build | ||
# valgrind --leak-check=full ./test/client_tests | ||
|
||
#- name: test application | ||
# run: | | ||
# cd client/build | ||
# valgrind --leak-check=full ./test/application_tests | ||
|
||
- name: coverage | ||
run: | | ||
cd client/build | ||
make gcov | ||
make lcov | ||
- name: archive code coverage results | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: code-coverage-report_linear | ||
path: client/build/test/lcoverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.16.3) | ||
|
||
project(link_share) | ||
|
||
|
||
|
||
add_subdirectory(src) | ||
|
||
enable_testing() | ||
#add_subdirectory(test) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
#include <netinet/in.h> | ||
#include <string> | ||
|
||
#include "socket.hpp" | ||
#include "socket.hpp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. между первой и второй? :) |
||
|
||
|
||
|
||
class Client { | ||
public: | ||
Client(const std::string& _host, int _port); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. уберите _ |
||
~Client() {} | ||
void Connect(); | ||
void Close(); | ||
void writeToServer(std::string& req); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Request - это куда более сложная структура, чем string |
||
std::string readFromServer(bool* endFlag); | ||
std::vector<char> readFileBodyFromServer(bool* endFlag); | ||
private: | ||
const std::string& host; | ||
int port; | ||
Socket sock; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
template<typename T, typename... Args> | ||
void writeData(T* key); | ||
|
||
template<typename T, typename... Args> | ||
void writeData(T* key, Args... args); | ||
|
||
void fillObject(std::string* str); | ||
void fillObject(std::vector<std::string>* str); | ||
|
||
|
||
std::string createRoomInput(); | ||
std::string deleteRoomInput(); | ||
std::string addUsersInput(); | ||
std::string deleteUsersInput(); | ||
std::string addLinkInput(); | ||
std::string deleteLinkInput(); | ||
std::string makeSnapshotInput(); | ||
std::string logInInput(); | ||
std::string signUpInput(); | ||
std::string downloadSnapshotInput(); | ||
std::string getUserRoomInput(); | ||
std::string getUserLinksInput(); | ||
std::string getLinkSnapshotsInput(); | ||
|
||
#include "inputUtils.tpp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. обычно это как раз-таки hpp... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем? |
||
|
||
template<typename T, typename... Args> | ||
void writeData(T* key) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем? |
||
fillObject(key); | ||
} | ||
|
||
template<typename T, typename... Args> | ||
void writeData(T* key, Args... args) { | ||
fillObject(key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. writeData(key); |
||
writeData(args...); | ||
Comment on lines
+5
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем выносить в отдельный файл? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include <memory> | ||
|
||
class LinkImpl; | ||
|
||
class Link { | ||
public: | ||
Link(std::string& name, std::string& url, std::string& uuid, std::string& description); | ||
Link(Link& link); | ||
~Link(); | ||
std::string GetLinkName(); | ||
std::string GetLinkInfo(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. почему возвращается не LinkInfo, а string? |
||
std::shared_ptr<LinkImpl> getLinkImpl(); | ||
std::string GetSnapshotUuid(); | ||
void SetLinkInfo(); | ||
void AddSnapshot(const std::string& uuid); | ||
private: | ||
std::shared_ptr<LinkImpl> linkImpl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. обычно для этого используется unique_ptr, т.к. он "легче" |
||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <vector> | ||
#include "room.hpp" | ||
#include "userinfo.hpp" | ||
|
||
|
||
typedef struct recFile | ||
{ | ||
std::string name; | ||
std::vector<char> body; | ||
} recFile; | ||
|
||
|
||
template <class ResponseParser> | ||
class ModelImpl; | ||
|
||
template <class ResponseParser> | ||
class Model { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. название особо ни о чём не говорит :/ |
||
public: | ||
Model(); | ||
~Model(); | ||
std::string GetRoomInfoStr(const std::string& roomName); | ||
std::string GetCurrentRoomInfoStr(); | ||
std::string GetLinkInfoStr(const std::string& linkName); | ||
std::string GetLinkSnapshotInfoStr(const std::string& linkName); | ||
void SetUserInfo(std::shared_ptr<UserInfo> info); | ||
std::string GetUserInfoStr(); | ||
void AddUsers(std::vector<std::string> users); | ||
void AddSnapshotUuid(const std::string& linkname, const std::string& uuid); | ||
void RemoveUsers(std::vector<std::string> users); | ||
void AddLink(std::shared_ptr<Link> newLink); | ||
void RemoveLink(const std::string& linkName); | ||
void AddRoom(std::shared_ptr<Room> newRoom); | ||
void RemoveRoom(const std::string& roomName); | ||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. почему добавление по указателю, а удаление по имени? |
||
std::string FormRequest(std::string& action); | ||
void HandleResponse(std::string& response); | ||
void HandleFile(recFile& newFile); | ||
bool IsHandlerRecievingFiles(); | ||
bool IsServRequired(); | ||
bool IsLogin(); | ||
private: | ||
std::shared_ptr<ModelImpl<ResponseParser>> modelImpl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unique_ptr |
||
}; | ||
|
||
#include "model.tpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
обычно CI запускает один скрипт, а какие тесты запускать/не запускать задаются конфигом и/или уже на уровне этого скрипта