dynamic-graph-py.cc 1.13 KB
Newer Older
florent's avatar
florent committed
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
/*
 *  Copyright 2010 (C) CNRS
 *  Author: Florent Lamiraux
 */

#include <Python.h>
#include <iostream>
#include <string>

static PyObject*
loadPlugin(PyObject* self, PyObject* args)
{
  char* plugin = NULL;
  char* path = NULL;

  if (!PyArg_ParseTuple(args,"ss", &plugin, &path))
    return NULL;

  std::cout << "loadPlugin " << std::string(plugin) << " "
	    << std::string(path) << std::endl;
  return Py_BuildValue("");
}

static PyObject*
plug(PyObject* self, PyObject* args)
{
  char* out = NULL;
  char* in = NULL;
  if (!PyArg_ParseTuple(args,"ss", &out, &in))
    return NULL;

  std::cout << "plug " << std::string(out) << " "
	    << std::string(in) << std::endl;
  return Py_BuildValue("");
}

/**
   \brief List of python functions
*/
static PyMethodDef sotTutorialMethods[] = {
  {"loadPlugin",  loadPlugin, METH_VARARGS,
     "load a plugin into the dynamic-graph"},
  {"plug",  plug, METH_VARARGS,
     "plug an output signal into an input signal"},
  {NULL, NULL, 0, NULL}        /* Sentinel */
};

PyMODINIT_FUNC
initwrap(void)
{
    PyObject *m;

    m = Py_InitModule("wrap", sotTutorialMethods);
    if (m == NULL)
        return;
}