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 void cpPlugins::Interface::Parameters::
37 ConfigureAsVector( const TString& name, const TUint& dim, const V& v )
39 std::stringstream str;
41 for( unsigned int d = 1; d < dim; ++d )
43 std::string s = str.str( );
44 this->m_Parameters[ name ] =
45 TParameter( Self::Vector, TValues( s, s ) );
49 // -------------------------------------------------------------------------
51 I cpPlugins::Interface::Parameters::
52 GetIndex( const TString& name, const TUint& dim ) const
55 TParameters::const_iterator i = this->m_Parameters.find( name );
56 if( i != this->m_Parameters.end( ) )
58 if( i->second.first == Self::Index )
60 std::istringstream str( i->second.second.second );
63 while( std::getline( str, token, ';' ) && d < dim )
65 v[ d ] = std::atoi( token.c_str( ) );
75 // If parameter not found
76 for( unsigned int d = 0; d < dim; ++d )
81 // -------------------------------------------------------------------------
83 P cpPlugins::Interface::Parameters::
84 GetPoint( const TString& name, const TUint& dim ) const
87 TParameters::const_iterator i = this->m_Parameters.find( name );
88 if( i != this->m_Parameters.end( ) )
90 if( i->second.first == Self::Point )
92 std::istringstream str( i->second.second.second );
95 while( std::getline( str, token, ';' ) && d < dim )
97 v[ d ] = std::atof( token.c_str( ) );
107 // If parameter not found
108 for( unsigned int d = 0; d < dim; ++d )
113 // -------------------------------------------------------------------------
115 V cpPlugins::Interface::Parameters::
116 GetVector( const TString& name, const TUint& dim ) const
119 TParameters::const_iterator i = this->m_Parameters.find( name );
120 if( i != this->m_Parameters.end( ) )
122 if( i->second.first == Self::Vector )
124 std::istringstream str( i->second.second.second );
127 while( std::getline( str, token, ';' ) && d < dim )
129 v[ d ] = std::atof( token.c_str( ) );
139 // If parameter not found
140 for( unsigned int d = 0; d < dim; ++d )
145 // -------------------------------------------------------------------------
147 void cpPlugins::Interface::Parameters::
149 std::vector< I >& lst, const TString& name, const TUint& dim
154 TParameters::const_iterator i = this->m_Parameters.find( name );
155 if( i == this->m_Parameters.end( ) )
157 if( i->second.first == Self::IndexList )
160 std::istringstream str( i->second.second.second );
163 while( std::getline( str, token, '#' ) )
165 std::istringstream str2( token );
169 while( std::getline( str2, token2, ';' ) && d < dim )
171 v[ d ] = std::atoi( token.c_str( ) );
180 // -------------------------------------------------------------------------
182 void cpPlugins::Interface::Parameters::
184 std::vector< P >& lst, const TString& name, const TUint& dim
189 TParameters::const_iterator i = this->m_Parameters.find( name );
190 if( i == this->m_Parameters.end( ) )
192 if( i->second.first == Self::PointList )
195 std::istringstream str( i->second.second.second );
198 while( std::getline( str, token, '#' ) )
200 std::istringstream str2( token );
204 while( std::getline( str2, token2, ';' ) && d < dim )
206 v[ d ] = std::atof( token.c_str( ) );
215 // -------------------------------------------------------------------------
217 void cpPlugins::Interface::Parameters::
219 std::vector< V >& lst, const TString& name, const TUint& dim
224 TParameters::const_iterator i = this->m_Parameters.find( name );
225 if( i == this->m_Parameters.end( ) )
227 if( i->second.first == Self::VectorList )
230 std::istringstream str( i->second.second.second );
233 while( std::getline( str, token, '#' ) )
235 std::istringstream str2( token );
239 while( std::getline( str2, token2, ';' ) && d < dim )
241 v[ d ] = std::atof( token.c_str( ) );
250 // -------------------------------------------------------------------------
252 void cpPlugins::Interface::Parameters::
253 SetIndex( const TString& name, const TUint& dim, const I& v )
255 TParameters::iterator i = this->m_Parameters.find( name );
256 if( i == this->m_Parameters.end( ) )
258 if( i->second.first != Self::Index )
261 std::stringstream str;
263 for( unsigned int d = 1; d < dim; ++d )
264 str << ";" << v[ d ];
265 i->second.second.second = str.str( );
269 // -------------------------------------------------------------------------
271 void cpPlugins::Interface::Parameters::
272 SetPoint( const TString& name, const TUint& dim, const P& v )
274 TParameters::iterator i = this->m_Parameters.find( name );
275 if( i == this->m_Parameters.end( ) )
277 if( i->second.first != Self::Point )
280 std::stringstream str;
282 for( unsigned int d = 1; d < dim; ++d )
283 str << ";" << v[ d ];
284 i->second.second.second = str.str( );
288 // -------------------------------------------------------------------------
290 void cpPlugins::Interface::Parameters::
291 SetVector( const TString& name, const TUint& dim, const V& v )
293 TParameters::iterator i = this->m_Parameters.find( name );
294 if( i == this->m_Parameters.end( ) )
296 if( i->second.first != Self::Vector )
299 std::stringstream str;
301 for( unsigned int d = 1; d < dim; ++d )
302 str << ";" << v[ d ];
303 i->second.second.second = str.str( );
307 // -------------------------------------------------------------------------
309 void cpPlugins::Interface::Parameters::
310 AddToIndexList( const TString& name, const TUint& dim, const I& v )
312 TParameters::iterator i = this->m_Parameters.find( name );
313 if( i == this->m_Parameters.end( ) )
315 if( i->second.first != Self::IndexList )
318 std::stringstream str;
319 if( i->second.second.second == "" )
322 str << "#" << v[ 0 ];
323 for( unsigned int d = 1; d < dim; ++d )
324 str << ";" << v[ d ];
325 i->second.second.second += str.str( );
329 // -------------------------------------------------------------------------
331 void cpPlugins::Interface::Parameters::
332 AddToPointList( const TString& name, const TUint& dim, const P& v )
334 TParameters::iterator i = this->m_Parameters.find( name );
335 if( i == this->m_Parameters.end( ) )
337 if( i->second.first != Self::PointList )
340 std::stringstream str;
341 if( i->second.second.second == "" )
344 str << "#" << v[ 0 ];
345 for( unsigned int d = 1; d < dim; ++d )
346 str << ";" << v[ d ];
347 i->second.second.second += str.str( );
351 // -------------------------------------------------------------------------
353 void cpPlugins::Interface::Parameters::
354 AddToVectorList( const TString& name, const TUint& dim, const V& v )
356 TParameters::iterator i = this->m_Parameters.find( name );
357 if( i == this->m_Parameters.end( ) )
359 if( i->second.first != Self::VectorList )
362 std::stringstream str;
363 if( i->second.second.second == "" )
366 str << "#" << v[ 0 ];
367 for( unsigned int d = 1; d < dim; ++d )
368 str << ";" << v[ d ];
369 i->second.second.second += str.str( );
373 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__