LCOV - code coverage report
Current view: top level - include/xapian - registry.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7028d852e609 Lines: 1 1 100.0 %
Date: 2019-02-17 14:59:59 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file registry.h
       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
       6                 :            :  *
       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.
      11                 :            :  *
      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.
      16                 :            :  *
      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
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef XAPIAN_INCLUDED_REGISTRY_H
      24                 :            : #define XAPIAN_INCLUDED_REGISTRY_H
      25                 :            : 
      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
      29                 :            : 
      30                 :            : #include <xapian/intrusive_ptr.h>
      31                 :            : #include <xapian/visibility.h>
      32                 :            : #include <string>
      33                 :            : 
      34                 :            : namespace Xapian {
      35                 :            : 
      36                 :            : // Forward declarations.
      37                 :            : class LatLongMetric;
      38                 :            : class MatchSpy;
      39                 :            : class PostingSource;
      40                 :            : class Weight;
      41                 :            : 
      42                 :            : /** Registry for user subclasses.
      43                 :            :  *
      44                 :            :  *  This class provides a way for the remote server to look up user subclasses
      45                 :            :  *  when unserialising.
      46                 :            :  */
      47                 :          4 : class XAPIAN_VISIBILITY_DEFAULT Registry {
      48                 :            :   public:
      49                 :            :     /// Class holding details of the registry.
      50                 :            :     class Internal;
      51                 :            : 
      52                 :            :   private:
      53                 :            :     /// @internal Reference counted internals.
      54                 :            :     Xapian::Internal::intrusive_ptr_nonnull<Internal> internal;
      55                 :            : 
      56                 :            :   public:
      57                 :            :     /** Copy constructor.
      58                 :            :      *
      59                 :            :      *  The internals are reference counted, so copying is cheap.
      60                 :            :      *
      61                 :            :      *  @param other    The object to copy.
      62                 :            :      */
      63                 :            :     Registry(const Registry & other);
      64                 :            : 
      65                 :            :     /** Assignment operator.
      66                 :            :      *
      67                 :            :      *  The internals are reference counted, so assignment is cheap.
      68                 :            :      *
      69                 :            :      *  @param other    The object to copy.
      70                 :            :      */
      71                 :            :     Registry & operator=(const Registry & other);
      72                 :            : 
      73                 :            :     /** Move constructor.
      74                 :            :      *
      75                 :            :      * @param other     The object to move.
      76                 :            :      */
      77                 :            :     Registry(Registry && other);
      78                 :            : 
      79                 :            :     /** Move assignment operator.
      80                 :            :      *
      81                 :            :      * @param other     The object to move.
      82                 :            :      */
      83                 :            :     Registry & operator=(Registry && other);
      84                 :            : 
      85                 :            :     /** Default constructor.
      86                 :            :      *
      87                 :            :      *  The registry will contain all standard subclasses of user-subclassable
      88                 :            :      *  classes.
      89                 :            :      */
      90                 :            :     Registry();
      91                 :            : 
      92                 :            :     ~Registry();
      93                 :            : 
      94                 :            :     /** Register a weighting scheme.
      95                 :            :      *
      96                 :            :      *  @param wt       The weighting scheme to register.
      97                 :            :      */
      98                 :            :     void register_weighting_scheme(const Xapian::Weight &wt);
      99                 :            : 
     100                 :            :     /** Get the weighting scheme given a name.
     101                 :            :      *
     102                 :            :      *  @param name     The name of the weighting scheme to find.
     103                 :            :      *  @return         An object with the requested name, or NULL if the
     104                 :            :      *                  weighting scheme could not be found.  The returned
     105                 :            :      *                  object is owned by the registry and so must not be
     106                 :            :      *                  deleted by the caller.
     107                 :            :      */
     108                 :            :     const Xapian::Weight *
     109                 :            :             get_weighting_scheme(const std::string & name) const;
     110                 :            : 
     111                 :            :     /** Register a user-defined posting source class.
     112                 :            :      *
     113                 :            :      *  @param source   The posting source to register.
     114                 :            :      */
     115                 :            :     void register_posting_source(const Xapian::PostingSource &source);
     116                 :            : 
     117                 :            :     /** Get a posting source given a name.
     118                 :            :      *
     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.
     124                 :            :      */
     125                 :            :     const Xapian::PostingSource *
     126                 :            :             get_posting_source(const std::string & name) const;
     127                 :            : 
     128                 :            :     /** Register a user-defined match spy class.
     129                 :            :      *
     130                 :            :      *  @param spy      The match spy to register.
     131                 :            :      */
     132                 :            :     void register_match_spy(const Xapian::MatchSpy &spy);
     133                 :            : 
     134                 :            :     /** Get a match spy given a name.
     135                 :            :      *
     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.
     141                 :            :      */
     142                 :            :     const Xapian::MatchSpy *
     143                 :            :             get_match_spy(const std::string & name) const;
     144                 :            : 
     145                 :            :     /// Register a user-defined lat-long metric class.
     146                 :            :     void register_lat_long_metric(const Xapian::LatLongMetric &metric);
     147                 :            : 
     148                 :            :     /** Get a lat-long metric given a name.
     149                 :            :      *
     150                 :            :      *  The returned metric is owned by the registry object.
     151                 :            :      *
     152                 :            :      *  Returns NULL if the metric could not be found.
     153                 :            :      */
     154                 :            :     const Xapian::LatLongMetric *
     155                 :            :             get_lat_long_metric(const std::string & name) const;
     156                 :            : 
     157                 :            : };
     158                 :            : 
     159                 :            : }
     160                 :            : 
     161                 :            : #endif /* XAPIAN_INCLUDED_REGISTRY_H */

Generated by: LCOV version 1.11