1 |
|
|
#ifndef DYNAMIC_GRAPH_PY |
2 |
|
|
#define DYNAMIC_GRAPH_PY |
3 |
|
|
|
4 |
|
|
#include <dynamic-graph/debug.h> |
5 |
|
|
#include <dynamic-graph/exception-factory.h> |
6 |
|
|
#include <dynamic-graph/signal-base.h> |
7 |
|
|
|
8 |
|
|
#include <boost/python.hpp> |
9 |
|
|
#include <boost/python/stl_iterator.hpp> |
10 |
|
|
#include <iostream> |
11 |
|
|
#include <sstream> |
12 |
|
|
|
13 |
|
|
#include "dynamic-graph/python/signal-wrapper.hh" |
14 |
|
|
|
15 |
|
|
namespace bp = boost::python; |
16 |
|
|
|
17 |
|
|
namespace dynamicgraph { |
18 |
|
|
namespace python { |
19 |
|
|
|
20 |
|
|
template <typename Iterator> |
21 |
|
|
inline bp::list to_py_list(Iterator begin, Iterator end) { |
22 |
|
|
typedef typename Iterator::value_type T; |
23 |
|
|
bp::list lst; |
24 |
|
|
std::for_each(begin, end, [&](const T& t) { lst.append(t); }); |
25 |
|
|
return lst; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
template <typename Iterator> |
29 |
|
|
inline bp::tuple to_py_tuple(Iterator begin, Iterator end) { |
30 |
|
|
return bp::tuple(to_py_list(begin, end)); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
template <typename T> |
34 |
|
|
inline std::vector<T> to_std_vector(const bp::object& iterable) { |
35 |
|
|
return std::vector<T>(bp::stl_input_iterator<T>(iterable), |
36 |
|
|
bp::stl_input_iterator<T>()); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
void exposeSignals(); |
40 |
|
|
|
41 |
|
|
// Declare functions defined in other source files |
42 |
|
|
namespace signalBase { |
43 |
|
|
SignalBase<int>* createSignalWrapper(const char* name, const char* type, |
44 |
|
|
bp::object object); |
45 |
|
|
} // namespace signalBase |
46 |
|
|
namespace entity { |
47 |
|
|
|
48 |
|
|
/// \param obj an Entity object |
49 |
|
|
void addCommands(boost::python::object obj); |
50 |
|
|
void addSignals(boost::python::object obj); |
51 |
|
|
|
52 |
|
|
Entity* create(const char* type, const char* name); |
53 |
|
|
bp::object executeCmd(bp::tuple args, bp::dict); |
54 |
|
|
} // namespace entity |
55 |
|
|
|
56 |
|
|
namespace factory { |
57 |
|
|
bp::tuple getEntityClassList(); |
58 |
|
|
} |
59 |
|
|
namespace pool { |
60 |
|
|
void writeGraph(const char* filename); |
61 |
|
|
bp::list getEntityList(); |
62 |
|
|
const std::map<std::string, Entity*>* getEntityMap(); |
63 |
|
|
} // namespace pool |
64 |
|
|
namespace debug { |
65 |
|
|
void addLoggerFileOutputStream(const char* filename); |
66 |
|
|
void addLoggerCoutOutputStream(); |
67 |
|
|
void closeLoggerFileOutputStream(); |
68 |
|
|
void realTimeLoggerSpinOnce(); |
69 |
|
|
void realTimeLoggerDestroy(); |
70 |
|
|
void realTimeLoggerInstance(); |
71 |
|
|
} // namespace debug |
72 |
|
|
|
73 |
|
|
} // namespace python |
74 |
|
|
} // namespace dynamicgraph |
75 |
|
|
|
76 |
|
|
#endif |