-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyncedFileServer.h
More file actions
65 lines (47 loc) · 2.03 KB
/
Copy pathSyncedFileServer.h
File metadata and controls
65 lines (47 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Created by stefano on 06/08/20.
//
#ifndef FILEWATCHER_SYNCEDFILE_H
#define FILEWATCHER_SYNCEDFILE_H
#include <string>
#include <optional>
#include <boost/property_tree/ptree.hpp>
enum class FileStatus {created, modified, erased, not_valid};
class SyncedFileServer {
private:
std::string path;
std::string hash = "";
unsigned long file_size = 0;
bool is_file;
FileStatus fileStatus = FileStatus::not_valid;
// il file viene aggiunto alla coda di file da modificare,
// fino a quando non si inizia il caricamento il file non viene riaggiunto
// alla coda se sono effettuate ulteriori modifiche
// la variabile is_syncing deve essere letta e modificata solo dalla classe
// UploadJobs che la protegge con un lock nel caso ci sia un thread pool che effettua l'upload parallelo
bool is_syncing = false;
public:
// SyncedFileServer();
explicit SyncedFileServer(const std::string& JSON);
// SyncedFileServer(SyncedFileServer const &syncedFile);
void update_file_data();
static std::string CalcSha256(const std::string& filename);
std::string to_string();
//Deleted solo perchè non li usiamo e perchè evitiamo di usarli inconsciamente
SyncedFileServer(SyncedFileServer const &syncedFile)=delete;
SyncedFileServer(SyncedFileServer&& syncedFile)=delete;
SyncedFileServer& operator=(const SyncedFileServer& syncedFile)=delete;
SyncedFileServer&& operator=(SyncedFileServer&& syncedFile)=delete;
bool operator==(const SyncedFileServer &rhs) const;
bool operator!=(const SyncedFileServer &rhs) const;
[[nodiscard]] const std::string &getPath() const;
[[nodiscard]] const std::string &getHash() const;
[[nodiscard]] FileStatus getFileStatus() const;
[[nodiscard]] unsigned long getFileSize() const;
[[nodiscard]] bool isSyncing() const;
[[nodiscard]] bool isFile() const;
void setSyncing(bool syncing);
std::string getJSON();
boost::property_tree::basic_ptree<std::string, std::string> getPtree();
};
#endif //FILEWATCHER_SYNCEDFILE_H