NCBI C++ ToolKit
query_data_source.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___QUERY_DATA_SOURCE__HPP
2 #define GUI_OBJUTILS___QUERY_DATA_SOURCE__HPP
3 
4 /* $Id: query_data_source.hpp 36811 2016-11-02 13:41:29Z falkrb $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Robert Falk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistr.hpp>
36 #include <objmgr/scope.hpp>
37 #include <gui/gui_export.h>
39 
41 
42 class CMacroQueryExec;
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// class IQueryDataSource
46 ///
47 /// This is an abstract interface for any datasource that wants to support
48 /// queries using CQueryParseTree and CQueryExec. This interface supports
49 /// searching the data source for a spcified string (when parsing is not being
50 /// used) and supports the creation of a query execution object that is
51 /// tailored for that data source. This interface also allows the user
52 /// to set and clear a set of selected results for the data source.
53 ///
55 public:
56  typedef vector<pair<string,string> > TNamedQueries;
57 
58  /// dtor
59  virtual ~IQueryDataSource() {}
60 
61  /// get number and names of columns in data source
62  virtual string GetColumnLabel(size_t col) const = 0;
63  virtual size_t GetColsCount() const = 0;
64 
65  /// Execute a string-matching query on the underlying data
66  /// @param[in] query
67  /// Reference to a pattern to search for.
68  /// @param[out] num_selected
69  /// Number of matching rows.
70  /// @param[out] num_queried
71  /// Total rows queried.
72  /// @param[in] string_matching
73  /// String matching algorithm to use.
74  /// @param[in] use_case
75  /// Whether to do a case sensitive compare (default), or not.
76  virtual void ExecuteStringQuery(const string &query, size_t& num_selected, size_t& num_queried, CStringMatching::EStringMatching string_matching = CStringMatching::ePlainSearch, NStr::ECase use_case = NStr::eCase) = 0;
77 
78  /// Return a scope for the data source, if available.
80 
81  /// Create an appropriate instance of a subclass of CQueryExec for that
82  /// will be used to execute a query on the data source.
83  virtual CMacroQueryExec* GetQueryExec(bool casesensitive, CStringMatching::EStringMatching matching) = 0;
84 
85  /// Clear any current results from previous queries
86  virtual void ClearQueryResults() = 0;
87  /// Set selection results to be whatever elements are selected in 'q'.
88  virtual void SetQueryResults(CMacroQueryExec* q) = 0;
89 };
90 
92 
93 #endif // GUI_OBJUTILS___QUERY_DATA_SOURCE__HPP
class CMacroQueryExec
EStringMatching
String matching algorithms.
@ ePlainSearch
Plain search.
class IQueryDataSource
virtual ~IQueryDataSource()
dtor
virtual CRef< objects::CScope > GetScope()
Return a scope for the data source, if available.
virtual void ClearQueryResults()=0
Clear any current results from previous queries.
vector< pair< string, string > > TNamedQueries
virtual string GetColumnLabel(size_t col) const =0
get number and names of columns in data source
virtual size_t GetColsCount() const =0
virtual void ExecuteStringQuery(const string &query, size_t &num_selected, size_t &num_queried, CStringMatching::EStringMatching string_matching=CStringMatching::ePlainSearch, NStr::ECase use_case=NStr::eCase)=0
Execute a string-matching query on the underlying data.
virtual void SetQueryResults(CMacroQueryExec *q)=0
Set selection results to be whatever elements are selected in 'q'.
virtual CMacroQueryExec * GetQueryExec(bool casesensitive, CStringMatching::EStringMatching matching)=0
Create an appropriate instance of a subclass of CQueryExec for that will be used to execute a query o...
The NCBI C++ standard methods for dealing with std::string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
ECase
Which type of string comparison.
Definition: ncbistr.hpp:1204
@ eCase
Case sensitive compare.
Definition: ncbistr.hpp:1205
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
static string query
Modified on Sun Apr 14 05:29:08 2024 by modify_doxy.py rev. 669887