HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxRequestInfo.hpp
Go to the documentation of this file.
1 
14 #ifndef SPHINX_REQUEST_INFO_HPP
15 #define SPHINX_REQUEST_INFO_HPP
16 
17 #include <vector>
18 
19 #include "SphinxResultDataItem.hpp"
20 
21 namespace HCE
22 {
23 namespace sphinx
24 {
25 //-----------------------------------------------------------------------------
26 struct WordInfo
27 {
28  WordInfo(void) : word(""), hits(0), docs(0) {}
29  WordInfo(const std::string& word_, unsigned int hits_, unsigned int docs_) : word(word_), hits(hits_), docs(docs_) {}
30  WordInfo(const WordInfo& rhs);
31  WordInfo(WordInfo&& rhs);
32 
33  WordInfo& operator=(const WordInfo& rhs);
34  WordInfo& operator=(WordInfo&& rhs);
35 
36  std::string word;
37  unsigned int hits;
38  unsigned int docs;
39 };
40 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 {
44 public:
45  SphinxRequestInfo(void);
46  explicit SphinxRequestInfo(size_t wordsCount);
50 
53 
54  void setNodeName(const std::string& nodeName_) {nodeName=nodeName_;}
55  std::string getNodeName(void) const {return nodeName;}
56 
57  void setQuery(const std::string& query_) {query=query_;}
58  std::string getQuery(void) const {return query;}
59 
60  void setQueryId(unsigned int queryId_) {queryId=queryId_;}
61  unsigned int getQueryId(void) const {return queryId;}
62 
63  void setMaxResultsNumber(unsigned int maxResultsNumber_) {maxResultsNumber=maxResultsNumber_;}
64  unsigned int getMaxResultsNumber(void) const {return maxResultsNumber;}
65 
66  void setOrderBy(unsigned int orderBy_) {orderBy=orderBy_;}
67  unsigned int getOrderBy(void) const {return orderBy;}
68 
69  void setTotal(unsigned int total_) {total=total_;}
70  unsigned int getTotal(void) const {return total;}
71 
72  void setTotalFound(unsigned int totalFound_) {totalFound=totalFound_;}
73  unsigned int getTotalFound(void) const {return totalFound;}
74 
75  void setTimeMsec(unsigned int timeMsec_) {timeMsec=timeMsec_;}
76  unsigned int getTimeMsec(void) const {return timeMsec;}
77 
78  void addWordInfo(const WordInfo& wordInfo);
79  void addWordInfo(WordInfo&& wordInfo);
80  void addWordInfo(const std::string& word, unsigned int hits, unsigned int docs);
81 
82  const std::vector<SphinxResultDataItem<WordInfo> >& getWords(void) const {return words;}
83 
84  size_t getWordsCount(void) const;
85  const WordInfo& getWordItem(size_t index) const;
86  void setWordItem(size_t index, const WordInfo& word);
87  void setWordItem(size_t index, WordInfo&& word);
88 
89  void clear(void);
90  void reset(void);
91  void resize(size_t sz);
92 private:
93  std::string nodeName; // node name for about words information
94  std::string query; // query line
95  unsigned int queryId; // hash or crc received outside and it must come back
96  unsigned int maxResultsNumber; // use for size elements of docs need for allocate, also result document count resend to reduce
97  unsigned int orderBy; // order by document resend to reduce
98  unsigned int total;
99  unsigned int totalFound;
100  unsigned int timeMsec; // time of request (in msec.)
101 
102  std::vector<SphinxResultDataItem<WordInfo> > words;
103 };
104 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
106 } // namespace sphinx
107 } // namespace HCE
108 
109 #endif // SPHINX_REQUEST_INFO_HPP