diff --git a/include/dynamic-graph/pool.h b/include/dynamic-graph/pool.h index 4c4cd1acb02141c151db40af90156371da122c45..a3dee5776b84503febe9adc31522c8fef57adeed 100644 --- a/include/dynamic-graph/pool.h +++ b/include/dynamic-graph/pool.h @@ -88,6 +88,12 @@ namespace dynamicgraph void clearPlugin (const std::string& name); /*! @} */ + /// + /// \brief Get a signal by name + /// + /// \param sigpath stream containing a string of the form "entity.signal" + SignalBase<int>& getSignal( std::istringstream& sigpath ); + /*! \brief This method looks for the object named objectName, and ask to provide the function functionName with the arguments cmdArg. If the method of the object displays some information this will diff --git a/src/dgraph/pool.cpp b/src/dgraph/pool.cpp index c7091a558b01865878c0748ca64e459cbde30b02..5baf94a15cbe9e6e915de28c0aafc900e6e7e9de 100644 --- a/src/dgraph/pool.cpp +++ b/src/dgraph/pool.cpp @@ -23,11 +23,14 @@ /* --------------------------------------------------------------------- */ /* --- DYNAMIC-GRAPH --- */ -#include <dynamic-graph/pool.h> -#include <dynamic-graph/debug.h> -#include <dynamic-graph/entity.h> #include <list> #include <typeinfo> +#include <iostream> +#include <sstream> +#include <string> +#include "dynamic-graph/pool.h" +#include "dynamic-graph/debug.h" +#include "dynamic-graph/entity.h" using namespace dynamicgraph; @@ -240,6 +243,38 @@ commandLine( const std::string& objectName,const std::string& functionName, } } +static bool +objectNameParser( std::istringstream& cmdparse, + std::string& objName, + std::string& funName ) +{ + const int SIZE=128; + char buffer[SIZE]; + cmdparse >> std::ws; + cmdparse.getline( buffer,SIZE,'.' ); + if(! cmdparse.good () ) // The callback is not an object method + return false; + + objName = buffer; + //cmdparse.getline( buffer,SIZE ); + //funName = buffer; + cmdparse >> funName; + return true; +} + +SignalBase<int>& +PoolStorage:: +getSignal( std::istringstream& sigpath ) +{ + std::string objname,signame; + if(! objectNameParser( sigpath,objname,signame ) ) + { DG_THROW ExceptionFactory( ExceptionFactory::UNREFERED_SIGNAL, + "Parse error in signal name" ); } + + Entity& ent = getEntity( objname ); + return ent.getSignal( signame ); +} + namespace dynamicgraph { //! The global g_pool object. PoolStorage g_pool;