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 std::istringstream tok_str( token );
108 // If parameter not found
109 for( unsigned int d = 0; d < dim; ++d )
114 // -------------------------------------------------------------------------
116 V cpPlugins::Interface::Parameters::
117 GetVector( const TString& name, const TUint& dim ) const
120 TParameters::const_iterator i = this->m_Parameters.find( name );
121 if( i != this->m_Parameters.end( ) )
123 if( i->second.first == Self::Vector )
125 std::istringstream str( i->second.second.second );
128 while( std::getline( str, token, ';' ) && d < dim )
130 std::istringstream tok_str( token );
141 // If parameter not found
142 for( unsigned int d = 0; d < dim; ++d )
147 // -------------------------------------------------------------------------
149 void cpPlugins::Interface::Parameters::
151 std::vector< I >& lst, const TString& name, const TUint& dim
156 TParameters::const_iterator i = this->m_Parameters.find( name );
157 if( i == this->m_Parameters.end( ) )
159 if( i->second.first == Self::IndexList )
162 std::istringstream str( i->second.second.second );
165 while( std::getline( str, token, '#' ) )
167 std::istringstream str2( token );
171 while( std::getline( str2, token2, ';' ) && d < dim )
173 v[ d ] = std::atoi( token.c_str( ) );
182 // -------------------------------------------------------------------------
184 void cpPlugins::Interface::Parameters::
186 std::vector< P >& lst, const TString& name, const TUint& dim
191 TParameters::const_iterator i = this->m_Parameters.find( name );
192 if( i == this->m_Parameters.end( ) )
194 if( i->second.first == Self::PointList )
197 std::istringstream str( i->second.second.second );
200 while( std::getline( str, token, '#' ) )
202 std::istringstream str2( token );
206 while( std::getline( str2, token2, ';' ) && d < dim )
208 std::istringstream tok_str( token );
218 // -------------------------------------------------------------------------
220 void cpPlugins::Interface::Parameters::
222 std::vector< V >& lst, const TString& name, const TUint& dim
227 TParameters::const_iterator i = this->m_Parameters.find( name );
228 if( i == this->m_Parameters.end( ) )
230 if( i->second.first == Self::VectorList )
233 std::istringstream str( i->second.second.second );
236 while( std::getline( str, token, '#' ) )
238 std::istringstream str2( token );
242 while( std::getline( str2, token2, ';' ) && d < dim )
244 std::istringstream tok_str( token );
254 // -------------------------------------------------------------------------
256 void cpPlugins::Interface::Parameters::
257 SetIndex( const TString& name, const TUint& dim, const I& v )
259 TParameters::iterator i = this->m_Parameters.find( name );
260 if( i == this->m_Parameters.end( ) )
262 if( i->second.first != Self::Index )
265 std::stringstream str;
267 for( unsigned int d = 1; d < dim; ++d )
268 str << ";" << v[ d ];
269 i->second.second.second = str.str( );
273 // -------------------------------------------------------------------------
275 void cpPlugins::Interface::Parameters::
276 SetPoint( const TString& name, const TUint& dim, const P& v )
278 TParameters::iterator i = this->m_Parameters.find( name );
279 if( i == this->m_Parameters.end( ) )
281 if( i->second.first != Self::Point )
284 std::stringstream str;
286 for( unsigned int d = 1; d < dim; ++d )
287 str << ";" << v[ d ];
288 i->second.second.second = str.str( );
292 // -------------------------------------------------------------------------
294 void cpPlugins::Interface::Parameters::
295 SetVector( const TString& name, const TUint& dim, const V& v )
297 TParameters::iterator i = this->m_Parameters.find( name );
298 if( i == this->m_Parameters.end( ) )
300 if( i->second.first != Self::Vector )
303 std::stringstream str;
305 for( unsigned int d = 1; d < dim; ++d )
306 str << ";" << v[ d ];
307 i->second.second.second = str.str( );
311 // -------------------------------------------------------------------------
313 void cpPlugins::Interface::Parameters::
314 AddToIndexList( const TString& name, const TUint& dim, const I& v )
316 TParameters::iterator i = this->m_Parameters.find( name );
317 if( i == this->m_Parameters.end( ) )
319 if( i->second.first != Self::IndexList )
322 std::stringstream str;
323 if( i->second.second.second == "" )
326 str << "#" << v[ 0 ];
327 for( unsigned int d = 1; d < dim; ++d )
328 str << ";" << v[ d ];
329 i->second.second.second += str.str( );
333 // -------------------------------------------------------------------------
335 void cpPlugins::Interface::Parameters::
336 AddToPointList( const TString& name, const TUint& dim, const P& v )
338 TParameters::iterator i = this->m_Parameters.find( name );
339 if( i == this->m_Parameters.end( ) )
341 if( i->second.first != Self::PointList )
344 std::stringstream str;
345 if( i->second.second.second == "" )
348 str << "#" << v[ 0 ];
349 for( unsigned int d = 1; d < dim; ++d )
350 str << ";" << v[ d ];
351 i->second.second.second += str.str( );
355 // -------------------------------------------------------------------------
357 void cpPlugins::Interface::Parameters::
358 AddToVectorList( const TString& name, const TUint& dim, const V& v )
360 TParameters::iterator i = this->m_Parameters.find( name );
361 if( i == this->m_Parameters.end( ) )
363 if( i->second.first != Self::VectorList )
366 std::stringstream str;
367 if( i->second.second.second == "" )
370 str << "#" << v[ 0 ];
371 for( unsigned int d = 1; d < dim; ++d )
372 str << ";" << v[ d ];
373 i->second.second.second += str.str( );
377 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__