60 void clear_weighting_schemes();
63 void clear_posting_sources();
66 void clear_match_spies();
69 void clear_lat_long_metrics();
80 string name = obj.name();
81 if (
rare(name.empty())) {
85 pair<typename map<string, T *>::iterator,
bool> r;
86 r = registry.insert(make_pair(name, static_cast<T*>(NULL)));
97 swap(p, r.first->second);
101 T * clone = obj.clone();
106 r.first->second = clone;
110 static inline const T *
113 typename map<string, T*>::const_iterator i = registry.find(name);
114 if (i == registry.end()) {
122 Registry::Internal::Internal()
127 Registry::Internal::~Internal()
129 clear_weighting_schemes();
130 clear_posting_sources();
132 clear_lat_long_metrics();
136 Registry::Internal::add_defaults()
140 wtschemes[weighting_scheme->
name()] = weighting_scheme;
142 wtschemes[weighting_scheme->
name()] = weighting_scheme;
144 wtschemes[weighting_scheme->
name()] = weighting_scheme;
146 wtschemes[weighting_scheme->
name()] = weighting_scheme;
148 wtschemes[weighting_scheme->
name()] = weighting_scheme;
150 wtschemes[weighting_scheme->
name()] = weighting_scheme;
152 wtschemes[weighting_scheme->
name()] = weighting_scheme;
154 wtschemes[weighting_scheme->
name()] = weighting_scheme;
156 wtschemes[weighting_scheme->
name()] = weighting_scheme;
158 wtschemes[weighting_scheme->
name()] = weighting_scheme;
160 wtschemes[weighting_scheme->
name()] = weighting_scheme;
162 wtschemes[weighting_scheme->
name()] = weighting_scheme;
164 wtschemes[weighting_scheme->
name()] = weighting_scheme;
166 wtschemes[weighting_scheme->
name()] = weighting_scheme;
168 wtschemes[weighting_scheme->
name()] = weighting_scheme;
172 postingsources[source->
name()] = source;
174 postingsources[source->
name()] = source;
176 postingsources[source->
name()] = source;
178 postingsources[source->
name()] = source;
182 postingsources[source->
name()] = source;
186 matchspies[spy->
name()] = spy;
190 lat_long_metrics[metric->
name()] = metric;
194 Registry::Internal::clear_weighting_schemes()
196 map<string, Xapian::Weight*>::const_iterator i;
197 for (i = wtschemes.begin(); i != wtschemes.end(); ++i) {
203 Registry::Internal::clear_posting_sources()
205 map<string, Xapian::PostingSource *>::const_iterator i;
206 for (i = postingsources.begin(); i != postingsources.end(); ++i) {
212 Registry::Internal::clear_match_spies()
214 map<string, Xapian::MatchSpy *>::const_iterator i;
215 for (i = matchspies.begin(); i != matchspies.end(); ++i) {
221 Registry::Internal::clear_lat_long_metrics()
223 map<string, Xapian::LatLongMetric *>::const_iterator i;
224 for (i = lat_long_metrics.begin(); i != lat_long_metrics.end(); ++i) {
230 : internal(other.internal)
267 LOGCALL_VOID(API,
"Xapian::Registry::register_weighting_scheme", wt.
name());
281 LOGCALL_VOID(API,
"Xapian::Registry::register_posting_source", source.
name());
309 LOGCALL_VOID(API,
"Xapian::Registry::register_lat_long_metric", metric.
name());
The Xapian namespace contains public interfaces for the Xapian library.
void register_weighting_scheme(const Xapian::Weight &wt)
Register a weighting scheme.
virtual std::string name() const
Return the name of this weighting scheme.
InvalidOperationError indicates the API was used in an invalid way.
Abstract base class for match spies.
A posting source which looks up weights in a map using values as the key.
#define LOGCALL_DTOR(CATEGORY, CLASS)
External sources of posting information.
static const T * lookup_object(map< string, T *> registry, const string &name)
This class implements the InL2 weighting scheme.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
const Xapian::PostingSource * get_posting_source(const std::string &name) const
Get a posting source given a name.
std::map< std::string, Xapian::LatLongMetric * > lat_long_metrics
Registered lat-long metrics.
std::map< std::string, Xapian::MatchSpy * > matchspies
Registered match spies.
static void register_object(map< string, T *> ®istry, const T &obj)
Xapian::Weight subclass implementing the PL2+ probabilistic formula.
Read weights from a value which is known to decrease as docid increases.
Hierarchy of classes which Xapian can throw as exceptions.
This class implements the BB2 weighting scheme.
Xapian::Weight subclass implementing Coordinate Matching.
const Xapian::MatchSpy * get_match_spy(const std::string &name) const
Get a match spy given a name.
Posting source which returns a weight based on geospatial distance.
Class implementing a "boolean" weighting scheme.
Geospatial search support routines.
void register_match_spy(const Xapian::MatchSpy &spy)
Register a user-defined match spy class.
Registry for user subclasses.
A posting source which returns a fixed weight for all documents.
const Xapian::Weight * get_weighting_scheme(const std::string &name) const
Get the weighting scheme given a name.
Base class for calculating distances between two lat/long coordinates.
Registry()
Default constructor.
Xapian::Weight subclass implementing the traditional probabilistic formula.
This class implements the DLH weighting scheme, which is a representative scheme of the Divergence fr...
This class implements the PL2 weighting scheme.
A sequence of latitude-longitude coordinates.
This class implements the IneB2 weighting scheme.
Base class which provides an "external" source of postings.
Registry & operator=(const Registry &other)
Assignment operator.
Base class for objects managed by intrusive_ptr.
#define LOGCALL_CTOR(CATEGORY, CLASS, PARAMS)
Class for counting the frequencies of values in the matching documents.
This class implements the IfB2 weighting scheme.
A posting source which reads weights from a value slot.
void register_posting_source(const Xapian::PostingSource &source)
Register a user-defined posting source class.
This class implements the DPH weighting scheme.
virtual std::string name() const =0
Return the full name of the metric.
void register_lat_long_metric(const Xapian::LatLongMetric &metric)
Register a user-defined lat-long metric class.
std::map< std::string, Xapian::PostingSource * > postingsources
Registered external posting sources.
std::map< std::string, Xapian::Weight * > wtschemes
Registered weighting schemes.
Calculate the great-circle distance between two coordinates on a sphere.
Xapian::Weight subclass implementing the Language Model formula.
Xapian::Internal::intrusive_ptr< Internal > internal
virtual std::string name() const
Name of the posting source class.
Xapian::Weight subclass implementing the BM25+ probabilistic formula.
Xapian::Weight subclass implementing the BM25 probabilistic formula.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Class for looking up user subclasses during unserialisation.
Xapian::Weight subclass implementing the tf-idf weighting scheme.
Abstract base class for weighting schemes.
const Xapian::LatLongMetric * get_lat_long_metric(const std::string &name) const
Get a lat-long metric given a name.
virtual std::string name() const
Return the name of this match spy.