#include <cpPlugins/Interface/Parameters.h>
-#include <cstdarg>
-#include <cstdlib>
-#include <sstream>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetMacro( TYPE ) \
- void cpPlugins::Interface::Parameters:: \
- SetValueAs##TYPE( const TString& name, const T##TYPE& v ) \
- { \
- TParameters::iterator pIt = this->m_Parameters.find( name ); \
- if( pIt == this->m_Parameters.end( ) ) \
- return; \
- if( pIt->second.first != Self::TYPE ) \
- return; \
- std::stringstream ss; \
- ss << v; \
- pIt->second.second = ss.str( ); \
- }
-
-cpPlugins_Interface_Parameters_SetMacro( String );
-cpPlugins_Interface_Parameters_SetMacro( Bool );
-cpPlugins_Interface_Parameters_SetMacro( Int );
-cpPlugins_Interface_Parameters_SetMacro( Uint );
-cpPlugins_Interface_Parameters_SetMacro( Real );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetArrayMacro( TYPE, ATYPE ) \
- void cpPlugins::Interface::Parameters:: \
- SetValueAs##TYPE( const TString& name, const TUint& n, ... ) \
- { \
- TParameters::iterator pIt = this->m_Parameters.find( name ); \
- if( pIt == this->m_Parameters.end( ) ) \
- return; \
- if( pIt->second.first != Self::TYPE ) \
- return; \
- va_list v_lst; \
- va_start( v_lst, n ); \
- std::stringstream ss; \
- for( TUint i = 0; i < n; ++i ) \
- ss << va_arg( v_lst, ATYPE ) << ","; \
- va_end( v_lst ); \
- pIt->second.second = ss.str( ); \
- }
-
-cpPlugins_Interface_Parameters_SetArrayMacro( Index, int );
-cpPlugins_Interface_Parameters_SetArrayMacro( Point, double );
+#include <cpPlugins/Interface/ProcessObject.h>
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetListMacro( TYPE ) \
- void cpPlugins::Interface::Parameters:: \
- AddValueTo##TYPE##List( const TString& name, const T##TYPE& v ) \
- { \
- 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; \
- ss << pIt->second.second << v << "#"; \
- 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 );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetArrayListMacro( TYPE, ATYPE ) \
- void cpPlugins::Interface::Parameters:: \
- AddValueTo##TYPE##List( const TString& name, const TUint& n, ... ) \
- { \
- TParameters::iterator pIt = this->m_Parameters.find( name ); \
- if( pIt == this->m_Parameters.end( ) ) \
- return; \
- if( pIt->second.first != Self::TYPE##List ) \
- return; \
- va_list v_lst; \
- va_start( v_lst, n ); \
- std::stringstream ss; \
- ss << pIt->second.second; \
- for( TUint i = 0; i < n; ++i ) \
- ss << va_arg( v_lst, ATYPE ) << ","; \
- va_end( v_lst ); \
- ss << "#"; \
- pIt->second.second = ss.str( ); \
- }
-
-cpPlugins_Interface_Parameters_SetArrayListMacro( Index, int );
-cpPlugins_Interface_Parameters_SetArrayListMacro( Point, double );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_ClearListMacro( TYPE ) \
- void cpPlugins::Interface::Parameters:: \
- Clear##TYPE##List( const TString& name ) \
- { \
- TParameters::iterator pIt = this->m_Parameters.find( name ); \
- if( pIt == this->m_Parameters.end( ) ) \
- return; \
- if( pIt->second.first != Self::TYPE##List ) \
- return; \
- pIt->second.second = ""; \
- }
-
-cpPlugins_Interface_Parameters_ClearListMacro( String );
-cpPlugins_Interface_Parameters_ClearListMacro( Bool );
-cpPlugins_Interface_Parameters_ClearListMacro( Int );
-cpPlugins_Interface_Parameters_ClearListMacro( Uint );
-cpPlugins_Interface_Parameters_ClearListMacro( Real );
-cpPlugins_Interface_Parameters_ClearListMacro( Index );
-cpPlugins_Interface_Parameters_ClearListMacro( Point );
+#include <sstream>
// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Parameters( )
+const cpPlugins::Interface::
+ProcessObject* cpPlugins::Interface::Parameters::
+GetProcessObject( ) const
{
- this->Clear( );
+ return( this->m_Process );
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Parameters( const Self& other )
+void cpPlugins::Interface::Parameters::
+SetProcessObject( ProcessObject* v )
{
- this->m_Parameters = other.m_Parameters;
+ this->m_Process = v;
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-~Parameters( )
+void cpPlugins::Interface::Parameters::
+Modified( ) const
{
- this->Clear( );
+ this->Superclass::Modified( );
+ if( this->m_Process != NULL )
+ this->m_Process->Modified( );
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Self& cpPlugins::Interface::Parameters::
-operator=( const Self& other )
+void cpPlugins::Interface::Parameters::
+Clear( )
{
- this->m_Parameters = other.m_Parameters;
- return( *this );
+ this->m_Parameters.clear( );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-Clear( )
+ConfigureAsString( const TString& name, const TString& v )
{
- this->m_Parameters.clear( );
+ this->m_Parameters[ name ] = TParameter( Self::String, TValues( v, v ) );
+ this->Modified( );
}
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Configure( Y ) \
+ void cpPlugins::Interface::Parameters:: \
+ ConfigureAs##Y( const TString& name, const T##Y& v ) \
+ { \
+ std::stringstream str; \
+ str << v; \
+ std::string s = str.str( ); \
+ this->m_Parameters[ name ] = \
+ TParameter( Self::Y, TValues( s, s ) ); \
+ this->Modified( ); \
+ }
+
+cpPlugins_Parameters_Configure( Bool );
+cpPlugins_Parameters_Configure( Int );
+cpPlugins_Parameters_Configure( Uint );
+cpPlugins_Parameters_Configure( Real );
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_List_Configure( Y ) \
+ void cpPlugins::Interface::Parameters:: \
+ ConfigureAs##Y##List( const TString& name ) \
+ { \
+ this->m_Parameters[ name ] = \
+ TParameter( Self::Y##List, TValues( "", "" ) ); \
+ this->Modified( ); \
+ }
+
+cpPlugins_Parameters_List_Configure( String );
+cpPlugins_Parameters_List_Configure( Bool );
+cpPlugins_Parameters_List_Configure( Int );
+cpPlugins_Parameters_List_Configure( Uint );
+cpPlugins_Parameters_List_Configure( Real );
+cpPlugins_Parameters_List_Configure( Index );
+cpPlugins_Parameters_List_Configure( Point );
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-Configure( const Self::Type& type, const TString& name )
+ConfigureAsChoices(
+ const TString& name, const std::vector< TString >& choices
+ )
{
- this->m_Parameters[ name ] = TParameter( type, "" );
+ // It is invalid not to give choices when configuring
+ if( choices.size( ) == 0 )
+ return;
+
+ std::stringstream str_choices;
+ str_choices << choices[ 0 ];
+ for( unsigned int i = 1; i < choices.size( ); ++i )
+ str_choices << "#" << choices[ i ];
+ this->m_Parameters[ name ] =
+ TParameter( Self::Choices, TValues( str_choices.str( ), "" ) );
+ this->Modified( );
}
// -------------------------------------------------------------------------
-std::vector< cpPlugins::Interface::Parameters::TString >
-cpPlugins::Interface::Parameters::
-GetParameters( ) const
+void cpPlugins::Interface::Parameters::
+GetNames( std::vector< TString >& container ) const
{
- std::vector< TString > parameters;
- TParameters::const_iterator pIt = this->m_Parameters.begin( );
- for( ; pIt != this->m_Parameters.end( ); ++pIt )
- parameters.push_back( pIt->first );
- return( parameters );
+ container.clear( );
+ TParameters::const_iterator i = this->m_Parameters.begin( );
+ for( ; i != this->m_Parameters.end( ); ++i )
+ container.push_back( i->first );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
Type cpPlugins::Interface::Parameters::
-GetParameterType( const TString& name ) const
+GetType( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ return( i->second.first );
+ else
return( Self::NoType );
- return( pIt->second.first );
}
// -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters::
-TString& cpPlugins::Interface::Parameters::
-GetRawValue( const TString& name ) const
-{
- static const TString null_str = "";
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( null_str );
- return( pIt->second.second );
-}
+#define cpPlugins_Parameters_Has( Y ) \
+ bool cpPlugins::Interface::Parameters:: \
+ Has##Y( const TString& name ) const \
+ { \
+ TParameters::const_iterator i = this->m_Parameters.find( name ); \
+ if( i != this->m_Parameters.end( ) ) \
+ return( i->second.first == Self::Y ); \
+ else \
+ return( false ); \
+ }
+
+cpPlugins_Parameters_Has( String );
+cpPlugins_Parameters_Has( Bool );
+cpPlugins_Parameters_Has( Int );
+cpPlugins_Parameters_Has( Uint );
+cpPlugins_Parameters_Has( Real );
+cpPlugins_Parameters_Has( Index );
+cpPlugins_Parameters_Has( Point );
+cpPlugins_Parameters_Has( StringList );
+cpPlugins_Parameters_Has( BoolList );
+cpPlugins_Parameters_Has( IntList );
+cpPlugins_Parameters_Has( UintList );
+cpPlugins_Parameters_Has( RealList );
+cpPlugins_Parameters_Has( IndexList );
+cpPlugins_Parameters_Has( PointList );
+cpPlugins_Parameters_Has( Choices );
// -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters::
-TString& cpPlugins::Interface::Parameters::
-GetValueAsString( const TString& name ) const
+cpPlugins::Interface::Parameters::
+TString cpPlugins::Interface::Parameters::
+GetString( const TString& name ) const
{
- static const TString null_str = "";
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( null_str );
- if( pIt->second.first != Self::String )
- return( null_str );
-
- return( pIt->second.second );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ if( i->second.first == Self::String )
+ return( i->second.second.second );
+
+ } // fi
+ return( "" );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
TBool cpPlugins::Interface::Parameters::
-GetValueAsBool( const TString& name ) const
+GetBool( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( TBool( false ) );
- if( pIt->second.first != Self::Bool )
- return( TBool( false ) );
- return( TBool( std::atoi( pIt->second.second.c_str( ) ) == 1 ) );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ if( i->second.first == Self::Bool )
+ return( std::atoi( i->second.second.second.c_str( ) ) == 1 );
+
+ } // fi
+ return( false );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
TInt cpPlugins::Interface::Parameters::
-GetValueAsInt( const TString& name ) const
+GetInt( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( TInt( 0 ) );
- if( pIt->second.first != Self::Int )
- return( TInt( 0 ) );
- return( TInt( std::atoi( pIt->second.second.c_str( ) ) ) );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ if( i->second.first == Self::Int )
+ return( TInt( std::atoi( i->second.second.second.c_str( ) ) ) );
+
+ } // fi
+ return( TInt( 0 ) );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
TUint cpPlugins::Interface::Parameters::
-GetValueAsUint( const TString& name ) const
+GetUint( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( TUint( 0 ) );
- if( pIt->second.first != Self::Uint )
- return( TUint( 0 ) );
- return( TUint( std::atoi( pIt->second.second.c_str( ) ) ) );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ if( i->second.first == Self::Uint )
+ return( TUint( std::atoi( i->second.second.second.c_str( ) ) ) );
+
+ } // fi
+ return( TUint( 0 ) );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
TReal cpPlugins::Interface::Parameters::
-GetValueAsReal( const TString& name ) const
+GetReal( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
- return( TReal( 0 ) );
- if( pIt->second.first != Self::Real )
- return( TReal( 0 ) );
- return( TReal( std::atof( pIt->second.second.c_str( ) ) ) );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ if( i->second.first == Self::Real )
+ return( TReal( std::atof( i->second.second.second.c_str( ) ) ) );
+
+ } // fi
+ return( TReal( 0 ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetValueAsStringList(
- std::vector< TString >& lst, const TString& name
- ) const
+GetStringList( std::vector< TString >& lst, const TString& name ) const
{
lst.clear( );
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
return;
- if( pIt->second.first != Self::StringList )
+ if( i->second.first != Self::StringList )
return;
- std::istringstream ss( pIt->second.second );
+ std::istringstream str( i->second.second.second );
std::string token;
- while( std::getline( ss, token, '#' ) )
- if( token != "" )
- lst.push_back( token );
+ while( std::getline( str, token, '#' ) )
+ lst.push_back( token );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetValueAsBoolList( std::vector< TBool >& lst, const TString& name ) const
+GetBoolList( std::vector< TBool >& lst, const TString& name ) const
{
lst.clear( );
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
return;
- if( pIt->second.first != Self::BoolList )
+ if( i->second.first != Self::BoolList )
return;
- std::istringstream ss( pIt->second.second );
+ std::istringstream str( i->second.second.second );
std::string token;
- while( std::getline( ss, token, '#' ) )
- if( token != "" )
- lst.push_back( TBool( std::atoi( token.c_str( ) ) == 1 ) );
+ while( std::getline( str, token, '#' ) )
+ lst.push_back( std::atoi( token.c_str( ) ) == 1 );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetValueAsIntList( std::vector< TInt >& lst, const TString& name ) const
+GetIntList( std::vector< TInt >& lst, const TString& name ) const
{
lst.clear( );
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
return;
- if( pIt->second.first != Self::IntList )
+ if( i->second.first != Self::IntList )
return;
- std::istringstream ss( pIt->second.second );
+ std::istringstream str( i->second.second.second );
std::string token;
- while( std::getline( ss, token, '#' ) )
- if( token != "" )
- lst.push_back( TInt( std::atoi( token.c_str( ) ) ) );
+ while( std::getline( str, token, '#' ) )
+ lst.push_back( TInt( std::atoi( token.c_str( ) ) ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetValueAsUintList( std::vector< TUint >& lst, const TString& name ) const
+GetUintList( std::vector< TUint >& lst, const TString& name ) const
{
lst.clear( );
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
return;
- if( pIt->second.first != Self::UintList )
+ if( i->second.first != Self::UintList )
return;
- std::istringstream ss( pIt->second.second );
+ std::istringstream str( i->second.second.second );
std::string token;
- while( std::getline( ss, token, '#' ) )
- if( token != "" )
- lst.push_back( TUint( std::atoi( token.c_str( ) ) ) );
+ while( std::getline( str, token, '#' ) )
+ lst.push_back( TUint( std::atoi( token.c_str( ) ) ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetValueAsRealList( std::vector< TReal >& lst, const TString& name ) const
+GetRealList( std::vector< TReal >& lst, const TString& name ) const
{
lst.clear( );
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt == this->m_Parameters.end( ) )
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
return;
- if( pIt->second.first != Self::RealList )
+ if( i->second.first != Self::RealList )
return;
- std::istringstream ss( pIt->second.second );
+ std::istringstream str( i->second.second.second );
std::string token;
- while( std::getline( ss, token, '#' ) )
- if( token != "" )
- lst.push_back( TReal( std::atof( token.c_str( ) ) ) );
+ while( std::getline( str, token, '#' ) )
+ lst.push_back( TReal( std::atof( token.c_str( ) ) ) );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasStringValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::String );
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasBoolValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Bool );
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIntValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Int );
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasUintValue( const TString& name ) const
+void cpPlugins::Interface::Parameters::
+GetChoices( std::vector< TString >& choices, const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Uint );
- return( false );
-}
+ choices.clear( );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
+ return;
+ if( i->second.first != Self::Choices )
+ return;
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasRealValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Real );
- return( false );
+ std::istringstream str( i->second.second.first );
+ std::string token;
+ while( std::getline( str, token, '#' ) )
+ choices.push_back( token );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIndexValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+TString cpPlugins::Interface::Parameters::
+GetSelectedChoice( const TString& name ) const
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Index );
- return( false );
+ TParameters::const_iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
+ return( "" );
+ if( i->second.first != Self::Choices )
+ return( "" );
+ return( i->second.second.second );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasPointValue( const TString& name ) const
+void cpPlugins::Interface::Parameters::
+SetString( const TString& name, const TString& v )
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::Point );
- return( false );
-}
+ TParameters::iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
+ return;
+ if( i->second.first != Self::String )
+ return;
+ i->second.second.second = v;
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Set( Y ) \
+ void cpPlugins::Interface::Parameters:: \
+ Set##Y( const TString& name, const T##Y& v ) \
+ { \
+ TParameters::iterator i = this->m_Parameters.find( name ); \
+ if( i == this->m_Parameters.end( ) ) \
+ return; \
+ if( i->second.first != Self::Y ) \
+ return; \
+ std::stringstream str; \
+ str << v; \
+ i->second.second.second = str.str( ); \
+ this->Modified( ); \
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasStringListValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::StringList );
- return( false );
-}
+cpPlugins_Parameters_Set( Bool );
+cpPlugins_Parameters_Set( Int );
+cpPlugins_Parameters_Set( Uint );
+cpPlugins_Parameters_Set( Real );
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Add( Y ) \
+ void cpPlugins::Interface::Parameters:: \
+ AddTo##Y##List( const TString& name, const T##Y& v ) \
+ { \
+ TParameters::iterator i = this->m_Parameters.find( name ); \
+ if( i == this->m_Parameters.end( ) ) \
+ return; \
+ if( i->second.first != Self::Y##List ) \
+ return; \
+ std::stringstream str; \
+ if( i->second.second.second == "" ) \
+ str << v; \
+ else \
+ str << "#" << v; \
+ i->second.second.second += str.str( ); \
+ this->Modified( ); \
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasBoolListValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::BoolList );
- return( false );
-}
+cpPlugins_Parameters_Add( String );
+cpPlugins_Parameters_Add( Bool );
+cpPlugins_Parameters_Add( Int );
+cpPlugins_Parameters_Add( Uint );
+cpPlugins_Parameters_Add( Real );
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Clear( Y ) \
+ void cpPlugins::Interface::Parameters:: \
+ Clear##Y##List( const TString& name ) \
+ { \
+ TParameters::iterator i = this->m_Parameters.find( name ); \
+ if( i == this->m_Parameters.end( ) ) \
+ return; \
+ if( i->second.first != Self::Y##List ) \
+ return; \
+ i->second.second.second = ""; \
+ this->Modified( ); \
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIntListValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::IntList );
- return( false );
-}
+cpPlugins_Parameters_Clear( String );
+cpPlugins_Parameters_Clear( Bool );
+cpPlugins_Parameters_Clear( Int );
+cpPlugins_Parameters_Clear( Uint );
+cpPlugins_Parameters_Clear( Real );
+cpPlugins_Parameters_Clear( Index );
+cpPlugins_Parameters_Clear( Point );
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Parameters::
-HasUintListValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::UintList );
- return( false );
+SetSelectedChoice( const TString& name, const TString& choice )
+{
+ TParameters::iterator i = this->m_Parameters.find( name );
+ if( i == this->m_Parameters.end( ) )
+ return( false );
+ if( i->second.first != Self::Choices )
+ return( false );
+ if( i->second.second.first.find( choice ) != std::string::npos )
+ {
+ i->second.second.second = choice;
+ this->Modified( );
+ return( true );
+ }
+ else
+ return( false );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasRealListValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+Parameters( )
+ : Superclass( ),
+ m_Process( NULL )
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::RealList );
- return( false );
+ this->Clear( );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIndexListValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+~Parameters( )
{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::IndexList );
- return( false );
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasPointListValue( const TString& name ) const
-{
- TParameters::const_iterator pIt = this->m_Parameters.find( name );
- if( pIt != this->m_Parameters.end( ) )
- return( pIt->second.first == Self::PointList );
- return( false );
+void cpPlugins::Interface::Parameters::
+PrintSelf( std::ostream& os, itk::Indent indent ) const
+{
+ TParameters::const_iterator i = this->m_Parameters.begin( );
+ for( ; i != this->m_Parameters.end( ); ++i )
+ os << indent
+ << i->first << ": ("
+ << i->second.first << " | "
+ << i->second.second.first << " | "
+ << i->second.second.second << ")"
+ << std::endl;
}
// eof - $RCSfile$