Commit bad2e760 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

format: clang-format-12

parent 8889710b
Pipeline #16013 passed with stage
in 4 minutes and 10 seconds
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <boost/python.hpp>
#include <dynamic-graph/linear-algebra.h> #include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/value.h> #include <dynamic-graph/value.h>
#include <boost/python.hpp>
namespace dynamicgraph { namespace dynamicgraph {
namespace python { namespace python {
namespace convert { namespace convert {
......
#ifndef DYNAMIC_GRAPH_PY #ifndef DYNAMIC_GRAPH_PY
#define DYNAMIC_GRAPH_PY #define DYNAMIC_GRAPH_PY
#include <iostream>
#include <sstream>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <dynamic-graph/debug.h> #include <dynamic-graph/debug.h>
#include <dynamic-graph/exception-factory.h> #include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/signal-base.h> #include <dynamic-graph/signal-base.h>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <iostream>
#include <sstream>
#include "dynamic-graph/python/signal-wrapper.hh" #include "dynamic-graph/python/signal-wrapper.hh"
namespace bp = boost::python; namespace bp = boost::python;
......
...@@ -15,7 +15,7 @@ namespace dynamicgraph { ...@@ -15,7 +15,7 @@ namespace dynamicgraph {
namespace python { namespace python {
class Interpreter; class Interpreter;
typedef shared_ptr<Interpreter> InterpreterPtr_t; typedef shared_ptr<Interpreter> InterpreterPtr_t;
} // namespace python } // namespace python
} // namespace dynamicgraph } // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_PYTHON_FWD_HH #endif // DYNAMIC_GRAPH_PYTHON_FWD_HH
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE #undef _XOPEN_SOURCE
#include <dynamic-graph/python/fwd.hh> #include <dynamic-graph/python/fwd.hh>
#include "dynamic-graph/python/api.hh"
#include "dynamic-graph/python/python-compat.hh"
#include "dynamic-graph/python/api.hh" #include "dynamic-graph/python/api.hh"
#include "dynamic-graph/python/python-compat.hh"
namespace dynamicgraph { namespace dynamicgraph {
namespace python { namespace python {
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#include <pinocchio/fwd.hpp> #include <pinocchio/fwd.hpp>
#endif #endif
#include <boost/python.hpp> #include <dynamic-graph/entity.h>
#include <boost/mpl/for_each.hpp> #include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector.hpp> #include <boost/mpl/vector.hpp>
#include <boost/python.hpp>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/python/dynamic-graph-py.hh> #include <dynamic-graph/python/dynamic-graph-py.hh>
namespace dynamicgraph { namespace dynamicgraph {
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
#ifndef DGPY_SIGNAL_WRAPPER #ifndef DGPY_SIGNAL_WRAPPER
#define DGPY_SIGNAL_WRAPPER #define DGPY_SIGNAL_WRAPPER
#include <boost/python.hpp> #include <dynamic-graph/entity.h>
#include <boost/bind.hpp>
#include <dynamic-graph/linear-algebra.h> #include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/signal.h> #include <dynamic-graph/signal.h>
#include <dynamic-graph/entity.h>
#include <boost/bind.hpp>
#include <boost/python.hpp>
#include "dynamic-graph/python/python-compat.hh" #include "dynamic-graph/python/python-compat.hh"
namespace dynamicgraph { namespace dynamicgraph {
......
// Copyright 2020, Joseph Mirabel, LAAS-CNRS. // Copyright 2020, Joseph Mirabel, LAAS-CNRS.
#include <sstream>
#include <boost/python.hpp>
#include <dynamic-graph/signal-base.h> #include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal-ptr.h> #include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h> #include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h> #include <dynamic-graph/signal.h>
#include <boost/python.hpp>
#include <sstream>
#include "dynamic-graph/python/signal-wrapper.hh" #include "dynamic-graph/python/signal-wrapper.hh"
namespace dynamicgraph { namespace dynamicgraph {
......
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <iostream> #include "dynamic-graph/python/convert-dg-to-py.hh"
#include <sstream>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <dynamic-graph/signal-base.h> #include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal.h>
#include <dynamic-graph/signal-caster.h> #include <dynamic-graph/signal-caster.h>
#include <dynamic-graph/signal.h>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <iostream>
#include <sstream>
#include "dynamic-graph/python/convert-dg-to-py.hh"
#include "dynamic-graph/python/python-compat.hh" #include "dynamic-graph/python/python-compat.hh"
namespace dynamicgraph { namespace dynamicgraph {
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
#include <iostream> #include <iostream>
#define ENABLE_RT_LOG #define ENABLE_RT_LOG
#include <dynamic-graph/entity.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/real-time-logger.h> #include <dynamic-graph/real-time-logger.h>
#include <boost/shared_ptr.hpp>
#include <map> #include <map>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/entity.h>
#include <vector> #include <vector>
#include <boost/shared_ptr.hpp>
#include "dynamic-graph/python/dynamic-graph-py.hh" #include "dynamic-graph/python/dynamic-graph-py.hh"
typedef boost::shared_ptr<std::ofstream> ofstreamShrPtr; typedef boost::shared_ptr<std::ofstream> ofstreamShrPtr;
......
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <iostream> #include "dynamic-graph/python/dynamic-graph-py.hh"
#include <sstream>
#include <boost/python.hpp>
#include <boost/python/raw_function.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <eigenpy/eigenpy.hpp>
#include <Eigen/Geometry>
#include <eigenpy/geometry.hpp>
#include <dynamic-graph/command.h>
#include <dynamic-graph/debug.h> #include <dynamic-graph/debug.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/entity.h> #include <dynamic-graph/entity.h>
#include <dynamic-graph/command.h> #include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
#include <dynamic-graph/pool.h> #include <dynamic-graph/pool.h>
#include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#include <dynamic-graph/tracer.h> #include <dynamic-graph/tracer.h>
#include "dynamic-graph/python/dynamic-graph-py.hh" #include <Eigen/Geometry>
#include "dynamic-graph/python/signal-wrapper.hh" #include <boost/python.hpp>
#include <boost/python/raw_function.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <eigenpy/eigenpy.hpp>
#include <eigenpy/geometry.hpp>
#include <iostream>
#include <sstream>
#include "dynamic-graph/python/convert-dg-to-py.hh" #include "dynamic-graph/python/convert-dg-to-py.hh"
#include "dynamic-graph/python/module.hh" #include "dynamic-graph/python/module.hh"
#include "dynamic-graph/python/signal-wrapper.hh"
namespace dynamicgraph { namespace dynamicgraph {
namespace python { namespace python {
...@@ -106,35 +104,38 @@ void exposeEntityBase() { ...@@ -106,35 +104,38 @@ void exposeEntityBase() {
.add_property("streamPrintPeriod", &Entity::getStreamPrintPeriod, &Entity::setStreamPrintPeriod, .add_property("streamPrintPeriod", &Entity::getStreamPrintPeriod, &Entity::setStreamPrintPeriod,
"set the period at which debugging information are printed") "set the period at which debugging information are printed")
.def("__str__", .def(
+[](const Entity& e) -> std::string { "__str__",
std::ostringstream os; +[](const Entity& e) -> std::string {
e.display(os); std::ostringstream os;
return os.str(); e.display(os);
}) return os.str();
.def("signals", })
+[](const Entity& e) -> bp::list { .def(
bp::list ret; "signals",
for (auto& el : e.getSignalMap()) ret.append(bp::ptr(el.second)); +[](const Entity& e) -> bp::list {
return ret; bp::list ret;
}, for (auto& el : e.getSignalMap()) ret.append(bp::ptr(el.second));
"Return the list of signals.") return ret;
},
"Return the list of signals.")
//.def("signal", +[](Entity& e, const std::string &name) { return &e.getSignal(name); }, //.def("signal", +[](Entity& e, const std::string &name) { return &e.getSignal(name); },
// reference_existing_object()) // reference_existing_object())
.def("signal", &getSignal, reference_existing_object(), "get signal by name from an Entity", bp::arg("name")) .def("signal", &getSignal, reference_existing_object(), "get signal by name from an Entity", bp::arg("name"))
.def("hasSignal", &Entity::hasSignal, "return True if the entity has a signal with the given name") .def("hasSignal", &Entity::hasSignal, "return True if the entity has a signal with the given name")
.def("displaySignals", .def(
+[](const Entity& e) { "displaySignals",
Entity::SignalMap signals(e.getSignalMap()); +[](const Entity& e) {
std::cout << "--- <" << e.getName(); Entity::SignalMap signals(e.getSignalMap());
if (signals.empty()) std::cout << "--- <" << e.getName();
std::cout << "> has no signal\n"; if (signals.empty())
else std::cout << "> has no signal\n";
std::cout << "> signal list:\n"; else
for (const auto& el : signals) el.second->display(std::cout << " |-- <") << '\n'; std::cout << "> signal list:\n";
}, for (const auto& el : signals) el.second->display(std::cout << " |-- <") << '\n';
"Print the list of signals into standard output: temporary.") },
"Print the list of signals into standard output: temporary.")
/* /*
.def("__getattr__", +[](Entity& e, const std::string &name) -> SignalBase<int>* { return &e.getSignal(name); }, .def("__getattr__", +[](Entity& e, const std::string &name) -> SignalBase<int>* { return &e.getSignal(name); },
...@@ -240,22 +241,26 @@ BOOST_PYTHON_MODULE(wrap) { ...@@ -240,22 +241,26 @@ BOOST_PYTHON_MODULE(wrap) {
typedef dg::PoolStorage::Entities MapOfEntities; typedef dg::PoolStorage::Entities MapOfEntities;
bp::class_<MapOfEntities>("MapOfEntities") bp::class_<MapOfEntities>("MapOfEntities")
.def("__len__", &MapOfEntities::size) .def("__len__", &MapOfEntities::size)
.def("keys", .def(
+[](const MapOfEntities& m) -> bp::tuple { "keys",
bp::list res; +[](const MapOfEntities& m) -> bp::tuple {
for (const auto& el : m) res.append(el.first); bp::list res;
return bp::tuple(res); for (const auto& el : m) res.append(el.first);
}) return bp::tuple(res);
.def("values", })
+[](const MapOfEntities& m) -> bp::tuple { .def(
bp::list res; "values",
for (const auto& el : m) res.append(bp::ptr(el.second)); +[](const MapOfEntities& m) -> bp::tuple {
return bp::tuple(res); bp::list res;
}) for (const auto& el : m) res.append(bp::ptr(el.second));
return bp::tuple(res);
})
.def("__getitem__", static_cast<dg::Entity*& (MapOfEntities::*)(const std::string& k)>(&MapOfEntities::at), .def("__getitem__", static_cast<dg::Entity*& (MapOfEntities::*)(const std::string& k)>(&MapOfEntities::at),
reference_existing_object()) reference_existing_object())
.def("__setitem__", +[](MapOfEntities& m, const std::string& n, dg::Entity* e) { m.emplace(n, e); }) .def(
"__setitem__", +[](MapOfEntities& m, const std::string& n, dg::Entity* e) { m.emplace(n, e); })
.def("__iter__", bp::iterator<MapOfEntities>()) .def("__iter__", bp::iterator<MapOfEntities>())
.def("__contains__", +[](const MapOfEntities& m, const std::string& n) -> bool { return m.count(n); }); .def(
"__contains__", +[](const MapOfEntities& m, const std::string& n) -> bool { return m.count(n); });
bp::to_python_converter<MapOfEntities::value_type, MapOfEntitiesPairToPythonConverter>(); bp::to_python_converter<MapOfEntities::value_type, MapOfEntitiesPairToPythonConverter>();
} }
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <iostream> #include <dynamic-graph/command.h>
#include <dynamic-graph/entity.h> #include <dynamic-graph/entity.h>
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
#include <dynamic-graph/command.h>
#include <dynamic-graph/linear-algebra.h> #include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/pool.h> #include <dynamic-graph/pool.h>
#include <dynamic-graph/value.h> #include <dynamic-graph/value.h>
#include <iostream>
#include "dynamic-graph/python/convert-dg-to-py.hh" #include "dynamic-graph/python/convert-dg-to-py.hh"
#include "dynamic-graph/python/dynamic-graph-py.hh" #include "dynamic-graph/python/dynamic-graph-py.hh"
......
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <iostream>
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
#include <iostream>
#include "dynamic-graph/python/dynamic-graph-py.hh" #include "dynamic-graph/python/dynamic-graph-py.hh"
using dynamicgraph::Entity; using dynamicgraph::Entity;
......
// Copyright 2011, 2012, Florent Lamiraux, LAAS-CNRS. // Copyright 2011, 2012, Florent Lamiraux, LAAS-CNRS.
#include <dynamic-graph/pool.h>
#include <dynamic-graph/entity.h> #include <dynamic-graph/entity.h>
#include <dynamic-graph/pool.h>
#include <vector> #include <vector>
#include "dynamic-graph/python/dynamic-graph-py.hh" #include "dynamic-graph/python/dynamic-graph-py.hh"
......
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS. // Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#include <iostream> #include <dynamic-graph/linear-algebra.h>
#include <sstream>
#include <boost/python.hpp>
#include "dynamic-graph/python/signal.hh"
#include <dynamic-graph/signal-base.h> #include <dynamic-graph/signal-base.h>
#include <dynamic-graph/signal.h>
#include <dynamic-graph/signal-ptr.h> #include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h> #include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/linear-algebra.h> #include <dynamic-graph/signal.h>
#include <dynamic-graph/value.h> #include <dynamic-graph/value.h>
#include <boost/python.hpp>
#include <iostream>
#include <sstream>
#include "dynamic-graph/python/dynamic-graph-py.hh" #include "dynamic-graph/python/dynamic-graph-py.hh"
#include "dynamic-graph/python/signal-wrapper.hh" #include "dynamic-graph/python/signal-wrapper.hh"
#include "dynamic-graph/python/signal.hh"
using dynamicgraph::SignalBase; using dynamicgraph::SignalBase;
...@@ -48,12 +46,13 @@ void exposeSignalBase(const char* name) { ...@@ -48,12 +46,13 @@ void exposeSignalBase(const char* name) {
.add_property("name", bp::make_function(&S_t::getName, bp::return_value_policy<bp::copy_const_reference>())) .add_property("name", bp::make_function(&S_t::getName, bp::return_value_policy<bp::copy_const_reference>()))
.def("getName", &S_t::getName, bp::return_value_policy<bp::copy_const_reference>()) .def("getName", &S_t::getName, bp::return_value_policy<bp::copy_const_reference>())
.def("getClassName", .def(
+[](const S_t& s) -> std::string { "getClassName",
std::string ret; +[](const S_t& s) -> std::string {
s.getClassName(ret); std::string ret;
return ret; s.getClassName(ret);
}) return ret;
})
.def("plug", &S_t::plug, "Plug the signal to another signal") .def("plug", &S_t::plug, "Plug the signal to another signal")
.def("unplug", &S_t::unplug, "Unplug the signal") .def("unplug", &S_t::unplug, "Unplug the signal")
...@@ -63,32 +62,35 @@ void exposeSignalBase(const char* name) { ...@@ -63,32 +62,35 @@ void exposeSignalBase(const char* name) {
.def("recompute", &S_t::recompute, "Recompute the signal at given time") .def("recompute", &S_t::recompute, "Recompute the signal at given time")
.def("__str__", .def(
+[](const S_t& s) -> std::string { "__str__",
std::ostringstream oss; +[](const S_t& s) -> std::string {
s.display(oss); std::ostringstream oss;
return oss.str(); s.display(oss);
}) return oss.str();
.def("displayDependencies", })
+[](const S_t& s, int time) -> std::string { .def(
std::ostringstream oss; "displayDependencies",
s.displayDependencies(oss, time); +[](const S_t& s, int time) -> std::string {
return oss.str(); std::ostringstream oss;
}, s.displayDependencies(oss, time);
"Print the signal dependencies in a string"); return oss.str();
},
"Print the signal dependencies in a string");
} }
template <> template <>
auto exposeSignal<MatrixHomogeneous, time_type>(const std::string& name) { auto exposeSignal<MatrixHomogeneous, time_type>(const std::string& name) {
typedef Signal<MatrixHomogeneous, time_type> S_t; typedef Signal<MatrixHomogeneous, time_type> S_t;
bp::class_<S_t, bp::bases<SignalBase<time_type> >, boost::noncopyable> obj(name.c_str(), bp::init<std::string>()); bp::class_<S_t, bp::bases<SignalBase<time_type> >, boost::noncopyable> obj(name.c_str(), bp::init<std::string>());
obj.add_property("value", +[](const S_t& signal) -> Matrix4 { return signal.accessCopy().matrix(); }, obj.add_property(
+[](S_t& signal, const Matrix4& v) { "value", +[](const S_t& signal) -> Matrix4 { return signal.accessCopy().matrix(); },
// TODO it isn't hard to support pinocchio::SE3 type here. +[](S_t& signal, const Matrix4& v) {
// However, this adds a dependency to pinocchio. // TODO it isn't hard to support pinocchio::SE3 type here.
signal.setConstant(MatrixHomogeneous(v)); // However, this adds a dependency to pinocchio.
}, signal.setConstant(MatrixHomogeneous(v));
"the signal value."); },
"the signal value.");
return obj; return obj;
} }
......
// Copyright (c) 2018, Joseph Mirabel // Copyright (c) 2018, Joseph Mirabel
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
#include <dynamic-graph/factory.h>
#include <dynamic-graph/command-bind.h>
#include "dynamic-graph/python/signal-wrapper.hh" #include "dynamic-graph/python/signal-wrapper.hh"
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/factory.h>
namespace dynamicgraph { namespace dynamicgraph {
namespace python { namespace python {
void PythonSignalContainer::signalRegistration(const SignalArray<int>& signals) { void PythonSignalContainer::signalRegistration(const SignalArray<int>& signals) {
......
#include "dynamic-graph/python/module.hh"
#include <dynamic-graph/tracer.h> #include <dynamic-graph/tracer.h>
#include "dynamic-graph/python/module.hh"
BOOST_PYTHON_MODULE(wrap) { BOOST_PYTHON_MODULE(wrap) {
using dynamicgraph::Tracer; using dynamicgraph::Tracer;
......