00001 #ifndef LUX_API_RESULT_H 00002 #define LUX_API_RESULT_H 00003 00004 #include "lux/lux.h" 00005 #include "lux/document/document.h" 00006 #include <string> 00007 #include <vector> 00008 00009 namespace Lux { 00010 00011 class Paging; 00012 00016 class Result { 00017 public: 00022 Result(Document &doc); 00028 Result(Document &doc, score_t score); 00032 ~Result() {} 00036 std::string get_id(void); 00040 std::string get(std::string field_name); 00044 score_t get_score(void); 00045 00046 private: 00047 Document doc_; 00048 score_t score_; 00049 }; 00050 00051 typedef std::vector<Result> ResultList; 00052 typedef ResultList::iterator RLIterator; 00053 00057 class ResultSet { 00058 public: 00062 ResultSet(void) {} 00069 ResultSet(uint32_t total_num, uint32_t base, uint32_t num); 00074 ResultSet(Paging &paging); 00078 ~ResultSet() {} 00082 void set_total_num(uint32_t total_num); 00086 void set_base(uint32_t base); 00090 void set_num(uint32_t num); 00094 uint32_t get_base(void); 00098 uint32_t get_base(void) const; 00102 uint32_t get_num(void); 00106 uint32_t get_num(void) const; 00110 uint32_t get_total_num(void); 00114 uint32_t get_total_num(void) const; 00118 void add(Result result); 00122 bool has_next(void); 00126 bool has_next(void) const; 00130 const Result get_next(void); 00134 const Result get_next(void) const; 00138 void init_iter(void); 00139 00140 private: 00141 ResultList result_list_; 00142 mutable RLIterator rl_iterator_; 00143 uint32_t total_num_; 00144 uint32_t base_; 00145 uint32_t num_; 00146 }; 00147 00148 } 00149 00150 #endif