2
/**************************************************************************
4
* Regina - A Normal Surface Theory Calculator *
5
* Computational Engine *
7
* Copyright (c) 1999-2013, Ben Burton *
8
* For further details contact Ben Burton (bab@debian.org). *
10
* This program is free software; you can redistribute it and/or *
11
* modify it under the terms of the GNU General Public License as *
12
* published by the Free Software Foundation; either version 2 of the *
13
* License, or (at your option) any later version. *
15
* As an exception, when this program is distributed through (i) the *
16
* App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or *
17
* (iii) Google Play by Google Inc., then that store may impose any *
18
* digital rights management, device limits and/or redistribution *
19
* restrictions that are required by its terms of service. *
21
* This program is distributed in the hope that it will be useful, but *
22
* WITHOUT ANY WARRANTY; without even the implied warranty of *
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
24
* General Public License for more details. *
26
* You should have received a copy of the GNU General Public *
27
* License along with this program; if not, write to the Free *
28
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
29
* MA 02110-1301, USA. *
31
**************************************************************************/
35
/*! \file packet/packetregistry-impl.h
36
* \brief Contains the registry of all packet types known to Regina.
38
* Each time a new packet type is created, this registry must be updated to:
40
* - add a #include line for the corresponding packet class;
41
* - add a corresponding case to each implementation of forPacket().
43
* See packetregistry.h for how other routines can use this registry.
46
#ifndef __PACKETREGISTRY_IMPL_H
48
#define __PACKETREGISTRY_IMPL_H
51
#include "packet/ncontainer.h"
52
#include "packet/ntext.h"
53
#include "triangulation/ntriangulation.h"
54
#include "surfaces/nnormalsurfacelist.h"
55
#include "packet/nscript.h"
56
#include "surfaces/nsurfacefilter.h"
57
#include "angle/nanglestructurelist.h"
58
#include "packet/npdf.h"
59
#include "dim2/dim2triangulation.h"
63
template <typename FunctionObject>
64
inline typename FunctionObject::ReturnType forPacket(
65
PacketType packetType, FunctionObject func,
66
typename FunctionObject::ReturnType defaultReturn) {
68
case PACKET_CONTAINER :
69
return func(PacketInfo<PACKET_CONTAINER>());
71
return func(PacketInfo<PACKET_TEXT>());
72
case PACKET_TRIANGULATION :
73
return func(PacketInfo<PACKET_TRIANGULATION>());
74
case PACKET_NORMALSURFACELIST :
75
return func(PacketInfo<PACKET_NORMALSURFACELIST>());
77
return func(PacketInfo<PACKET_SCRIPT>());
78
case PACKET_SURFACEFILTER :
79
return func(PacketInfo<PACKET_SURFACEFILTER>());
80
case PACKET_ANGLESTRUCTURELIST :
81
return func(PacketInfo<PACKET_ANGLESTRUCTURELIST>());
83
return func(PacketInfo<PACKET_PDF>());
84
case PACKET_DIM2TRIANGULATION :
85
return func(PacketInfo<PACKET_DIM2TRIANGULATION>());
86
default: return defaultReturn;
90
template <typename VoidFunctionObject>
91
inline void forPacket(PacketType packetType, VoidFunctionObject func) {
93
case PACKET_CONTAINER :
94
func(PacketInfo<PACKET_CONTAINER>()); break;
96
func(PacketInfo<PACKET_TEXT>()); break;
97
case PACKET_TRIANGULATION :
98
func(PacketInfo<PACKET_TRIANGULATION>()); break;
99
case PACKET_NORMALSURFACELIST :
100
func(PacketInfo<PACKET_NORMALSURFACELIST>()); break;
102
func(PacketInfo<PACKET_SCRIPT>()); break;
103
case PACKET_SURFACEFILTER :
104
func(PacketInfo<PACKET_SURFACEFILTER>()); break;
105
case PACKET_ANGLESTRUCTURELIST :
106
func(PacketInfo<PACKET_ANGLESTRUCTURELIST>()); break;
108
func(PacketInfo<PACKET_PDF>()); break;
109
case PACKET_DIM2TRIANGULATION :
110
func(PacketInfo<PACKET_DIM2TRIANGULATION>()); break;
115
} // namespace regina