bool sorter(const ri_ptr & lhs, const ri_ptr & rhs) { // if equal scores, prefer item with higher preference // usually this indicates network reliability or user-configured preference if( lhs->score() == rhs->score() ) { return lhs->preference() > rhs->preference(); } return lhs->score() > rhs->score(); }
// add a single result void add_result( ri_ptr rip ) { if (!m_cancelled) { boost::mutex::scoped_lock lock(m_mut); if (rip->score() == 1.0) { m_solved = true; } m_results.push_back(rip); // fire callbacks: BOOST_FOREACH(rq_callback_t & cb, m_callbacks) { cb(id(), rip); }
void add_result(ri_ptr rip) { //cout << "RQ.add_result: "<< pip->score() <<"\t" // << pip->artist() << " - " << pip->track() << endl; { boost::mutex::scoped_lock lock(m_mut); m_results.push_back(rip); } // decide if this result "solves" the query: // for now just assume score of 1 means solved. if(rip->score() == 1.0) { // cout << "SOLVED " << id() << endl; m_solved = true; } // fire callbacks: BOOST_FOREACH(rq_callback_t & cb, m_callbacks) { cb(id(), rip); }