You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

feiqmodel.h 1.2 kB

8 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef FEIQMODEL_H
  2. #define FEIQMODEL_H
  3. #include "fellow.h"
  4. #include <memory>
  5. #include <list>
  6. #include <mutex>
  7. #include "filetask.h"
  8. #include "uniqueid.h"
  9. using namespace std;
  10. class FeiqModel
  11. {
  12. public:
  13. FeiqModel();
  14. public:
  15. void addFellow(shared_ptr<Fellow> fellow);
  16. shared_ptr<Fellow> getFullInfoOf(shared_ptr<Fellow> fellow);
  17. shared_ptr<Fellow> findFirstFellowOf(const string& ip);
  18. list<shared_ptr<Fellow>> searchFellow(const string& text);
  19. shared_ptr<Fellow> getShared(const Fellow* fellow);
  20. public:
  21. shared_ptr<FileTask> addDownloadTask(shared_ptr<Fellow> fellow, shared_ptr<FileContent> fileContent);
  22. shared_ptr<FileTask> addUploadTask(shared_ptr<Fellow> fellow, shared_ptr<FileContent> fileContent);
  23. shared_ptr<FileTask> findTask(IdType packetNo, IdType fileId, FileTaskType type = FileTaskType::Upload);
  24. list<shared_ptr<FileTask>> searchTask(function<bool(const FileTask&)> predict);
  25. void removeFileTask(function<bool (const FileTask&)> predict);
  26. private:
  27. list<shared_ptr<Fellow>> mFellows;
  28. list<shared_ptr<FileTask>> mFileTasks;
  29. mutex mFellowLock;
  30. mutex mFileTaskLock;
  31. };
  32. #endif // FEIQMODEL_H

mac下的“飞秋”大多数只是飞鸽传书协议,而且未发现令人满意的开源项目,所以基于c++与qt实现了基础的飞秋协议。

Contributors (1)