forked from compilelife/feiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeiqmodel.h
More file actions
38 lines (32 loc) · 1.14 KB
/
feiqmodel.h
File metadata and controls
38 lines (32 loc) · 1.14 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
#ifndef FEIQMODEL_H
#define FEIQMODEL_H
#include "fellow.h"
#include <memory>
#include <list>
#include <mutex>
#include "filetask.h"
#include "uniqueid.h"
using namespace std;
class FeiqModel
{
public:
FeiqModel();
public:
void addFellow(shared_ptr<Fellow> fellow);
shared_ptr<Fellow> getFullInfoOf(shared_ptr<Fellow> fellow);
shared_ptr<Fellow> findFirstFellowOf(const string& ip);
list<shared_ptr<Fellow>> searchFellow(const string& text);
shared_ptr<Fellow> getShared(const Fellow* fellow);
public:
shared_ptr<FileTask> addDownloadTask(shared_ptr<Fellow> fellow, shared_ptr<FileContent> fileContent);
shared_ptr<FileTask> addUploadTask(shared_ptr<Fellow> fellow, shared_ptr<FileContent> fileContent);
shared_ptr<FileTask> findTask(IdType packetNo, IdType fileId, FileTaskType type = FileTaskType::Upload);
list<shared_ptr<FileTask>> searchTask(function<bool(const FileTask&)> predict);
void removeFileTask(function<bool (const FileTask&)> predict);
private:
list<shared_ptr<Fellow>> mFellows;
list<shared_ptr<FileTask>> mFileTasks;
mutex mFellowLock;
mutex mFileTaskLock;
};
#endif // FEIQMODEL_H