From f6aa64d8d3cdce7b96a973478f88ee58e5cc174e Mon Sep 17 00:00:00 2001 From: Olivier Stasse <olivier.stasse@gmail.com> Date: Wed, 10 Jul 2013 16:17:52 +0200 Subject: [PATCH] Allow to access class name of a signal. --- include/dynamic-graph/signal-base.h | 5 ++++- include/dynamic-graph/signal-ptr.t.cpp | 7 +++++-- include/dynamic-graph/signal.h | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/dynamic-graph/signal-base.h b/include/dynamic-graph/signal-base.h index 0f6eb341..ab379d74 100644 --- a/include/dynamic-graph/signal-base.h +++ b/include/dynamic-graph/signal-base.h @@ -20,7 +20,7 @@ # include <string> # include <sstream> # include <iostream> - +# include <typeinfo> # include <boost/noncopyable.hpp> # include <dynamic-graph/fwd.hh> @@ -72,6 +72,9 @@ namespace dynamicgraph return name; } + void getClassName(std::string & aClassName) const + { aClassName = typeid(this).name(); } + virtual void setPeriodTime (const Time&) {} diff --git a/include/dynamic-graph/signal-ptr.t.cpp b/include/dynamic-graph/signal-ptr.t.cpp index 82b03bd4..5f9da340 100644 --- a/include/dynamic-graph/signal-ptr.t.cpp +++ b/include/dynamic-graph/signal-ptr.t.cpp @@ -121,9 +121,12 @@ namespace dynamicgraph transmitAbstract = false; DG_THROW ExceptionSignal( ExceptionSignal::PLUG_IMPOSSIBLE, "Compl. Uncompatible types for plugin.", - "(while trying to plug <%s> on <%s>).", + "(while trying to plug <%s> on <%s>)" + " with types <%s> on <%s>.", unknown_ref->getName ().c_str (), - this->getName ().c_str ()); + this->getName ().c_str (), + typeid(T).name(), + typeid(unknown_ref).name()); } } else diff --git a/include/dynamic-graph/signal.h b/include/dynamic-graph/signal.h index e06aa88d..d70f1fc3 100644 --- a/include/dynamic-graph/signal.h +++ b/include/dynamic-graph/signal.h @@ -30,7 +30,6 @@ #include <dynamic-graph/exception-signal.h> #include <dynamic-graph/signal-base.h> - #ifdef HAVE_LIBBOOST_THREAD #include <boost/thread.hpp> #endif @@ -126,7 +125,9 @@ protected: virtual inline const T& operator ()( const Time & t ){ return access(t); } virtual Signal<T,Time>& operator= ( const T& t ); inline operator const T& () const { return accessCopy (); } - + virtual void getClassName(std::string & aClassName) const + { aClassName = typeid(this).name(); } + public: virtual void checkCompatibility () { throw Tcopy; } -- GitLab