From e7075aa319b938255a1e9441310570d30f613f6f Mon Sep 17 00:00:00 2001 From: Florent Lamiraux <florent@laas.fr> Date: Fri, 23 Dec 2011 15:33:47 +0100 Subject: [PATCH] Revert "Modify SignalBase.value." This reverts commit b055ba734eee6e6ac01fcec6997151ff461666d5. This commits seems to have side effects. Revert it temporarily. --- src/signal-base-py.cc | 68 +++++++++---------------------------------- 1 file changed, 13 insertions(+), 55 deletions(-) diff --git a/src/signal-base-py.cc b/src/signal-base-py.cc index eb8e2bd..9832daf 100644 --- a/src/signal-base-py.cc +++ b/src/signal-base-py.cc @@ -18,7 +18,6 @@ #include <sstream> #include <dynamic-graph/signal-base.h> -#include <dynamic-graph/signal-ptr.h> #include <dynamic-graph/signal.h> #include <dynamic-graph/signal-caster.h> #include <dynamic-graph/linear-algebra.h> @@ -155,61 +154,20 @@ namespace dynamicgraph { pointer = PyCObject_AsVoidPtr(object); SignalBase<int>* signal = (SignalBase<int>*)pointer; - { // --- VECTOR SIGNALS ----------------- - // Two cases: the signal embeds directly a vector, or embeds - // an object deriving from vector.In the first case, - // the signal is directly cast into sig<vector>. - // In the second case, the derived object can be access as a vector - // using the signal-ptr<vector> type. - Signal<dynamicgraph::Vector,int> * sigvec - = dynamic_cast< Signal<dynamicgraph::Vector,int>* >( signal ); - if( NULL!= sigvec ) - { - return vectorToPython( sigvec->accessCopy() ); - } - - // Extraction of object derinving from vector: plug signal into - // a vector signal and get the value from the signal-ptr instead - // of the original vector. - SignalPtr<dynamicgraph::Vector,int> sigptr(NULL,"vector-caster"); - try - { - sigptr.plug(signal); - return vectorToPython( sigptr.accessCopy() ); - } - catch( dynamicgraph::ExceptionSignal& ex ) - { - if( ex.getCode() != dynamicgraph::ExceptionSignal::PLUG_IMPOSSIBLE ) - throw; - } - } - - { // --- MATRIX SIGNALS -------------------- - // Two cases: the signal embeds directly a matrix, or embeds - // an object deriving from matrix.In the first case, - // the signal is directly cast into sig<matrix>. - // In the second case, the derived object can be access as a matrix - // using the signal-ptr<matrix> type. - Signal<dynamicgraph::Matrix,int> * sigmat - = dynamic_cast< Signal<dynamicgraph::Matrix,int>* >( signal ); - if( NULL!= sigmat ) - { - return matrixToPython( sigmat->accessCopy() ); - } - - SignalPtr<dynamicgraph::Matrix,int> sigptr(NULL,"matrix-caster"); - try - { - sigptr.plug(signal); - return matrixToPython( sigptr.accessCopy() ); - } - catch( dynamicgraph::ExceptionSignal& ex ) - { - if( ex.getCode() != dynamicgraph::ExceptionSignal::PLUG_IMPOSSIBLE ) - throw; - } - } + /* Temptative for specific signal type. */ + Signal<dynamicgraph::Vector,int> * sigvec + = dynamic_cast< Signal<dynamicgraph::Vector,int>* >( signal ); + if( NULL!= sigvec ) + { + return vectorToPython( sigvec->accessCopy() ); + } + Signal<dynamicgraph::Matrix,int> * sigmat + = dynamic_cast< Signal<dynamicgraph::Matrix,int>* >( signal ); + if( NULL!= sigmat ) + { + return matrixToPython( sigmat->accessCopy() ); + } Signal<double,int> * sigdouble = dynamic_cast< Signal<double,int>* >( signal ); -- GitLab