]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Parameters.hxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.hxx
index b633f879f5e33b70b0a3064e259ca0c754849b4d..eecb2b6b08ebb74d201324a7cd79ec6039e685a1 100644 (file)
@@ -1,63 +1,18 @@
 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-ConfigureAsIndex( const TString& name, const TUint& dim, const I& v )
-{
-  std::stringstream str;
-  str << v[ 0 ];
-  for( unsigned int d = 1; d < dim; ++d )
-    str << ";" << v[ d ];
-  std::string s = str.str( );
-  this->m_Parameters[ name ] =
-    TParameter( Self::Index, TValues( s, s ) );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::Parameters::
-ConfigureAsPoint( const TString& name, const TUint& dim, const P& v )
-{
-  std::stringstream str;
-  str << v[ 0 ];
-  for( unsigned int d = 1; d < dim; ++d )
-    str << ";" << v[ d ];
-  std::string s = str.str( );
-  this->m_Parameters[ name ] =
-    TParameter( Self::Point, TValues( s, s ) );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-void cpPlugins::Interface::Parameters::
-ConfigureAsVector( const TString& name, const TUint& dim, const V& v )
-{
-  std::stringstream str;
-  str << v[ 0 ];
-  for( unsigned int d = 1; d < dim; ++d )
-    str << ";" << v[ d ];
-  std::string s = str.str( );
-  this->m_Parameters[ name ] =
-    TParameter( Self::Vector, TValues( s, s ) );
-  this->Modified( );
-}
-
 // -------------------------------------------------------------------------
 template< class I >
 I cpPlugins::Interface::Parameters::
-GetIndex( const TString& name, const TUint& dim ) const
+GetIndex( const std::string& name, const unsigned int& dim ) const
 {
   I v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Index )
     {
-      std::istringstream str( i->second.second.second );
+      std::istringstream str( i->second.second );
       std::string token;
       unsigned int d = 0;
       while( std::getline( str, token, ';' ) && d < dim )
@@ -81,15 +36,15 @@ GetIndex( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class P >
 P cpPlugins::Interface::Parameters::
-GetPoint( const TString& name, const TUint& dim ) const
+GetPoint( const std::string& name, const unsigned int& dim ) const
 {
   P v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Point )
     {
-      std::istringstream str( i->second.second.second );
+      std::istringstream str( i->second.second );
       std::string token;
       unsigned int d = 0;
       while( std::getline( str, token, ';' ) && d < dim )
@@ -114,15 +69,15 @@ GetPoint( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class V >
 V cpPlugins::Interface::Parameters::
-GetVector( const TString& name, const TUint& dim ) const
+GetVector( const std::string& name, const unsigned int& dim ) const
 {
   V v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Vector )
     {
-      std::istringstream str( i->second.second.second );
+      std::istringstream str( i->second.second );
       std::string token;
       unsigned int d = 0;
       while( std::getline( str, token, ';' ) && d < dim )
@@ -147,114 +102,7 @@ GetVector( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class I >
 void cpPlugins::Interface::Parameters::
-GetIndexList(
-  std::vector< I >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::IndexList )
-    return;
-
-  std::istringstream str( i->second.second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    I v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      v[ d ] = std::atoi( token.c_str( ) );
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::Parameters::
-GetPointList(
-  std::vector< P >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::PointList )
-    return;
-
-  std::istringstream str( i->second.second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    P v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      std::istringstream tok_str( token );
-      tok_str >> v[ d ];
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-void cpPlugins::Interface::Parameters::
-GetVectorList(
-  std::vector< V >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::VectorList )
-    return;
-
-  std::istringstream str( i->second.second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    V v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      std::istringstream tok_str( token );
-      tok_str >> v[ d ];
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetIndex( const TString& name, const TUint& dim, const I& v )
+SetIndex( const std::string& name, const unsigned int& dim, const I& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -266,14 +114,14 @@ SetIndex( const TString& name, const TUint& dim, const I& v )
   str << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second = str.str( );
+  i->second.second = str.str( );
   this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-SetPoint( const TString& name, const TUint& dim, const P& v )
+SetPoint( const std::string& name, const unsigned int& dim, const P& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -285,14 +133,14 @@ SetPoint( const TString& name, const TUint& dim, const P& v )
   str << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second = str.str( );
+  i->second.second = str.str( );
   this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 template< class V >
 void cpPlugins::Interface::Parameters::
-SetVector( const TString& name, const TUint& dim, const V& v )
+SetVector( const std::string& name, const unsigned int& dim, const V& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -304,14 +152,126 @@ SetVector( const TString& name, const TUint& dim, const V& v )
   str << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second = str.str( );
+  i->second.second = str.str( );
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+template< class I >
+std::vector< I > cpPlugins::Interface::Parameters::
+GetIndexList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< I > lst;
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::IndexList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        I v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          v[ d ] = std::atoi( token.c_str( ) );
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+std::vector< P > cpPlugins::Interface::Parameters::
+GetPointList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< P > lst;
+
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::PointList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        P v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          std::istringstream tok_str( token );
+          tok_str >> v[ d ];
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
+// -------------------------------------------------------------------------
+template< class V >
+std::vector< V > cpPlugins::Interface::Parameters::
+GetVectorList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< V > lst;
+
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::VectorList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        V v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          std::istringstream tok_str( token );
+          tok_str >> v[ d ];
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
 // -------------------------------------------------------------------------
 template< class I >
 void cpPlugins::Interface::Parameters::
-AddToIndexList( const TString& name, const TUint& dim, const I& v )
+AddToIndexList( const std::string& name, const unsigned int& dim, const I& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -320,20 +280,20 @@ AddToIndexList( const TString& name, const TUint& dim, const I& v )
     return;
 
   std::stringstream str;
-  if( i->second.second.second == "" )
+  if( i->second.second == "" )
     str << v[ 0 ];
   else
     str << "#" << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second += str.str( );
+  i->second.second += str.str( );
   this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-AddToPointList( const TString& name, const TUint& dim, const P& v )
+AddToPointList( const std::string& name, const unsigned int& dim, const P& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -342,20 +302,20 @@ AddToPointList( const TString& name, const TUint& dim, const P& v )
     return;
 
   std::stringstream str;
-  if( i->second.second.second == "" )
+  if( i->second.second == "" )
     str << v[ 0 ];
   else
     str << "#" << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second += str.str( );
+  i->second.second += str.str( );
   this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 template< class V >
 void cpPlugins::Interface::Parameters::
-AddToVectorList( const TString& name, const TUint& dim, const V& v )
+AddToVectorList( const std::string& name, const unsigned int& dim, const V& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -364,13 +324,13 @@ AddToVectorList( const TString& name, const TUint& dim, const V& v )
     return;
 
   std::stringstream str;
-  if( i->second.second.second == "" )
+  if( i->second.second == "" )
     str << v[ 0 ];
   else
     str << "#" << v[ 0 ];
   for( unsigned int d = 1; d < dim; ++d )
     str << ";" << v[ d ];
-  i->second.second.second += str.str( );
+  i->second.second += str.str( );
   this->Modified( );
 }