]> Creatis software - cpPlugins.git/commitdiff
More on parameters simplification
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 31 Dec 2014 10:06:29 +0000 (11:06 +0100)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 31 Dec 2014 10:06:29 +0000 (11:06 +0100)
18 files changed:
lib/cpPlugins/Interface/FilterObject.h
lib/cpPlugins/Interface/ImageSink.h
lib/cpPlugins/Interface/ImageSource.h
lib/cpPlugins/Interface/ImageToImageFilter.h
lib/cpPlugins/Interface/ImageToMeshFilter.h
lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h
lib/cpPlugins/Interface/MeshSink.h
lib/cpPlugins/Interface/MeshSource.h
lib/cpPlugins/Interface/MeshToImageFilter.h
lib/cpPlugins/Interface/MeshToMeshFilter.h
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/Parameters.hxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/SinkObject.h
lib/cpPlugins/Interface/SourceObject.h
lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h

index 9f526c48d5167761dec85d04f5c23c60325890cb..9718d76553271737cc2f6e687f683c99646d5b8d 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( FilterObject, ProcessObject );
 
index 3895e210dedaf5db6a6b55f944485d0d92885d22..526a46604b42bede6332b362e893c7f9104affb5 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( ImageSink, SinkObject );
 
index 2e8b80cb6d069349765fd49c61ee1b4618644f8b..56004bf5c7e6c0e91cef7f9872069c6e6254825b 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( ImageSource, SourceObject );
 
index d7ac57a14000f6013319191840cf2f30d9a48cfa..5da8bf2cb9a794224dc4fcdc09cfac1638dad050 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( ImageToImageFilter, FilterObject );
 
index 472f47a0ccb9e3bdcc5211a1a269fa71289b98ad..70dc9a207ae7768a4b45df0a32d09076af311673 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( ImageToMeshFilter, FilterObject );
 
index 1b274cc631e409796a23d395549f438ff4c4009e..716bfadf78bca069f3e37188bbb06df49c805b78 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >           Pointer;
       typedef itk::SmartPointer< const Self >     ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( ImageToPolyLineParametricPathFilter, FilterObject );
 
index b110cb3907652df783161c3ff4f2c1b67f455365..5eab768db00c6f9d43b6c6d463043eda4be2627d 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( MeshSink, SinkObject );
 
index 9c5c3d299850380fd7fa0db01ec489523e3919eb..745f62d0786337bead6e23e9793d9272e539b7c6 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( MeshSource, SourceObject );
 
index b6447d2042cfa2d9ed9d436c354cd509bbf941d6..e8f0b830f77ddd229698ed2f0258d2a8d683993d 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( MeshToImageFilter, FilterObject );
 
index 7121c0e7776b8467a648cda04b8adc3079d7907c..d47197f63126eb876059d0034cf0021c65b5791a 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( MeshToMeshFilter, FilterObject );
 
index dd8cece79b4c21699b590c64b2d9512a3f71fc39..c51cde6cb51f1a7136bbcdcd1a1078d801305386 100644 (file)
@@ -3,6 +3,48 @@
 #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( 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, long );
