-
Notifications
You must be signed in to change notification settings - Fork 1
/
Query.h
67 lines (47 loc) · 1.1 KB
/
Query.h
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
66
67
/*
* Copyright (c) 2019 pinc Software. All Rights Reserved.
*/
#ifndef QUERY_H
#define QUERY_H
#include <Messenger.h>
#include <ObjectList.h>
#include <String.h>
#include <Url.h>
#include <map>
class BUrl;
class Retriever;
enum UrlType {
kSource,
kThumbImage,
kLargeImage,
kOriginalImage,
};
typedef std::map<UrlType, BUrl> UrlMap;
class ResultListener {
public:
virtual void AddResult(const BString& id,
const char* info, UrlMap urls) = 0;
};
class Query : public ResultListener {
public:
Query(const BString& artist,
const BString& title);
virtual ~Query();
void AddRetriever(Retriever* retriever);
void AddListener(ResultListener* listener);
void Run();
void Abort(bool wait = true);
virtual void AddResult(const BString& id,
const char* info, UrlMap urls);
private:
static status_t _Run(void* self);
status_t _Run();
private:
thread_id fThread;
BObjectList<Retriever> fRetrievers;
BObjectList<ResultListener> fListeners;
BString fArtist;
BString fTitle;
bool fAbort;
};
#endif // QUERY_H