#include using namespace boost::python; #include "vlsisapd/dtr/Techno.h" #include "vlsisapd/dtr/Rules.h" #include "vlsisapd/dtr/DTRException.h" namespace DTR { void translator(DTRException const& e) { PyErr_SetString(PyExc_UserWarning, e.what()); } BOOST_PYTHON_MODULE(pyDTR) { // class DTR::Name class_("Name", init()) .def("getString", &Name::getString, return_value_policy()) // return_value_policy because this method return a refenrce on string ; // class DTR::Rule class_("Rule", init()) // accessors .def("getName" , &Rule::getName ) .def("getType" , &Rule::getType ) .def("getValue" , &Rule::getValue ) .def("getRef" , &Rule::getRef ) .def("getLayer1", &Rule::getLayer1) .def("getLayer2", &Rule::getLayer2) // modifiers .def("setType" , &Rule::setType ) ; // class DTR::ARule derived from DTR::Rule class_ >("ARule", init()) ; // class DTR::Techno class_("Techno", init()) .def("readFromFile", &Techno::readFromFile, return_value_policy()) .staticmethod("readFromFile") .def("getName" , &Techno::getName ) .def("getUnit" , &Techno::getUnit ) .def("getValue" , static_cast(&Techno::getValue)) .def("getValue" , static_cast(&Techno::getValue)) .def("getValue" , static_cast(&Techno::getValue)) ; // DTRException translator register_exception_translator(translator) ; } }