+cpPlugins_Interface_Parameters_SetArrayMacro( Point, double );
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 Parameters( )
@@ -35,116 +77,40 @@ operator=( const Self& other )
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-Configure( const Self::Type& type, const std::string& name )
+Configure( const Self::Type& type, const TString& name )
 {
   this->m_Parameters[ name ] = TParameter( type, "" );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsString( const std::string& name, const std::string& v )
-{
-  TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return;
-  if( pIt->second.first != Self::String )
-    return;
-
-  pIt->second.second = v;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsInt( const std::string& name, const TInt& v )
-{
-  TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return;
-  if( pIt->second.first != Self::Int )
-    return;
-
-  std::stringstream ss;
-  ss << v;
-  pIt->second.second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsUint( const std::string& name, const TUint& v )
-{
-  TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return;
-  if( pIt->second.first != Self::Uint )
-    return;
-
-  std::stringstream ss;
-  ss << v;
-  pIt->second.second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsReal( const std::string& name, const TReal& v )
-{
-  TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return;
-  if( pIt->second.first != Self::Real )
-    return;
-
-  std::stringstream ss;
-  ss << v;
-  pIt->second.second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsIndex( const std::string& name, const TUint& n, ... )
+std::vector< cpPlugins::Interface::Parameters::TString >
+cpPlugins::Interface::Parameters::
+GetParameters( ) const
 {
-  TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return;
-  if( pIt->second.first != Self::Index )
-    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, long ) << ":";
-  va_end( v_lst );
-
-  pIt->second.second = ss.str( );
+  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 );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetValueAsPoint( const std::string& name, const TUint& n, ... )
+cpPlugins::Interface::Parameters::
+Type cpPlugins::Interface::Parameters::
+GetParameterType( const TString& name ) const
 {
-  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::Point )
-    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, double ) << ":";
-  va_end( v_lst );
-
-  pIt->second.second = ss.str( );
+    return( Self::NoType );
+  return( pIt->second.first );
 }
 
 // -------------------------------------------------------------------------
-const std::string& cpPlugins::Interface::Parameters::
-GetValueAsString( const std::string& name ) const
+const cpPlugins::Interface::Parameters::
+TString& cpPlugins::Interface::Parameters::
+GetValueAsString( const TString& name ) const
 {
-  static const std::string null_str = "";
+  static const TString null_str = "";
   TParameters::const_iterator pIt = this->m_Parameters.find( name );
   if( pIt == this->m_Parameters.end( ) )
     return( null_str );
@@ -157,71 +123,65 @@ GetValueAsString( const std::string& name ) const
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TInt cpPlugins::Interface::Parameters::
-GetValueAsInt( const std::string& name ) const
+GetValueAsInt( const TString& name ) const
 {
-  static const std::string null_str = "";
   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( std::atoi( pIt->second.second.c_str( ) ) );
+  return( TInt( std::atoi( pIt->second.second.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TUint cpPlugins::Interface::Parameters::
-GetValueAsUint( const std::string& name ) const
+GetValueAsUint( const TString& name ) const
 {
-  static const std::string null_str = "";
   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( std::atoi( pIt->second.second.c_str( ) ) );
+  return( TUint( std::atoi( pIt->second.second.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TReal cpPlugins::Interface::Parameters::
-GetValueAsReal( const std::string& name ) const
+GetValueAsReal( const TString& name ) const
 {
-  static const std::string null_str = "";
   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( std::atof( pIt->second.second.c_str( ) ) );
+  return( TReal( std::atof( pIt->second.second.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
 GetValueAsStringList(
-  std::vector< std::string >& lst, const std::string& name
+  std::vector< TString >& lst, const TString& name
   ) const
 {
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsIntList( std::vector< TInt >& lst, const std::string& name ) const
+GetValueAsIntList( std::vector< TInt >& lst, const TString& name ) const
 {
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsUintList( std::vector< TUint >& lst, const std::string& name ) const
+GetValueAsUintList( std::vector< TUint >& lst, const TString& name ) const
 {
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsRealList( std::vector< TReal >& lst, const std::string& name ) const
+GetValueAsRealList( std::vector< TReal >& lst, const TString& name ) const
 {
 }
 
index a806ee7bdfdd82d42188b35f729703f558f12b72..7a7578a951258e269984f8ae6d24017085145e98 100644 (file)
@@ -29,14 +29,17 @@ namespace cpPlugins
         UintList,
         RealList,
         IndexList,
-        PointList
+        PointList,
+        NoType
       };
 
-      typedef std::pair< Self::Type, std::string > TParameter;
-      typedef std::map< std::string, TParameter >   TParameters;
       typedef long          TInt;
       typedef unsigned long TUint;
       typedef double        TReal;
+      typedef std::string   TString;
+
+      typedef std::pair< Self::Type, TString > TParameter;
+      typedef std::map< TString, TParameter >  TParameters;
 
     public:
       Parameters( );
@@ -45,76 +48,78 @@ namespace cpPlugins
 
       Self& operator=( const Self& other );
 
-      void Configure( const Self::Type& type, const std::string& name );
-      void SetValueAsString( const std::string& name, const std::string& v );
-      void SetValueAsInt( const std::string& name, const TInt& v );
-      void SetValueAsUint( const std::string& name, const TUint& v );
-      void SetValueAsReal( const std::string& name, const TReal& v );
-      void SetValueAsIndex( const std::string& name, const TUint& n, ... );
-      void SetValueAsPoint( const std::string& name, const TUint& n, ... );
+      void Configure( const Self::Type& type, const TString& name );
+      void SetValueAsString( const TString& name, const TString& v );
+      void SetValueAsInt( const TString& name, const TInt& v );
+      void SetValueAsUint( const TString& name, const TUint& v );
+      void SetValueAsReal( const TString& name, const TReal& v );
+      void SetValueAsIndex( const TString& name, const TUint& n, ... );
+      void SetValueAsPoint( const TString& name, const TUint& n, ... );
 
       template< class I >
       void SetValueAsStringList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
       template< class I >
       void SetValueAsIntList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
       template< class I >
       void SetValueAsUintList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
       template< class I >
       void SetValueAsRealList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
       template< class I >
       void SetValueAsIndexList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
       template< class I >
       void SetValueAsPointList(
-        const std::string& name, const I& b, const I& e
+        const TString& name, const I& b, const I& e
         );
 
-      const std::string& GetValueAsString( const std::string& name ) const;
-      TInt GetValueAsInt( const std::string& name ) const;
-      TUint GetValueAsUint( const std::string& name ) const;
-      TReal GetValueAsReal( const std::string& name ) const;
+      std::vector< TString > GetParameters( ) const;
+      Self::Type GetParameterType( const TString& name ) const;
+      const TString& GetValueAsString( const TString& name ) const;
+      TInt GetValueAsInt( const TString& name ) const;
+      TUint GetValueAsUint( const TString& name ) const;
+      TReal GetValueAsReal( const TString& name ) const;
 
       template< class I >
-      I GetValueAsIndex( const std::string& name ) const;
+      I GetValueAsIndex( const TString& name ) const;
 
       template< class P >
-      P GetValueAsPoint( const std::string& name ) const;
+      P GetValueAsPoint( const TString& name ) const;
 
       void GetValueAsStringList(
-        std::vector< std::string >& lst, const std::string& name
+        std::vector< TString >& lst, const TString& name
         ) const;
       void GetValueAsIntList(
-        std::vector< TInt >& lst, const std::string& name
+        std::vector< TInt >& lst, const TString& name
         ) const;
       void GetValueAsUintList(
-        std::vector< TUint >& lst, const std::string& name
+        std::vector< TUint >& lst, const TString& name
         ) const;
       void GetValueAsRealList(
-        std::vector< TReal >& lst, const std::string& name
+        std::vector< TReal >& lst, const TString& name
         ) const;
 
       template< class I >
       void GetValueAsIndexList(
-        std::vector< I >& lst, const std::string& name
+        std::vector< I >& lst, const TString& name
         ) const;
 
       template< class P >
       void GetValueAsPointList(
-        std::vector< P >& lst, const std::string& name
+        std::vector< P >& lst, const TString& name
         ) const;
 
 
index ac30bc9648e8c4344cbbda8aefb2c960dd7a95d8..f0c3a27e8d99b0ab17e95af7a02f33fc35a946e6 100644 (file)
 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 
+#include <cstdlib>
 #include <sstream>
 
 // -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsStringList( const std::string& 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::StringList )
-    return;
-
-  std::stringstream ss;
-  for( I i = b; i != e; ++i )
-    ss << *i << ":";
-  pIt->second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsIntList( const std::string& 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::IntList )
-    return;
-
-  std::stringstream ss;
-  for( I i = b; i != e; ++i )
-    ss << *i << ":";
-  pIt->second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsUintList( const std::string& 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::UintList )
-    return;
-
-  std::stringstream ss;
-  for( I i = b; i != e; ++i )
-    ss << *i << ":";
-  pIt->second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsRealList( const std::string& 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::RealList )
-    return;
-
-  std::stringstream ss;
-  for( I i = b; i != e; ++i )
-    ss << *i << ":";
-  pIt->second = ss.str( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsIndexList( const std::string& name, const I& b, const I& e )
-{
-  // TODO
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetValueAsPointList( const std::string& name, const I& b, const I& e )
-{
-  // TODO
-}
+#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 std::string& name ) const
+GetValueAsIndex( const TString& name ) const
 {
+  I idx;
   TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( I( ) );
-  if( pIt->second.first != Self::Index )
-    return( I( ) );
-
-  // TODO:
-  return( I( ) );
+  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 std::string& name ) const
+GetValueAsPoint( const TString& name ) const
 {
+  P pnt;
   TParameters::iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( P( ) );
-  if( pIt->second.first != Self::Point )
-    return( P( ) );
-
-  // TODO:
-  return( P( ) );
+  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 std::string& name ) const
+GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const
 {
   lst.clear( );
   TParameters::iterator pIt = this->m_Parameters.find( name );
@@ -135,7 +100,7 @@ GetValueAsIndexList( std::vector< I >& lst, const std::string& name ) const
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-GetValueAsPointList( std::vector< P >& lst, const std::string& name ) const
+GetValueAsPointList( std::vector< P >& lst, const TString& name ) const
 {
   lst.clear( );
   TParameters::iterator pIt = this->m_Parameters.find( name );
index e05e7a818de734f54f3f257e8cfb296a319bf0ad..61eaf96e661763080ed48470bfabf069bca4e8b5 100644 (file)
@@ -15,8 +15,8 @@ GetClassType( ) const
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::ProcessObject::
-TParameters& cpPlugins::Interface::ProcessObject::
+const cpPlugins::Interface::Parameters&
+cpPlugins::Interface::ProcessObject::
 GetDefaultParameters( ) const
 {
   return( this->m_DefaultParameters );
@@ -24,7 +24,7 @@ GetDefaultParameters( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+SetParameters( const cpPlugins::Interface::Parameters& params )
 {
   this->m_Parameters = params;
   this->Modified( );
index f4c80ae21a7fcf712406b4adc88e3a2f23f47603..a9779282c8a59e37973504e1ec04730a4bf2a5ae 100644 (file)
@@ -1,12 +1,11 @@
 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
-#include <map>
-#include <string>
 #include <itkProcessObject.h>
 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Object.h>
 #include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/Parameters.h>
 
 namespace cpPlugins
 {
@@ -23,17 +22,14 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef std::pair< std::string, std::string > TParameter;
-      typedef std::map< std::string, TParameter >   TParameters;
-
     public:
       itkTypeMacro( ProcessObject, Object );
 
     public:
       virtual std::string GetClassName( ) const;
       virtual std::string GetClassType( ) const;
-      virtual const TParameters& GetDefaultParameters( ) const;
-      virtual void SetParameters( const TParameters& params );
+      virtual const Parameters& GetDefaultParameters( ) const;
+      virtual void SetParameters( const Parameters& params );
 
       virtual unsigned int GetNumberOfInputs( ) const;
       virtual unsigned int GetNumberOfOutputs( ) const;
@@ -72,8 +68,8 @@ namespace cpPlugins
 
     protected:
       itk::ProcessObject::Pointer m_RealProcessObject;
-      TParameters m_DefaultParameters;
-      TParameters m_Parameters;
+      Parameters m_DefaultParameters;
+      Parameters m_Parameters;
 
       std::vector< DataObject::Pointer > m_Inputs;
       std::vector< DataObject::Pointer > m_Outputs;
index 52723d13d75dbb61163df3c11b269fac61c46b08..4edc44c813cf465cf1248ae03adc89426d1e6bf3 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( SinkObject, ProcessObject );
 
index 0c036ce68947de9106e2dcc2d2b8981f06fc76f8..ecb528ccbba61b8fd8e1dca28c09e4f75b69ed82 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkTypeMacro( SourceObject, ProcessObject );
 
index d9fe353a84ec9e1f9a08621d762988ce4d5bce06..2f61c3e20b9680a1cec44bba08451782527f5231 100644 (file)
@@ -19,9 +19,6 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >                Pointer;
       typedef itk::SmartPointer< const Self >          ConstPointer;
 
-      typedef Superclass::TParameter  TParameter;
-      typedef Superclass::TParameters TParameters;
-
     public:
       itkNewMacro( Self );
       itkTypeMacro(
@@ -39,10 +36,10 @@ namespace cpPlugins
       virtual std::string _GenerateData( );
 
       template< unsigned int D >
-      std::string _GD0( );
+        std::string _GD0( );
 
       template< class P, unsigned int D >
-      std::string _GD1( );
+        std::string _GD1( );
 
     private:
       // Purposely not implemented