xref: /haiku/src/add-ons/kernel/file_systems/packagefs/indices/Query.h (revision f73f5d4c42a01ece688cbb57b5d332cc0f68b2c6)
1 /*
2  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef QUERY_H
6 #define QUERY_H
7 
8 
9 #include <SupportDefs.h>
10 
11 #include <util/DoublyLinkedList.h>
12 
13 
14 struct dirent;
15 
16 namespace QueryParser {
17 	template<typename QueryPolicy> class Query;
18 };
19 
20 class Node;
21 class Volume;
22 
23 
24 class Query : public DoublyLinkedListLinkImpl<Query> {
25 public:
26 							~Query();
27 
28 	static	status_t		Create(Volume* volume, const char* queryString,
29 								uint32 flags, port_id port, uint32 token,
30 								Query*& _query);
31 
32 			status_t		Rewind();
33 			status_t		GetNextEntry(struct dirent* entry, size_t size);
34 
35 			void			LiveUpdate(Node* node,
36 								const char* attribute, int32 type,
37 								const void* oldKey, size_t oldLength,
38 								const void* newKey, size_t newLength);
39 
40 private:
41 			struct QueryPolicy;
42 			friend struct QueryPolicy;
43 			typedef QueryParser::Query<QueryPolicy> QueryImpl;
44 
45 private:
46 							Query(Volume* volume);
47 
48 			status_t		_Init(const char* queryString, uint32 flags,
49 								port_id port, uint32 token);
50 
51 private:
52 			Volume*			fVolume;
53 			QueryImpl*		fImpl;
54 };
55 
56 
57 typedef DoublyLinkedList<Query> QueryList;
58 
59 
60 #endif	// QUERY_H
61