35
/*********************
37
* Normal Surface Filter Registry
38
* ------------------------------
41
* THIS FILE SHOULD BE EDITED EACH TIME A NEW FILTERING CLASS
44
* Note that each normal surface filtering class should be a subclass
47
* For each such filtering class there should be a line of the form:
49
* REGISTER_FILTER(id, class, name)
52
* id = the integer ID of the new filtering class.
53
* class = the C++ subclass of NSurfaceFilter being registered.
54
* name = the string (English) name of the corresponding
57
* The appropriate include files should also be placed with full path
58
* and without full path in the appropriate include sections below.
60
* To use the filter registry, simply #include this file. If you
61
* have not defined __FILTER_REGISTRY_BODY, only the include
62
* sections will be brought in. If you have defined
63
* __FILTER_REGISTRY_BODY, the include sections will be skipped
64
* and the REGISTER_FILTER lines will be brought in instead.
65
* By suitably defining the macro REGISTER_FILTER before including
66
* this file, you can have these lines do whatever you wish.
68
* If you do #include this file, be sure to #undef both
69
* REGISTER_FILTER and __FILTER_REGISTRY_BODY when you are
70
* finished, so that if --enable-final is being used then these
71
* macros are left undefined for the following files.
75
* When selecting an integer ID for your new filtering class, the
76
* following guidelines should be adhered to:
78
* 0-999: Reserved for use with the official program distribution.
79
* 1000-9999: Reserved for future use.
83
#ifndef __FILTER_REGISTRY_BODY
84
#include "surfaces/nsurfacefilter.h"
85
#include "surfaces/sfproperties.h"
86
#include "surfaces/sfcombination.h"
88
REGISTER_FILTER(0, NSurfaceFilter, "Default filter")
89
REGISTER_FILTER(1, NSurfaceFilterProperties,
90
"Filter by basic properties")
91
REGISTER_FILTER(2, NSurfaceFilterCombination,
95
35
/*! \file surfaces/filterregistry.h
96
* \brief Contains a registry of normal surface filtering classes known to
97
* the engine. Each such class should be a subclass of NSurfaceFilter.
99
* Each time a new filtering class is created, this filter registry should be
100
* updated. Instructions regarding how to do this are included in
101
* <i>filterregistry.h</i>, which also contains instructions regarding
102
* how to actually use the filter registry.
104
* See NSurfaceFilter for further details.
36
* \brief Provides access to a registry of all normal surface filter classes
37
* that can be used to filter lists of normal surfaces in 3-manifold
40
* Each time a new filter is created, the file filterregistry-impl.h must be
41
* updated to include it. Instructions on how to do this are included in
42
* filterregistry-impl.h.
44
* External routines can access the registry by calling one of the
45
* forFilter() template functions defined in filterregistry.h.
47
* \warning You should not include this header unless it is necessary,
48
* since it will automatically import every header for every filter class
52
// The old registry macros will silently compile but do nothing.
53
// This could lead to nasty surprises, so throw an error if it looks like
54
// people are still trying to use them.
55
#ifdef __FILTER_REGISTRY_BODY
56
#error "The old REGISTER_FILTER macros have been removed. Use forFilter() instead."
59
#ifndef __FILTERREGISTRY_H
61
#define __FILTERREGISTRY_H
64
#include "surfaces/surfacefiltertype.h"
65
#include "utilities/registryutils.h"
75
* Allows the user to call a template function whose template parameter
76
* matches a given value of SurfaceFilterType, which is not known
77
* until runtime. In essence, this routine contains a switch/case statement
78
* that runs through all possible normal surface filter types.
80
* The advantages of this routine are that (i) the user does not need to
81
* repeatedly type such switch/case statements themselves; and (ii) if
82
* a new filter type is added then only a small amount of code
83
* needs to be extended to incorporate it.
85
* In detail: the function object \a func must define a templated
86
* unary bracket operator, so that <tt>func(SurfaceFilterInfo<t>)</tt> is
87
* defined for any valid SurfaceFilterType enum value \a t. Then,
88
* when the user calls <tt>forFilter(filter, func, defaultReturn)</tt>,
89
* this routine will call <tt>func(SurfaceFilterInfo<filter>)</tt> and pass
90
* back the corresponding return value. If \a filter does not denote a valid
91
* filter type, then forFilter() will pass back \a defaultReturn instead.
93
* There is also a two-argument variant of forFilter() that works with
96
* \pre The function object must have a typedef \a ReturnType indicating
97
* the return type of the corresponding templated unary bracket operator.
98
* Inheriting from Returns<...> is a convenient way to ensure this.
100
* \ifacespython Not present.
102
* @param filter the given type of normal surface filter.
103
* @param func the function object whose unary bracket operator we will
104
* call with a SurfaceFilterInfo<filter> object.
105
* @param defaultReturn the value to return if the given filter type
107
* @return the return value from the corresponding unary bracket
108
* operator of \a func, or \a defaultReturn if the given filter type
111
template <typename FunctionObject>
112
typename FunctionObject::ReturnType forFilter(
113
SurfaceFilterType filter, FunctionObject func,
114
typename FunctionObject::ReturnType defaultReturn);
117
* Allows the user to call a template function whose template parameter
118
* matches a given value of SurfaceFilterType, which is not known
119
* until runtime. In essence, this routine contains a switch/case statement
120
* that runs through all possible normal surface filter types.
122
* The advantages of this routine are that (i) the user does not need to
123
* repeatedly type such switch/case statements themselves; and (ii) if
124
* a new filter type is added then only a small amount of code
125
* needs to be extended to incorporate it.
127
* In detail: the function object \a func must define a templated
128
* unary bracket operator, so that <tt>func(SurfaceFilterInfo<t>)</tt> is
129
* defined for any valid SurfaceFilterType enum value \a t. Then,
130
* when the user calls <tt>forFilter(filter, func)</tt>,
131
* this routine will call <tt>func(SurfaceFilterInfo<filter>)</tt> in turn.
132
* If \a filter does not denote a valid filter type, then forFilter()
135
* There is also a three-argument variant of forFilter() that works with
136
* functions with return values.
138
* \ifacespython Not present.
140
* @param filter the given type of normal surface filter.
141
* @param func the function object whose unary bracket operator we will
142
* call with a SurfaceFilterInfo<filter> object.
144
template <typename VoidFunctionObject>
145
void forFilter(SurfaceFilterType filter, VoidFunctionObject func);
149
} // namespace regina
151
// Import template implementations:
152
#include "surfaces/filterregistry-impl.h"