[ci] Fix clang-santisers job for GHA change
[xapian.git] / xapian-core / include / xapian / registry.h
blob9503eb7ff55b030ca2105f445316994cf20914e4
1 /** @file
2 * @brief Class for looking up user subclasses during unserialisation.
3 */
4 /* Copyright 2009 Lemur Consulting Ltd
5 * Copyright 2009,2011,2013,2014,2019,2024 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
23 #ifndef XAPIAN_INCLUDED_REGISTRY_H
24 #define XAPIAN_INCLUDED_REGISTRY_H
26 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
27 # error Never use <xapian/registry.h> directly; include <xapian.h> instead.
28 #endif
30 #include <xapian/intrusive_ptr.h>
31 #include <xapian/visibility.h>
32 #include <string>
34 namespace Xapian {
36 // Forward declarations.
37 class KeyMaker;
38 class LatLongMetric;
39 class MatchSpy;
40 class PostingSource;
41 class Weight;
43 /** Registry for user subclasses.
45 * This class provides a way for the remote server to look up user subclasses
46 * when unserialising.
48 class XAPIAN_VISIBILITY_DEFAULT Registry {
49 public:
50 /// Class holding details of the registry.
51 class Internal;
53 private:
54 /// @internal Reference counted internals.
55 Xapian::Internal::intrusive_ptr_nonnull<Internal> internal;
57 public:
58 /** Copy constructor.
60 * The internals are reference counted, so copying is cheap.
62 * @param other The object to copy.
64 Registry(const Registry & other);
66 /** Assignment operator.
68 * The internals are reference counted, so assignment is cheap.
70 * @param other The object to copy.
72 Registry & operator=(const Registry & other);
74 /** Move constructor.
76 * @param other The object to move.
78 Registry(Registry && other);
80 /** Move assignment operator.
82 * @param other The object to move.
84 Registry & operator=(Registry && other);
86 /** Default constructor.
88 * The registry will contain all standard subclasses of user-subclassable
89 * classes.
91 Registry();
93 ~Registry();
95 /** Register a weighting scheme.
97 * @param wt The weighting scheme to register.
99 void register_weighting_scheme(const Xapian::Weight &wt);
101 /** Get the weighting scheme given a name.
103 * @param name The name of the weighting scheme to find.
104 * @return An object with the requested name, or NULL if the
105 * weighting scheme could not be found. The returned
106 * object is owned by the registry and so must not be
107 * deleted by the caller.
109 const Xapian::Weight* get_weighting_scheme(std::string_view name) const;
111 /** Register a user-defined posting source class.
113 * @param source The posting source to register.
115 void register_posting_source(const Xapian::PostingSource &source);
117 /** Get a posting source given a name.
119 * @param name The name of the posting source to find.
120 * @return An object with the requested name, or NULL if the
121 * posting source could not be found. The returned
122 * object is owned by the registry and so must not be
123 * deleted by the caller.
125 const Xapian::PostingSource*
126 get_posting_source(std::string_view name) const;
128 /** Register a user-defined match spy class.
130 * @param spy The match spy to register.
132 void register_match_spy(const Xapian::MatchSpy &spy);
134 /** Get a match spy given a name.
136 * @param name The name of the match spy to find.
137 * @return An object with the requested name, or NULL if the
138 * match spy could not be found. The returned
139 * object is owned by the registry and so must not be
140 * deleted by the caller.
142 const Xapian::MatchSpy* get_match_spy(std::string_view name) const;
144 /// Register a user-defined lat-long metric class.
145 void register_lat_long_metric(const Xapian::LatLongMetric &metric);
147 /** Get a lat-long metric given a name.
149 * The returned metric is owned by the registry object.
151 * Returns NULL if the metric could not be found.
153 const Xapian::LatLongMetric*
154 get_lat_long_metric(std::string_view name) const;
156 /** Register a user-defined KeyMaker subclass.
158 * @param keymaker The KeyMaker subclass to register. The clean up of
159 * this object is handled via Xapian's optional reference
160 * counting. The simplest way to do so is to allocate it
161 * with <code>new</code> and call <code>release()</code>
162 * on it before passing it to this method to tell Xapian
163 * to manage its lifetime. The alternative approach is
164 * for the caller to ensure the KeyMaker object remains
165 * valid for the lifetime of the Registry object.
167 void register_key_maker(Xapian::KeyMaker* keymaker);
169 /** Get a KeyMaker given a name.
171 * @param name The name of the KeyMaker to find.
172 * @return An object with the requested name, or NULL if the
173 * KeyMaker could not be found. The returned
174 * object must <b>not</b> be deleted by the caller.
176 const Xapian::KeyMaker* get_key_maker(std::string_view name) const;
181 #endif /* XAPIAN_INCLUDED_REGISTRY_H */