ddc
QueryOptions.h
Go to the documentation of this file.
1 //-*- Mode: C++ -*-
2 // DDC originally by Alexey Sokirko
3 // Changes and modifications 2011-2020 by Bryan Jurish
4 //
5 // This file is part of DDC.
6 //
7 // DDC is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // DDC is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with DDC. If not, see <http://www.gnu.org/licenses/>.
19 //
20 
21 #ifndef DDC_QUERY_OPTIONS_H
22 #define DDC_QUERY_OPTIONS_H
23 
24 #include "../ConcordLib/QueryFilter.h"
25 
26 //======================================================================
27 // typedefs
28 
29 class CQueryCompiler; //-- forward decl
30 
31 typedef vector<CQFilter*> CQFilterList;
32 typedef vector<string> CQSubcorpusList;
33 typedef list<string> CQCommentList;
34 
35 //======================================================================
39 class CQueryOptions : public ddcObject {
40 public:
43 
44  // if true, DDC shows file names, instead of bibliographical information for this query
47 
50 
54 
57 
59  vector<string> m_Within;
60 
62  string m_HitTypeStr;
63 
66 
68  vector<CDDCFilterWithBounds> m_Filters;
69 
72 
75 
78 
79 public:
80  //------------------------------------------------------------
82 
83 
86  :
87  m_ContextSentencesCount(0),
88  m_bEnableBibliography(true),
89  m_bDebugRank(false),
90  m_bSeparateHits(false),
91  m_TextAreaNo(UnknownTextAreaNo),
92  m_HitTypeStr("")
93  {};
94 
96  virtual ~CQueryOptions(void);
97 
99  void swap(CQueryOptions &x);
100 
102  void assign(const CQueryOptions &src, bool deep=true);
103 
105  inline CQueryOptions* Clone(void) const
106  {
107  CQueryOptions *clone = new CQueryOptions();
108  clone->assign(*this);
109  return clone;
110  };
111 
114  {
115  CQueryOptions *clone = new CQueryOptions();
116  clone->assign(*this,false);
117  return clone;
118  };
120 
121 public:
122  //------------------------------------------------------------
124 
125 
127  virtual bool CheckSatisfiable(CQueryCompiler *compiler);
128 
130  virtual bool Compile(CQueryCompiler *compiler);
131 
133  virtual void Clear();
134 
136  void ClearComments();
137 
139  bool CanFilterByFile() const;
140 
142  bool IsTrivialFilter() const;
143 
145  CQFilter *PrimarySortFilter() const;
146 
148  bool IsPruneFilter() const;
150 
151 public:
152  //------------------------------------------------------------
154 
155  virtual ddcObjectList Children() const;
156  virtual void DisownChildren();
157  virtual string toString();
158  virtual string jsonClass() { return "CQueryOptions"; };
159  virtual string jsonData();
161 };
162 
163 #endif /* DDC_QUERY_OPTIONS_H */
164 
165 /*--- emacs style variables ---
166  * Local Variables:
167  * mode: C++
168  * c-file-style: "ellemtel"
169  * c-basic-offset: 4
170  * tab-width: 8
171  * indent-tabs-mode: nil
172  * End:
173  */
bool IsTrivialFilter() const
returns true iff all defined filters are trivial (i.e. do not change default hit-sort order) ...
Definition: QueryOptions.cpp:201
CQueryOptions * Clone(void) const
clone object (wraps new() and assign())
Definition: QueryOptions.h:105
string m_HitTypeStr
the break collection name which should be used while querying
Definition: QueryOptions.h:62
CQueryOptions()
Default constructor.
Definition: QueryOptions.h:85
virtual ~CQueryOptions(void)
Default destructor; calls Clear.
Definition: QueryOptions.cpp:28
void ClearComments()
clear comments
Definition: QueryOptions.cpp:184
vector< CDDCFilterWithBounds > m_Filters
(runtime) filters and sort operators which should be applied to the resulted hit set (available after...
Definition: QueryOptions.h:68
virtual void DisownChildren()
Definition: QueryOptions.cpp:359
class for global query filters aka "query operators"
Definition: QueryFilter.h:35
vector< string > m_Within
list of all &#39;WITHIN&#39; arguments (break collections or text areas) from currently parsed query ...
Definition: QueryOptions.h:59
CQCommentList m_Comments
user comments for this query (#CMT[comment text])
Definition: QueryOptions.h:74
virtual ddcObjectList Children() const
Definition: QueryOptions.cpp:353
virtual string jsonClass()
Definition: QueryOptions.h:158
virtual string toString()
Definition: QueryOptions.cpp:228
void assign(const CQueryOptions &src, bool deep=true)
assign options (copies filter list if deep is true)
Definition: QueryOptions.cpp:51
int m_TextAreaNo
the index of text area where DDC should perform the input query
Definition: QueryOptions.h:56
CQCommentList m_LexerComments
lexer comments for this query (#[lexer comment], #:line comment)
Definition: QueryOptions.h:77
bool m_bSeparateHits
Definition: QueryOptions.h:53
class for global query filters aka "query operators"
Definition: ddcObject.h:45
bool m_bDebugRank
if true, DDC initializes CHit::m_DebugRank
Definition: QueryOptions.h:49
CQFilter * PrimarySortFilter() const
returns a pointer (into m_QFilters) to the primary sort-filter, or NULL if no sort-filters are define...
Definition: QueryOptions.cpp:211
list< ddcObject * > ddcObjectList
Definition: ddcObject.h:28
vector< string > CQSubcorpusList
Definition: QueryOptions.h:32
size_t m_ContextSentencesCount
how many hits of the left and right context should be output (must be <= m_MaxContextSentencesCount) ...
Definition: QueryOptions.h:42
root-level query options (filters and flags)
Definition: QueryOptions.h:39
bool CanFilterByFile() const
returns true iff all defined filters are file-based (for optimized count(*) evaluation) ...
Definition: QueryOptions.cpp:191
CQueryOptions * SafeClone()
"safe" clone, used by CQFPrune (wraps new() and assign(*this,false))
Definition: QueryOptions.h:113
virtual string jsonData()
Definition: QueryOptions.cpp:290
Definition: QueryCompiler.h:50
bool m_bEnableBibliography
(CConcIndexator::m_bOutputBibliographyOfHits is default value for outputting bibliography ...
Definition: QueryOptions.h:46
virtual void Clear()
clear options.
Definition: QueryOptions.cpp:170
bool IsPruneFilter() const
returns true iff the primary sort-filter is prune-filter
Definition: QueryOptions.cpp:221
CQSubcorpusList m_Subcorpora
selected subcorpora for this query
Definition: QueryOptions.h:71
virtual bool CheckSatisfiable(CQueryCompiler *compiler)
Run optional fast unsatisfiability checks for query before Compile() is called.
Definition: QueryOptions.cpp:100
CQFilterList m_QFilters
(abstract) filters and sort operators which should be applied to the resulted hit set ...
Definition: QueryOptions.h:65
void swap(CQueryOptions &x)
swap options
Definition: QueryOptions.cpp:34
virtual bool Compile(CQueryCompiler *compiler)
Compile index-dependent filter properties (required for evaluation)
Definition: QueryOptions.cpp:132
vector< CQFilter * > CQFilterList
Definition: QueryOptions.h:29
list< string > CQCommentList
Definition: QueryOptions.h:33
const int UnknownTextAreaNo
Definition: BiblIndex.h:17