1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/**************************************************************************
* *
* Regina - A Normal Surface Theory Calculator *
* Python Interface *
* *
* Copyright (c) 1999-2008, Ben Burton *
* For further details contact Ben Burton (bab@debian.org). *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public *
* License along with this program; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
**************************************************************************/
/* end stub */
#include <boost/python.hpp>
#include "engine.h"
#include "shareableobject.h"
#include "regina-config.h"
void addGlobalArray();
void addAlgebra();
void addAngle();
void addCensus();
void addFile();
void addForeign();
void addManifold();
void addMaths();
void addPacket();
void addProgress();
void addSnapPea();
void addSplit();
void addSubcomplex();
void addSurfaces();
void addTriangulation();
void addUtilities();
using boost::python::self;
using regina::ShareableObject;
namespace {
std::string welcome() {
return std::string(PACKAGE_STRING) +
"\nA Normal Surface Theory Calculator" +
"\nCopyright (c) 1999-2008, Ben Burton";
}
void shareableWriteTextShort(const ShareableObject& obj) {
obj.writeTextShort(std::cout);
}
void shareableWriteTextLong(const ShareableObject& obj) {
obj.writeTextLong(std::cout);
}
}
/**
* Make == work like pointer equality for ShareableObject.
*/
namespace regina {
static inline bool operator == (const ShareableObject& a,
const ShareableObject& b) {
return &a == &b;
}
static inline bool operator != (const ShareableObject& a,
const ShareableObject& b) {
return &a != &b;
}
}
BOOST_PYTHON_MODULE(regina) {
// Welcome string:
boost::python::def("welcome", welcome);
// Wrappers for global array classes:
addGlobalArray();
// Core engine routines:
boost::python::def("getVersionString", regina::getVersionString);
boost::python::def("getVersionMajor", regina::getVersionMajor);
boost::python::def("getVersionMinor", regina::getVersionMinor);
boost::python::def("versionUsesUTF8", regina::versionUsesUTF8);
boost::python::def("testEngine", regina::testEngine);
// ShareableObject class:
boost::python::class_<ShareableObject, boost::noncopyable>
("ShareableObject", boost::python::no_init)
.def("writeTextShort", &shareableWriteTextShort)
.def("writeTextLong", &shareableWriteTextLong)
.def("toString", &ShareableObject::toString)
.def("toStringLong", &ShareableObject::toStringLong)
.def("__str__", &ShareableObject::toString)
.def(self == self)
.def(self != self)
;
// Components from subdirectories (in approximate dependency order):
addUtilities();
addProgress();
addMaths();
addAlgebra();
addPacket();
addTriangulation();
addCensus();
addFile();
addForeign();
addSplit();
addSnapPea();
addSubcomplex();
addManifold();
addAngle();
addSurfaces();
}
|