Factor out function to decode 2 hex digits
[xapian.git] / xapian-core / include / xapian / registry.h
blob3099d6bbb1630ee608f4db4f4d066a66250a00db
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 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 LatLongMetric;
38 class MatchSpy;
39 class PostingSource;
40 class Weight;
42 /** Registry for user subclasses.
44 * This class provides a way for the remote server to look up user subclasses
45 * when unserialising.
47 class XAPIAN_VISIBILITY_DEFAULT Registry {
48 public:
49 /// Class holding details of the registry.
50 class Internal;
52 private:
53 /// @internal Reference counted internals.
54 Xapian::Internal::intrusive_ptr<Internal> internal;
56 public:
57 /** Copy constructor.
59 * The internals are reference counted, so copying is cheap.
61 * @param other The object to copy.
63 Registry(const Registry & other);
65 /** Assignment operator.
67 * The internals are reference counted, so assignment is cheap.
69 * @param other The object to copy.
71 Registry & operator=(const Registry & other);
73 #ifdef XAPIAN_MOVE_SEMANTICS
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);
85 #endif
87 /** Default constructor.
89 * The registry will contain all standard subclasses of user-subclassable
90 * classes.
92 Registry();
94 ~Registry();
96 /** Register a weighting scheme.
98 * @param wt The weighting scheme to register.
100 void register_weighting_scheme(const Xapian::Weight &wt);
102 /** Get the weighting scheme given a name.
104 * @param name The name of the weighting scheme to find.
105 * @return An object with the requested name, or NULL if the
106 * weighting scheme could not be found. The returned
107 * object is owned by the registry and so must not be
108 * deleted by the caller.
110 const Xapian::Weight *
111 get_weighting_scheme(const std::string & name) const;
113 /** Register a user-defined posting source class.
115 * @param source The posting source to register.
117 void register_posting_source(const Xapian::PostingSource &source);
119 /** Get a posting source given a name.
121 * @param name The name of the posting source to find.
122 * @return An object with the requested name, or NULL if the
123 * posting source could not be found. The returned
124 * object is owned by the registry and so must not be
125 * deleted by the caller.
127 const Xapian::PostingSource *
128 get_posting_source(const std::string & name) const;
130 /** Register a user-defined match spy class.
132 * @param spy The match spy to register.
134 void register_match_spy(const Xapian::MatchSpy &spy);
136 /** Get a match spy given a name.
138 * @param name The name of the match spy to find.
139 * @return An object with the requested name, or NULL if the
140 * match spy could not be found. The returned
141 * object is owned by the registry and so must not be
142 * deleted by the caller.
144 const Xapian::MatchSpy *
145 get_match_spy(const std::string & name) const;
147 /// Register a user-defined lat-long metric class.
148 void register_lat_long_metric(const Xapian::LatLongMetric &metric);
150 /** Get a lat-long metric given a name.
152 * The returned metric is owned by the registry object.
154 * Returns NULL if the metric could not be found.
156 const Xapian::LatLongMetric *
157 get_lat_long_metric(const std::string & name) const;
163 #endif /* XAPIAN_INCLUDED_REGISTRY_H */