1 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
2 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
4 // -------------------------------------------------------------------------
6 I cpPlugins::Interface::Parameters::
7 GetIndex( const TString& name, const TUint& dim ) const
10 TParameters::const_iterator i = this->m_Parameters.find( name );
11 if( i != this->m_Parameters.end( ) )
13 if( i->second.first == Self::Index )
15 std::istringstream str( i->second.second );
18 while( std::getline( str, token, ';' ) && d < dim )
20 v[ d ] = std::atoi( token.c_str( ) );
30 // If parameter not found
31 for( unsigned int d = 0; d < dim; ++d )
36 // -------------------------------------------------------------------------
38 P cpPlugins::Interface::Parameters::
39 GetPoint( const TString& name, const TUint& dim ) const
42 TParameters::const_iterator i = this->m_Parameters.find( name );
43 if( i != this->m_Parameters.end( ) )
45 if( i->second.first == Self::Point )
47 std::istringstream str( i->second.second );
50 while( std::getline( str, token, ';' ) && d < dim )
52 std::istringstream tok_str( token );
63 // If parameter not found
64 for( unsigned int d = 0; d < dim; ++d )
69 // -------------------------------------------------------------------------
71 V cpPlugins::Interface::Parameters::
72 GetVector( const TString& name, const TUint& dim ) const
75 TParameters::const_iterator i = this->m_Parameters.find( name );
76 if( i != this->m_Parameters.end( ) )
78 if( i->second.first == Self::Vector )
80 std::istringstream str( i->second.second );
83 while( std::getline( str, token, ';' ) && d < dim )
85 std::istringstream tok_str( token );
96 // If parameter not found
97 for( unsigned int d = 0; d < dim; ++d )
102 // -------------------------------------------------------------------------
104 void cpPlugins::Interface::Parameters::
106 std::vector< I >& lst, const TString& name, const TUint& dim
111 TParameters::const_iterator i = this->m_Parameters.find( name );
112 if( i == this->m_Parameters.end( ) )
114 if( i->second.first == Self::IndexList )
117 std::istringstream str( i->second.second );
120 while( std::getline( str, token, '#' ) )
122 std::istringstream str2( token );
126 while( std::getline( str2, token2, ';' ) && d < dim )
128 v[ d ] = std::atoi( token.c_str( ) );
137 // -------------------------------------------------------------------------
139 void cpPlugins::Interface::Parameters::
141 std::vector< P >& lst, const TString& name, const TUint& dim
146 TParameters::const_iterator i = this->m_Parameters.find( name );
147 if( i == this->m_Parameters.end( ) )
149 if( i->second.first == Self::PointList )
152 std::istringstream str( i->second.second );
155 while( std::getline( str, token, '#' ) )
157 std::istringstream str2( token );
161 while( std::getline( str2, token2, ';' ) && d < dim )
163 std::istringstream tok_str( token );
173 // -------------------------------------------------------------------------
175 void cpPlugins::Interface::Parameters::
177 std::vector< V >& lst, const TString& name, const TUint& dim
182 TParameters::const_iterator i = this->m_Parameters.find( name );
183 if( i == this->m_Parameters.end( ) )
185 if( i->second.first == Self::VectorList )
188 std::istringstream str( i->second.second );
191 while( std::getline( str, token, '#' ) )
193 std::istringstream str2( token );
197 while( std::getline( str2, token2, ';' ) && d < dim )
199 std::istringstream tok_str( token );
209 // -------------------------------------------------------------------------
211 void cpPlugins::Interface::Parameters::
212 SetIndex( const TString& name, const TUint& dim, const I& v )
214 TParameters::iterator i = this->m_Parameters.find( name );
215 if( i == this->m_Parameters.end( ) )
217 if( i->second.first != Self::Index )
220 std::stringstream str;
222 for( unsigned int d = 1; d < dim; ++d )
223 str << ";" << v[ d ];
224 i->second.second = str.str( );
228 // -------------------------------------------------------------------------
230 void cpPlugins::Interface::Parameters::
231 SetPoint( 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::Point )
239 std::stringstream str;
241 for( unsigned int d = 1; d < dim; ++d )
242 str << ";" << v[ d ];
243 i->second.second = str.str( );
247 // -------------------------------------------------------------------------
249 void cpPlugins::Interface::Parameters::
250 SetVector( const TString& name, const TUint& dim, const V& v )
252 TParameters::iterator i = this->m_Parameters.find( name );
253 if( i == this->m_Parameters.end( ) )
255 if( i->second.first != Self::Vector )
258 std::stringstream str;
260 for( unsigned int d = 1; d < dim; ++d )
261 str << ";" << v[ d ];
262 i->second.second = str.str( );
266 // -------------------------------------------------------------------------
268 void cpPlugins::Interface::Parameters::
269 AddToIndexList( const TString& name, const TUint& dim, const I& v )
271 TParameters::iterator i = this->m_Parameters.find( name );
272 if( i == this->m_Parameters.end( ) )
274 if( i->second.first != Self::IndexList )
277 std::stringstream str;
278 if( i->second.second == "" )
281 str << "#" << v[ 0 ];
282 for( unsigned int d = 1; d < dim; ++d )
283 str << ";" << v[ d ];
284 i->second.second += str.str( );
288 // -------------------------------------------------------------------------
290 void cpPlugins::Interface::Parameters::
291 AddToPointList( const TString& name, const TUint& dim, const P& v )
293 TParameters::iterator i = this->m_Parameters.find( name );
294 if( i == this->m_Parameters.end( ) )
296 if( i->second.first != Self::PointList )
299 std::stringstream str;
300 if( i->second.second == "" )
303 str << "#" << v[ 0 ];
304 for( unsigned int d = 1; d < dim; ++d )
305 str << ";" << v[ d ];
306 i->second.second += str.str( );
310 // -------------------------------------------------------------------------
312 void cpPlugins::Interface::Parameters::
313 AddToVectorList( const TString& name, const TUint& dim, const V& v )
315 TParameters::iterator i = this->m_Parameters.find( name );
316 if( i == this->m_Parameters.end( ) )
318 if( i->second.first != Self::VectorList )
321 std::stringstream str;
322 if( i->second.second == "" )
325 str << "#" << v[ 0 ];
326 for( unsigned int d = 1; d < dim; ++d )
327 str << ";" << v[ d ];
328 i->second.second += str.str( );
332 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__