~ubuntu-branches/ubuntu/vivid/regina-normal/vivid

« back to all changes in this revision

Viewing changes to engine/surfaces/filterregistry.h

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2013-11-02 11:44:32 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20131102114432-acgci6b1pb2hjl8q
Tags: 4.95-1
* New upstream release.
* The python module is now installed in a standard location beneath
  /usr/lib/python2.7/dist-packages.
* Switched python packaging from python-support to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
/* end stub */
34
34
 
35
 
/*********************
36
 
 *
37
 
 *  Normal Surface Filter Registry
38
 
 *  ------------------------------
39
 
 *
40
 
 *
41
 
 *    THIS FILE SHOULD BE EDITED EACH TIME A NEW FILTERING CLASS
42
 
 *        IS CREATED!
43
 
 *
44
 
 *    Note that each normal surface filtering class should be a subclass
45
 
 *        of NSurfaceFilter.
46
 
 *
47
 
 *    For each such filtering class there should be a line of the form:
48
 
 *
49
 
 *        REGISTER_FILTER(id, class, name)
50
 
 *
51
 
 *    where:
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
55
 
 *            filtering method.
56
 
 *
57
 
 *    The appropriate include files should also be placed with full path
58
 
 *        and without full path in the appropriate include sections below.
59
 
 *
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.
67
 
 *
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.
72
 
 *
73
 
 *    Filter IDs:
74
 
 *    ----------
75
 
 *    When selecting an integer ID for your new filtering class, the
76
 
 *        following guidelines should be adhered to:
77
 
 *
78
 
 *    0-999:      Reserved for use with the official program distribution.
79
 
 *    1000-9999:  Reserved for future use.
80
 
 *    10000-:     Unreserved.
81
 
 */
82
 
 
83
 
#ifndef __FILTER_REGISTRY_BODY
84
 
    #include "surfaces/nsurfacefilter.h"
85
 
    #include "surfaces/sfproperties.h"
86
 
    #include "surfaces/sfcombination.h"
87
 
#else
88
 
    REGISTER_FILTER(0, NSurfaceFilter, "Default filter")
89
 
    REGISTER_FILTER(1, NSurfaceFilterProperties,
90
 
        "Filter by basic properties")
91
 
    REGISTER_FILTER(2, NSurfaceFilterCombination,
92
 
        "Combination filter")
93
 
#endif
94
 
 
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.
98
 
 *
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.
103
 
 *
104
 
 *  See NSurfaceFilter for further details.
105
 
 */
 
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
 
38
 *  triangulations.
 
39
 *
 
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.
 
43
 *
 
44
 *  External routines can access the registry by calling one of the
 
45
 *  forFilter() template functions defined in filterregistry.h.
 
46
 *
 
47
 *  \warning You should not include this header unless it is necessary,
 
48
 *  since it will automatically import every header for every filter class
 
49
 *  in the registry.
 
50
 */
 
51
 
 
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."
 
57
#endif
 
58
 
 
59
#ifndef __FILTERREGISTRY_H
 
60
#ifndef __DOXYGEN
 
61
#define __FILTERREGISTRY_H
 
62
#endif
 
63
 
 
64
#include "surfaces/surfacefiltertype.h"
 
65
#include "utilities/registryutils.h"
 
66
 
 
67
namespace regina {
 
68
 
 
69
/**
 
70
 * \weakgroup surfaces
 
71
 * @{
 
72
 */
 
73
 
 
74
/**
 
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.
 
79
 *
 
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.
 
84
 *
 
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.
 
92
 *
 
93
 * There is also a two-argument variant of forFilter() that works with
 
94
 * void functions.
 
95
 *
 
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.
 
99
 *
 
100
 * \ifacespython Not present.
 
101
 *
 
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
 
106
 * is not valid.
 
107
 * @return the return value from the corresponding unary bracket
 
108
 * operator of \a func, or \a defaultReturn if the given filter type
 
109
 * is not valid.
 
110
 */
 
111
template <typename FunctionObject>
 
112
typename FunctionObject::ReturnType forFilter(
 
113
        SurfaceFilterType filter, FunctionObject func,
 
114
        typename FunctionObject::ReturnType defaultReturn);
 
115
 
 
116
/**
 
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.
 
121
 *
 
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.
 
126
 *
 
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()
 
133
 * will do nothing.
 
134
 *
 
135
 * There is also a three-argument variant of forFilter() that works with
 
136
 * functions with return values.
 
137
 *
 
138
 * \ifacespython Not present.
 
139
 *
 
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.
 
143
 */
 
144
template <typename VoidFunctionObject>
 
145
void forFilter(SurfaceFilterType filter, VoidFunctionObject func);
 
146
 
 
147
/*@}*/
 
148
 
 
149
} // namespace regina
 
150
 
 
151
// Import template implementations:
 
152
#include "surfaces/filterregistry-impl.h"
 
153
 
 
154
#endif
106
155