matcher/scaleweight.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include "scaleweight.h"
00024 
00025 #include "serialise-double.h"
00026 
00027 ScaleWeight *
00028 ScaleWeight::clone() const {
00029     return new ScaleWeight(real_wt->clone(), factor);
00030 }
00031 
00032 ScaleWeight::~ScaleWeight() { delete real_wt; }
00033 
00034 std::string
00035 ScaleWeight::name() const {
00036     return "Scale";
00037 }
00038 
00039 std::string
00040 ScaleWeight::serialise() const {
00041     return serialise_double(factor) + real_wt->serialise();
00042 }
00043 
00044 ScaleWeight *
00045 ScaleWeight::unserialise(const std::string & s) const
00046 {
00047     const char *start = s.data();
00048     const char *p = start;
00049     const char *p_end = p + s.size();
00050     double factor_ = unserialise_double(&p, p_end);
00051     return new ScaleWeight(real_wt->unserialise(s.substr(p - start)), factor_);
00052 }
00053 
00054 Xapian::weight
00055 ScaleWeight::get_sumpart(Xapian::termcount t, Xapian::doclength l) const
00056 {
00057     return factor * real_wt->get_sumpart(t, l);
00058 }
00059 
00060 Xapian::weight
00061 ScaleWeight::get_maxpart() const {
00062     return factor * real_wt->get_maxpart();
00063 }
00064 
00065 Xapian::weight ScaleWeight::get_sumextra(Xapian::doclength l) const {
00066     return factor * real_wt->get_sumextra(l);
00067 }
00068 
00069 Xapian::weight ScaleWeight::get_maxextra() const {
00070     return factor * real_wt->get_maxextra();
00071 }
00072 
00073 bool ScaleWeight::get_sumpart_needs_doclength() const {
00074     return real_wt->get_sumpart_needs_doclength();
00075 }

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.