dynamic-graph-py.hh
Go to the documentation of this file.
1 #ifndef DYNAMIC_GRAPH_PY
2 #define DYNAMIC_GRAPH_PY
3 
4 #include <iostream>
5 #include <sstream>
6 
7 #include <boost/python.hpp>
8 #include <boost/python/stl_iterator.hpp>
9 
10 #include <dynamic-graph/debug.h>
11 #include <dynamic-graph/exception-factory.h>
12 #include <dynamic-graph/signal-base.h>
13 
15 
16 namespace bp = boost::python;
17 
18 namespace dynamicgraph {
19 namespace python {
20 
21 template <typename Iterator>
22 inline bp::list to_py_list(Iterator begin, Iterator end) {
23  typedef typename Iterator::value_type T;
24  bp::list lst;
25  std::for_each(begin, end, [&](const T& t) { lst.append(t); });
26  return lst;
27 }
28 
29 template <typename Iterator>
30 inline bp::tuple to_py_tuple(Iterator begin, Iterator end) {
31  return bp::tuple(to_py_list(begin, end));
32 }
33 
34 template <typename T>
35 inline std::vector<T> to_std_vector(const bp::object& iterable) {
36  return std::vector<T>(bp::stl_input_iterator<T>(iterable), 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, bp::object object);
44 } // namespace signalBase
45 namespace entity {
46 
48 void addCommands(boost::python::object obj);
49 void addSignals(boost::python::object obj);
50 
51 Entity* create(const char* type, const char* name);
52 bp::object executeCmd(bp::tuple args, bp::dict);
53 } // namespace entity
54 
55 namespace factory {
56 bp::tuple getEntityClassList();
57 }
58 namespace pool {
59 void writeGraph(const char* filename);
60 bp::list getEntityList();
61 const std::map<std::string, Entity*>* getEntityMap();
62 } // namespace pool
63 namespace debug {
64 void addLoggerFileOutputStream(const char* filename);
70 } // namespace debug
71 
72 } // namespace python
73 } // namespace dynamicgraph
74 
75 #endif
void addSignals(boost::python::object obj)
void closeLoggerFileOutputStream()
Definition: debug-py.cc:37
void addLoggerFileOutputStream(const char *filename)
Definition: debug-py.cc:27
bp::list to_py_list(Iterator begin, Iterator end)
Definition: dynamic-graph-py.hh:22
void addLoggerCoutOutputStream()
Definition: debug-py.cc:41
MapOfEntities * getEntityMap()
Definition: dynamic-graph-py.cc:63
void realTimeLoggerDestroy()
Definition: debug-py.cc:43
void exposeSignals()
Definition: signal-base-py.cc:95
bp::object executeCmd(bp::tuple args, bp::dict)
Definition: entity-py.cc:75
void realTimeLoggerInstance()
Definition: debug-py.cc:47
bp::tuple to_py_tuple(Iterator begin, Iterator end)
Definition: dynamic-graph-py.hh:30
bp::tuple getEntityClassList()
Get name of entity.
Definition: factory-py.cc:19
std::vector< T > to_std_vector(const bp::object &iterable)
Definition: dynamic-graph-py.hh:35
void writeGraph(const char *filename)
Definition: pool-py.cc:14
bp::list getEntityList()
Get list of entities.
Definition: pool-py.cc:21
void realTimeLoggerSpinOnce()
Definition: debug-py.cc:45
SignalBase< int > * createSignalWrapper(const char *name, const char *type, bp::object object)
Create an instance of SignalWrapper.
Definition: signal-base-py.cc:141
void addCommands(boost::python::object obj)
Definition: convert-dg-to-py.hh:8
Entity * create(const char *type, const char *name)
Create an instance of Entity.
Definition: entity-py.cc:57