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

« back to all changes in this revision

Viewing changes to engine/packet/packetregistry-impl.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:
 
1
 
 
2
/**************************************************************************
 
3
 *                                                                        *
 
4
 *  Regina - A Normal Surface Theory Calculator                           *
 
5
 *  Computational Engine                                                  *
 
6
 *                                                                        *
 
7
 *  Copyright (c) 1999-2013, Ben Burton                                   *
 
8
 *  For further details contact Ben Burton (bab@debian.org).              *
 
9
 *                                                                        *
 
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.                       *
 
14
 *                                                                        *
 
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.               *
 
20
 *                                                                        *
 
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.                              *
 
25
 *                                                                        *
 
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.                                                   *
 
30
 *                                                                        *
 
31
 **************************************************************************/
 
32
 
 
33
/* end stub */
 
34
 
 
35
/*! \file packet/packetregistry-impl.h
 
36
 *  \brief Contains the registry of all packet types known to Regina.
 
37
 *
 
38
 * Each time a new packet type is created, this registry must be updated to:
 
39
 *
 
40
 * - add a #include line for the corresponding packet class;
 
41
 * - add a corresponding case to each implementation of forPacket().
 
42
 *
 
43
 * See packetregistry.h for how other routines can use this registry.
 
44
 */
 
45
 
 
46
#ifndef __PACKETREGISTRY_IMPL_H
 
47
#ifndef __DOXYGEN
 
48
#define __PACKETREGISTRY_IMPL_H
 
49
#endif
 
50
 
 
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"
 
60
 
 
61
namespace regina {
 
62
 
 
63
template <typename FunctionObject>
 
64
inline typename FunctionObject::ReturnType forPacket(
 
65
        PacketType packetType, FunctionObject func,
 
66
        typename FunctionObject::ReturnType defaultReturn) {
 
67
    switch (packetType) {
 
68
        case PACKET_CONTAINER :
 
69
            return func(PacketInfo<PACKET_CONTAINER>());
 
70
        case PACKET_TEXT :
 
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>());
 
76
        case PACKET_SCRIPT :
 
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>());
 
82
        case PACKET_PDF :
 
83
            return func(PacketInfo<PACKET_PDF>());
 
84
        case PACKET_DIM2TRIANGULATION :
 
85
            return func(PacketInfo<PACKET_DIM2TRIANGULATION>());
 
86
        default: return defaultReturn;
 
87
    }
 
88
}
 
89
 
 
90
template <typename VoidFunctionObject>
 
91
inline void forPacket(PacketType packetType, VoidFunctionObject func) {
 
92
    switch (packetType) {
 
93
        case PACKET_CONTAINER :
 
94
            func(PacketInfo<PACKET_CONTAINER>()); break;
 
95
        case PACKET_TEXT :
 
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;
 
101
        case PACKET_SCRIPT :
 
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;
 
107
        case PACKET_PDF :
 
108
            func(PacketInfo<PACKET_PDF>()); break;
 
109
        case PACKET_DIM2TRIANGULATION :
 
110
            func(PacketInfo<PACKET_DIM2TRIANGULATION>()); break;
 
111
        default: break;
 
112
    }
 
113
}
 
114
 
 
115
} // namespace regina
 
116
 
 
117
#endif
 
118