1 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
2 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
4 // -------------------------------------------------------------------------
6 I cpPlugins::Interface::Parameters::
7 GetIndex( const std::string& name, const unsigned int& dim ) const
10 auto 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 std::string& name, const unsigned int& dim ) const
42 auto 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 std::string& name, const unsigned int& dim ) const
75 auto 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::
105 SetIndex( const std::string& name, const unsigned int& dim, const I& v )
107 TParameters::iterator i = this->m_Parameters.find( name );
108 if( i == this->m_Parameters.end( ) )
110 if( i->second.first != Self::Index )
113 std::stringstream str;
115 for( unsigned int d = 1; d < dim; ++d )
116 str << ";" << v[ d ];
117 i->second.second = str.str( );
121 // -------------------------------------------------------------------------
123 void cpPlugins::Interface::Parameters::
124 SetPoint( const std::string& name, const unsigned int& dim, const P& v )
126 TParameters::iterator i = this->m_Parameters.find( name );
127 if( i == this->m_Parameters.end( ) )
129 if( i->second.first != Self::Point )
132 std::stringstream str;
134 for( unsigned int d = 1; d < dim; ++d )
135 str << ";" << v[ d ];
136 i->second.second = str.str( );
140 // -------------------------------------------------------------------------
142 void cpPlugins::Interface::Parameters::
143 SetVector( const std::string& name, const unsigned int& dim, const V& v )
145 TParameters::iterator i = this->m_Parameters.find( name );
146 if( i == this->m_Parameters.end( ) )
148 if( i->second.first != Self::Vector )
151 std::stringstream str;
153 for( unsigned int d = 1; d < dim; ++d )
154 str << ";" << v[ d ];
155 i->second.second = str.str( );
159 // -------------------------------------------------------------------------
161 std::vector< I > cpPlugins::Interface::Parameters::
162 GetIndexList( const std::string& name, const unsigned int& dim ) const
164 std::vector< I > lst;
165 auto i = this->m_Parameters.find( name );
166 if( i != this->m_Parameters.end( ) )
168 if( i->second.first == Self::IndexList )
170 std::istringstream str( i->second.second );
173 while( std::getline( str, token, '#' ) )
175 std::istringstream str2( token );
179 while( std::getline( str2, token2, ';' ) && d < dim )
181 v[ d ] = std::atoi( token.c_str( ) );
195 // -------------------------------------------------------------------------
197 std::vector< P > cpPlugins::Interface::Parameters::
198 GetPointList( const std::string& name, const unsigned int& dim ) const
200 std::vector< P > lst;
202 auto i = this->m_Parameters.find( name );
203 if( i != this->m_Parameters.end( ) )
205 if( i->second.first == Self::PointList )
207 std::istringstream str( i->second.second );
210 while( std::getline( str, token, '#' ) )
212 std::istringstream str2( token );
216 while( std::getline( str2, token2, ';' ) && d < dim )
218 std::istringstream tok_str( token );
233 // -------------------------------------------------------------------------
235 std::vector< V > cpPlugins::Interface::Parameters::
236 GetVectorList( const std::string& name, const unsigned int& dim ) const
238 std::vector< V > lst;
240 auto i = this->m_Parameters.find( name );
241 if( i != this->m_Parameters.end( ) )
243 if( i->second.first == Self::VectorList )
245 std::istringstream str( i->second.second );
248 while( std::getline( str, token, '#' ) )
250 std::istringstream str2( token );
254 while( std::getline( str2, token2, ';' ) && d < dim )
256 std::istringstream tok_str( token );
271 // -------------------------------------------------------------------------
273 void cpPlugins::Interface::Parameters::
274 AddToIndexList( const std::string& name, const unsigned int& dim, const I& v )
276 TParameters::iterator i = this->m_Parameters.find( name );
277 if( i == this->m_Parameters.end( ) )
279 if( i->second.first != Self::IndexList )
282 std::stringstream str;
283 if( i->second.second == "" )
286 str << "#" << v[ 0 ];
287 for( unsigned int d = 1; d < dim; ++d )
288 str << ";" << v[ d ];
289 i->second.second += str.str( );
293 // -------------------------------------------------------------------------
295 void cpPlugins::Interface::Parameters::
296 AddToPointList( const std::string& name, const unsigned int& dim, const P& v )
298 TParameters::iterator i = this->m_Parameters.find( name );
299 if( i == this->m_Parameters.end( ) )
301 if( i->second.first != Self::PointList )
304 std::stringstream str;
305 if( i->second.second == "" )
308 str << "#" << v[ 0 ];
309 for( unsigned int d = 1; d < dim; ++d )
310 str << ";" << v[ d ];
311 i->second.second += str.str( );
315 // -------------------------------------------------------------------------
317 void cpPlugins::Interface::Parameters::
318 AddToVectorList( const std::string& name, const unsigned int& dim, const V& v )
320 TParameters::iterator i = this->m_Parameters.find( name );
321 if( i == this->m_Parameters.end( ) )
323 if( i->second.first != Self::VectorList )
326 std::stringstream str;
327 if( i->second.second == "" )
330 str << "#" << v[ 0 ];
331 for( unsigned int d = 1; d < dim; ++d )
332 str << ";" << v[ d ];
333 i->second.second += str.str( );
337 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__