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 ] = TParameter( Self::Index, TValues( s, s ) );
18 // -------------------------------------------------------------------------
20 void cpPlugins::Interface::Parameters::
21 ConfigureAsPoint( const TString& name, const TUint& dim, const P& v )
23 std::stringstream str;
25 for( unsigned int d = 1; d < dim; ++d )
27 std::string s = str.str( );
28 this->m_Parameters[ name ] = TParameter( Self::Point, TValues( s, s ) );
32 // -------------------------------------------------------------------------
34 I cpPlugins::Interface::Parameters::
35 GetIndex( const TString& name, const TUint& dim ) const
38 TParameters::const_iterator i = this->m_Parameters.find( name );
39 if( i != this->m_Parameters.end( ) )
41 if( i->second.first == Self::Index )
43 std::istringstream str( i->second.second.second );
46 while( std::getline( str, token, ';' ) && d < dim )
48 v[ d ] = std::atoi( token.c_str( ) );
58 // If parameter not found
59 for( unsigned int d = 0; d < dim; ++d )
64 // -------------------------------------------------------------------------
66 P cpPlugins::Interface::Parameters::
67 GetPoint( const TString& name, const TUint& dim ) const
70 TParameters::const_iterator i = this->m_Parameters.find( name );
71 if( i != this->m_Parameters.end( ) )
73 if( i->second.first == Self::Point )
75 std::istringstream str( i->second.second.second );
78 while( std::getline( str, token, ';' ) && d < dim )
80 v[ d ] = std::atof( token.c_str( ) );
90 // If parameter not found
91 for( unsigned int d = 0; d < dim; ++d )
96 // -------------------------------------------------------------------------
98 void cpPlugins::Interface::Parameters::
100 std::vector< I >& lst, const TString& name, const TUint& dim
105 TParameters::const_iterator i = this->m_Parameters.find( name );
106 if( i == this->m_Parameters.end( ) )
108 if( i->second.first == Self::IndexList )
111 std::istringstream str( i->second.second.second );
114 while( std::getline( str, token, '#' ) )
116 std::istringstream str2( token );
120 while( std::getline( str2, token2, ';' ) && d < dim )
122 v[ d ] = std::atoi( token.c_str( ) );
131 // -------------------------------------------------------------------------
133 void cpPlugins::Interface::Parameters::
135 std::vector< P >& lst, const TString& name, const TUint& dim
140 TParameters::const_iterator i = this->m_Parameters.find( name );
141 if( i == this->m_Parameters.end( ) )
143 if( i->second.first == Self::PointList )
146 std::istringstream str( i->second.second.second );
149 while( std::getline( str, token, '#' ) )
151 std::istringstream str2( token );
155 while( std::getline( str2, token2, ';' ) && d < dim )
157 v[ d ] = std::atof( token.c_str( ) );
166 // -------------------------------------------------------------------------
168 void cpPlugins::Interface::Parameters::
169 SetIndex( const TString& name, const TUint& dim, const I& v )
171 TParameters::iterator i = this->m_Parameters.find( name );
172 if( i == this->m_Parameters.end( ) )
174 if( i->second.first != Self::Index )
177 std::stringstream str;
179 for( unsigned int d = 1; d < dim; ++d )
180 str << ";" << v[ d ];
181 i->second.second.second = str.str( );
185 // -------------------------------------------------------------------------
187 void cpPlugins::Interface::Parameters::
188 SetPoint( const TString& name, const TUint& dim, const P& v )
190 TParameters::iterator i = this->m_Parameters.find( name );
191 if( i == this->m_Parameters.end( ) )
193 if( i->second.first != Self::Point )
196 std::stringstream str;
198 for( unsigned int d = 1; d < dim; ++d )
199 str << ";" << v[ d ];
200 i->second.second.second = str.str( );
204 // -------------------------------------------------------------------------
206 void cpPlugins::Interface::Parameters::
207 AddToIndexList( const TString& name, const TUint& dim, const I& v )
209 TParameters::iterator i = this->m_Parameters.find( name );
210 if( i == this->m_Parameters.end( ) )
212 if( i->second.first != Self::IndexList )
215 std::stringstream str;
216 if( i->second.second.second == "" )
219 str << "#" << v[ 0 ];
220 for( unsigned int d = 1; d < dim; ++d )
221 str << ";" << v[ d ];
222 i->second.second.second += str.str( );
226 // -------------------------------------------------------------------------
228 void cpPlugins::Interface::Parameters::
229 AddToPointList( const TString& name, const TUint& dim, const P& v )
231 TParameters::iterator i = this->m_Parameters.find( name );
232 if( i == this->m_Parameters.end( ) )
234 if( i->second.first != Self::PointList )
237 std::stringstream str;
238 if( i->second.second.second == "" )
241 str << "#" << v[ 0 ];
242 for( unsigned int d = 1; d < dim; ++d )
243 str << ";" << v[ d ];
244 i->second.second.second += str.str( );
248 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__