1 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
2 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
4 // -------------------------------------------------------------------------
6 void cpPlugins::Interface::Parameters::
7 ConfigureAsIndex( const TString& name, const TUint& dim, const I& v )
11 for( unsigned int d = 1; d < dim; ++d )
13 std::string s = str.str( );
14 this->m_Parameters[ name ] =
15 TParameter( Self::Index, TValues( s, s ) );
19 // -------------------------------------------------------------------------
21 void cpPlugins::Interface::Parameters::
22 ConfigureAsPoint( const TString& name, const TUint& dim, const P& v )
24 std::stringstream str;
26 for( unsigned int d = 1; d < dim; ++d )
28 std::string s = str.str( );
29 this->m_Parameters[ name ] =
30 TParameter( Self::Point, TValues( s, s ) );
34 // -------------------------------------------------------------------------
36 I cpPlugins::Interface::Parameters::
37 GetIndex( const TString& name, const TUint& dim ) const
40 TParameters::const_iterator i = this->m_Parameters.find( name );
41 if( i != this->m_Parameters.end( ) )
43 if( i->second.first == Self::Index )
45 std::istringstream str( i->second.second.second );
48 while( std::getline( str, token, ';' ) && d < dim )
50 v[ d ] = std::atoi( token.c_str( ) );
60 // If parameter not found
61 for( unsigned int d = 0; d < dim; ++d )
66 // -------------------------------------------------------------------------
68 P cpPlugins::Interface::Parameters::
69 GetPoint( const TString& name, const TUint& dim ) const
72 TParameters::const_iterator i = this->m_Parameters.find( name );
73 if( i != this->m_Parameters.end( ) )
75 if( i->second.first == Self::Point )
77 std::istringstream str( i->second.second.second );
80 while( std::getline( str, token, ';' ) && d < dim )
82 v[ d ] = std::atof( token.c_str( ) );
92 // If parameter not found
93 for( unsigned int d = 0; d < dim; ++d )
98 // -------------------------------------------------------------------------
100 void cpPlugins::Interface::Parameters::
102 std::vector< I >& lst, const TString& name, const TUint& dim
107 TParameters::const_iterator i = this->m_Parameters.find( name );
108 if( i == this->m_Parameters.end( ) )
110 if( i->second.first == Self::IndexList )
113 std::istringstream str( i->second.second.second );
116 while( std::getline( str, token, '#' ) )
118 std::istringstream str2( token );
122 while( std::getline( str2, token2, ';' ) && d < dim )
124 v[ d ] = std::atoi( token.c_str( ) );
133 // -------------------------------------------------------------------------
135 void cpPlugins::Interface::Parameters::
137 std::vector< P >& lst, const TString& name, const TUint& dim
142 TParameters::const_iterator i = this->m_Parameters.find( name );
143 if( i == this->m_Parameters.end( ) )
145 if( i->second.first == Self::PointList )
148 std::istringstream str( i->second.second.second );
151 while( std::getline( str, token, '#' ) )
153 std::istringstream str2( token );
157 while( std::getline( str2, token2, ';' ) && d < dim )
159 v[ d ] = std::atof( token.c_str( ) );
168 // -------------------------------------------------------------------------
170 void cpPlugins::Interface::Parameters::
171 SetIndex( const TString& name, const TUint& dim, const I& v )
173 TParameters::iterator i = this->m_Parameters.find( name );
174 if( i == this->m_Parameters.end( ) )
176 if( i->second.first != Self::Index )
179 std::stringstream str;
181 for( unsigned int d = 1; d < dim; ++d )
182 str << ";" << v[ d ];
183 i->second.second.second = str.str( );
187 // -------------------------------------------------------------------------
189 void cpPlugins::Interface::Parameters::
190 SetPoint( const TString& name, const TUint& dim, const P& v )
192 TParameters::iterator i = this->m_Parameters.find( name );
193 if( i == this->m_Parameters.end( ) )
195 if( i->second.first != Self::Point )
198 std::stringstream str;
200 for( unsigned int d = 1; d < dim; ++d )
201 str << ";" << v[ d ];
202 i->second.second.second = str.str( );
206 // -------------------------------------------------------------------------
208 void cpPlugins::Interface::Parameters::
209 AddToIndexList( const TString& name, const TUint& dim, const I& v )
211 TParameters::iterator i = this->m_Parameters.find( name );
212 if( i == this->m_Parameters.end( ) )
214 if( i->second.first != Self::IndexList )
217 std::stringstream str;
218 if( i->second.second.second == "" )
221 str << "#" << v[ 0 ];
222 for( unsigned int d = 1; d < dim; ++d )
223 str << ";" << v[ d ];
224 i->second.second.second += str.str( );
228 // -------------------------------------------------------------------------
230 void cpPlugins::Interface::Parameters::
231 AddToPointList( const TString& name, const TUint& dim, const P& v )
233 TParameters::iterator i = this->m_Parameters.find( name );
234 if( i == this->m_Parameters.end( ) )
236 if( i->second.first != Self::PointList )
239 std::stringstream str;
240 if( i->second.second.second == "" )
243 str << "#" << v[ 0 ];
244 for( unsigned int d = 1; d < dim; ++d )
245 str << ";" << v[ d ];
246 i->second.second.second += str.str( );
250 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__