#ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ #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 = ss.str( ); \ } cpPlugins_Interface_Parameters_SetListMacro( String ); 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 ); // ------------------------------------------------------------------------- template< class I > I cpPlugins::Interface::Parameters:: GetValueAsIndex( const TString& name ) const { I idx; TParameters::iterator pIt = this->m_Parameters.find( name ); if( pIt != this->m_Parameters.end( ) ) { if( pIt->second.first == Self::Index ) { std::istringstream ss( pIt->second.second ); std::string token; unsigned int i = 0; while( std::getline( ss, token, ',' ) ) { if( token != "" ) idx[ i++ ] = std::atoi( token.c_str( ) ); } // elihw } // fi } // fi return( idx ); } // ------------------------------------------------------------------------- template< class P > P cpPlugins::Interface::Parameters:: GetValueAsPoint( const TString& name ) const { P pnt; TParameters::iterator pIt = this->m_Parameters.find( name ); if( pIt != this->m_Parameters.end( ) ) { if( pIt->second.first == Self::Point ) { std::istringstream ss( pIt->second.second ); std::string token; unsigned int i = 0; while( std::getline( ss, token, ',' ) ) { if( token != "" ) pnt[ i++ ] = std::atof( token.c_str( ) ); } // elihw } // fi } // fi return( pnt ); } // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Parameters:: GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const { lst.clear( ); TParameters::iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return; if( pIt->second.first != Self::IndexList ) return; // TODO: } // ------------------------------------------------------------------------- template< class P > void cpPlugins::Interface::Parameters:: GetValueAsPointList( std::vector< P >& lst, const TString& name ) const { lst.clear( ); TParameters::iterator pIt = this->m_Parameters.find( name ); if( pIt == this->m_Parameters.end( ) ) return; if( pIt->second.first != Self::PointList ) return; // TODO: } #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__ // eof - $RCSfile$