X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FParameters.hxx;h=e47b799c7616e2c85ea7148bb4eb4fe2956e22a4;hb=2361f4f97631e09d88d8a5510a369817dcaa19db;hp=9afcc3224184ee2326b8128f3fb86da890d60126;hpb=a3fd8b70054c862446ed7e3fabf2fd24cfe2ad92;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Parameters.hxx b/lib/cpPlugins/Interface/Parameters.hxx index 9afcc32..e47b799 100644 --- a/lib/cpPlugins/Interface/Parameters.hxx +++ b/lib/cpPlugins/Interface/Parameters.hxx @@ -5,31 +5,6 @@ #include #include -// ------------------------------------------------------------------------- -#define cpPlugins_Interface_Parameters_SetListMacro( TYPE ) \ - template< class I > \ - void cpPlugins::Interface::Parameters:: \ - SetValueAs##TYPE##List( const TString& name, const I& b, const I& e ) \ - { \ - TParameters::iterator pIt = this->m_Parameters.find( name ); \ - if( pIt == this->m_Parameters.end( ) ) \ - return; \ - if( pIt->second.first != Self::TYPE##List ) \ - return; \ - std::stringstream ss; \ - for( I i = b; i != e; ++i ) \ - ss << *i << ":"; \ - pIt->second.second = ss.str( ); \ - } - -cpPlugins_Interface_Parameters_SetListMacro( String ); -cpPlugins_Interface_Parameters_SetListMacro( Bool ); -cpPlugins_Interface_Parameters_SetListMacro( Int ); -cpPlugins_Interface_Parameters_SetListMacro( Uint ); -cpPlugins_Interface_Parameters_SetListMacro( Real ); -cpPlugins_Interface_Parameters_SetListMacro( Index ); -cpPlugins_Interface_Parameters_SetListMacro( Point ); - // ------------------------------------------------------------------------- #define cpPlugins_Interface_Parameters_SetIndexOrPointMacro( NAME, TYPE ) \ template< class T > \ @@ -37,7 +12,7 @@ cpPlugins_Interface_Parameters_SetListMacro( Point ); GetValueAs##NAME( const TString& name ) const \ { \ T val; \ - TParameters::iterator pIt = this->m_Parameters.find( name ); \ + TParameters::const_iterator pIt = this->m_Parameters.find( name ); \ if( pIt != this->m_Parameters.end( ) ) \ { \ if( pIt->second.first == Self::NAME ) \ @@ -47,9 +22,8 @@ cpPlugins_Interface_Parameters_SetListMacro( Point ); unsigned int i = 0; \ while( std::getline( ss, token, ',' ) ) \ { \ - if( token != "" ) \ + if( token != "" ) \ val[ i++ ] = TYPE( std::atof( token.c_str( ) ) ); \ - \ } \ } \ } \ @@ -65,14 +39,30 @@ void cpPlugins::Interface::Parameters:: GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const { lst.clear( ); - TParameters::iterator pIt = this->m_Parameters.find( name ); + TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return; if( pIt->second.first != Self::IndexList ) return; - // TODO: - std::cerr << "TODO GetValueAsIndexList" << std::endl; + std::istringstream ss( pIt->second.second ); + std::string token; + while( std::getline( ss, token, ':' ) ) + { + if( token != "" ) + { + std::istringstream ts( token ); + std::string text; + unsigned int i = 0; + I idx; + while( std::getline( ts, text, ',' ) ) + if( text != "" ) + idx[ i++ ] = std::atoi( text.c_str( ) ); + lst.push_back( idx ); + + } // fi + + } // elihw } // ------------------------------------------------------------------------- @@ -81,14 +71,30 @@ void cpPlugins::Interface::Parameters:: GetValueAsPointList( std::vector< P >& lst, const TString& name ) const { lst.clear( ); - TParameters::iterator pIt = this->m_Parameters.find( name ); + TParameters::const_iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return; if( pIt->second.first != Self::PointList ) return; - // TODO: - std::cerr << "TODO GetValueAsPointList" << std::endl; + std::istringstream ss( pIt->second.second ); + std::string token; + while( std::getline( ss, token, ':' ) ) + { + if( token != "" ) + { + std::istringstream ts( token ); + std::string text; + unsigned int i = 0; + P pnt; + while( std::getline( ts, text, ',' ) ) + if( text != "" ) + pnt[ i++ ] = std::atof( text.c_str( ) ); + lst.push_back( pnt ); + + } // fi + + } // elihw } #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__