Skip to content
Snippets Groups Projects
Commit 98d9c163 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Add python binding for writing graph.

parent 3ff69b7c
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,7 @@ ADD_LIBRARY(${PYTHON_MODULE}
signal-base-py.cc
entity-py.cc
factory-py.cc
pool-py.cc
signal-caster-py.cc
)
......
......@@ -51,10 +51,13 @@ namespace dynamicgraph {
}
namespace factory {
PyObject* getEntityClassList(PyObject* self, PyObject* args);
extern PyObject* getEntityClassList(PyObject* self, PyObject* args);
}
namespace signalCaster {
PyObject* getSignalTypeList(PyObject* self, PyObject* args);
extern PyObject* getSignalTypeList(PyObject* self, PyObject* args);
}
namespace pool {
extern PyObject* writeGraph (PyObject* self, PyObject* args);
}
PyObject* dgpyError;
......@@ -198,6 +201,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph::python::signalCaster::getSignalTypeList,
METH_VARARGS,
"return the list of signal type names"},
{"writeGraph",
dynamicgraph::python::pool::writeGraph,
METH_VARARGS,
"Write the graph of entities in a filename."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
......
// Copyright 2011, 2012, Florent Lamiraux, LAAS-CNRS.
//
// This file is part of dynamic-graph-python.
// dynamic-graph-python is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// dynamic-graph-python 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 Lesser Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include <Python.h>
#include <dynamic-graph/pool.h>
namespace dynamicgraph {
namespace python {
extern PyObject* dgpyError;
namespace pool {
PyObject* writeGraph (PyObject* /*self*/, PyObject* args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
return NULL;
try {
PoolStorage::getInstance()->writeGraph (filename);
} catch (const std::exception& exc) {
PyErr_SetString(dgpyError, exc.what());
return NULL;
}
return Py_BuildValue ("");
}
} // python
} // dynamicgraph
} // namespace pool
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment