libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / mail / QueryList.h
blob47205eaef5c1a976aa60e10e517bac06375b2e28
1 /*
2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef QUERY_LIST_H
6 #define QUERY_LIST_H
9 #include <map>
10 #include <vector>
12 #include <Entry.h>
13 #include <Handler.h>
14 #include <Locker.h>
15 #include <ObjectList.h>
16 #include <Query.h>
19 struct QueryList;
22 class QueryListener {
23 public:
24 virtual ~QueryListener();
25 virtual void EntryCreated(QueryList& source,
26 const entry_ref& ref, ino_t node) = 0;
27 virtual void EntryRemoved(QueryList& source,
28 const node_ref& nodeRef) = 0;
32 typedef std::map<node_ref, entry_ref> RefMap;
35 class QueryList : public BHandler, public BLocker {
36 public:
37 QueryList();
38 virtual ~QueryList();
40 status_t Init(const char* predicate,
41 BVolume* volume = NULL);
43 void AddListener(QueryListener* listener);
44 void RemoveListener(QueryListener* listener);
46 const RefMap& Entries() const
47 { return fRefs; }
49 virtual void MessageReceived(BMessage* message);
51 private:
52 void _AddEntry(const entry_ref& ref, ino_t node);
53 void _RemoveEntry(const node_ref& nodeRef);
54 void _NotifyEntryCreated(const entry_ref& ref,
55 ino_t node);
56 void _NotifyEntryRemoved(const node_ref& nodeRef);
57 void _AddVolume(BVolume& volume,
58 const char* predicate);
60 static status_t _FetchQuery(void* self);
61 status_t _FetchQuery();
63 private:
64 typedef std::vector<thread_id> ThreadVector;
65 typedef std::vector<BQuery*> QueryVector;
67 bool fQuit;
68 RefMap fRefs;
69 QueryVector fQueries;
70 QueryVector fQueryQueue;
71 ThreadVector fFetchThreads;
72 BObjectList<QueryListener> fListeners;
76 #endif // QUERY_LIST_H