signal-caster-py.cc 930 Bytes
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
1
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
2
3
4
5
6
7
8

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

#include <dynamic-graph/signal-caster.h>

9
#include "dynamic-graph/python/dynamic-graph-py.hh"
Guilhem Saurel's avatar
Guilhem Saurel committed
10

11
namespace dynamicgraph {
Guilhem Saurel's avatar
format    
Guilhem Saurel committed
12
namespace python {
13

Guilhem Saurel's avatar
format    
Guilhem Saurel committed
14
15
16
17
18
19
20
namespace signalCaster {
PyObject* getSignalTypeList(PyObject* /*self*/, PyObject* args) {
  if (!PyArg_ParseTuple(args, "")) return NULL;
  std::vector<std::string> typeList = dynamicgraph::SignalCaster::getInstance()->listTypenames();
  Py_ssize_t typeNumber = typeList.size();
  // Build a tuple object
  PyObject* typeTuple = PyTuple_New(typeNumber);
21

Guilhem Saurel's avatar
format    
Guilhem Saurel committed
22
23
24
25
  for (Py_ssize_t iType = 0; iType < typeNumber; ++iType) {
    PyObject* className = Py_BuildValue("s", typeList[iType].c_str());
    PyTuple_SetItem(typeTuple, iType, className);
  }
26

Guilhem Saurel's avatar
format    
Guilhem Saurel committed
27
28
29
30
31
  return Py_BuildValue("O", typeTuple);
}
}  // namespace signalCaster
}  // namespace python
}  // namespace dynamicgraph