1 | /*------------------------------------------------------------------------------ |
2 | * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team |
3 | * |
4 | * Distributable under the terms of either the Apache License (Version 2.0) or |
5 | * the GNU Lesser General Public License, as specified in the COPYING file. |
6 | ------------------------------------------------------------------------------*/ |
7 | #ifndef _lucene_search_Explanation |
8 | #define _lucene_search_Explanation |
9 | |
10 | #if defined(_LUCENE_PRAGMA_ONCE) |
11 | # pragma once |
12 | #endif |
13 | |
14 | CL_NS_DEF(search) |
15 | |
16 | #define LUCENE_SEARCH_EXPLANATION_DESC_LEN 200 |
17 | class Explanation :LUCENE_BASE { |
18 | private: |
19 | qreal value; // the value of this node |
20 | TCHAR description[LUCENE_SEARCH_EXPLANATION_DESC_LEN]; // what it represents |
21 | CL_NS(util)::CLArrayList<Explanation*,CL_NS(util)::Deletor::Object<Explanation> > details; // sub-explanations |
22 | |
23 | TCHAR* toString(int32_t depth); |
24 | protected: |
25 | Explanation(const Explanation& copy); |
26 | public: |
27 | Explanation(); |
28 | ~Explanation(); |
29 | |
30 | Explanation(qreal value, const TCHAR* description); |
31 | void set(const Explanation& other); |
32 | |
33 | Explanation* clone() const; |
34 | |
35 | /** The value assigned to this explanation node. */ |
36 | qreal getValue() const; |
37 | |
38 | /** Sets the value assigned to this explanation node. */ |
39 | void setValue(qreal value); |
40 | |
41 | /** A description of this explanation node. */ |
42 | const TCHAR* getDescription() const; ///<returns reference |
43 | |
44 | /** Sets the description of this explanation node. */ |
45 | void setDescription(const TCHAR* description); |
46 | |
47 | /** The sub-nodes of this explanation node. |
48 | * @param ret this array of Explanations should be getDetailsLength()+1 in size. |
49 | The array will be null terminated. |
50 | */ |
51 | void getDetails(Explanation** ret); |
52 | int getDetailsLength(); |
53 | Explanation* getDetail(int i); |
54 | |
55 | /** Adds a sub-node to this explanation node. */ |
56 | void addDetail(Explanation* detail); |
57 | |
58 | /** Render an explanation as text. */ |
59 | TCHAR* toString(); |
60 | |
61 | /** Render an explanation as HTML. */ |
62 | TCHAR* toHtml(); |
63 | }; |
64 | |
65 | CL_NS_END |
66 | #endif |
67 | |