1 #include <cpPlugins/Interface/Parameters.h>
6 // -------------------------------------------------------------------------
7 cpPlugins::Interface::Parameters::
10 this->m_Parameters.clear( );
13 // -------------------------------------------------------------------------
14 cpPlugins::Interface::Parameters::
15 Parameters( const Self& other )
17 this->m_Parameters = other.m_Parameters;
20 // -------------------------------------------------------------------------
21 cpPlugins::Interface::Parameters::
24 this->m_Parameters.clear( );
27 // -------------------------------------------------------------------------
28 cpPlugins::Interface::Parameters::
29 Self& cpPlugins::Interface::Parameters::
30 operator=( const Self& other )
32 this->m_Parameters = other.m_Parameters;
36 // -------------------------------------------------------------------------
37 void cpPlugins::Interface::Parameters::
38 Configure( const Self::Type& type, const std::string& name )
40 this->m_Parameters[ name ] = TParameter( type, "" );
43 // -------------------------------------------------------------------------
44 void cpPlugins::Interface::Parameters::
45 SetValueAsString( const std::string& name, const std::string& v )
47 TParameters::iterator pIt = this->m_Parameters.find( name );
48 if( pIt == this->m_Parameters.end( ) )
50 if( pIt->second.first != Self::String )
53 pIt->second.second = v;
56 // -------------------------------------------------------------------------
57 void cpPlugins::Interface::Parameters::
58 SetValueAsInt( const std::string& name, const TInt& v )
60 TParameters::iterator pIt = this->m_Parameters.find( name );
61 if( pIt == this->m_Parameters.end( ) )
63 if( pIt->second.first != Self::Int )
68 pIt->second.second = ss.str( );
71 // -------------------------------------------------------------------------
72 void cpPlugins::Interface::Parameters::
73 SetValueAsUint( const std::string& name, const TUint& v )
75 TParameters::iterator pIt = this->m_Parameters.find( name );
76 if( pIt == this->m_Parameters.end( ) )
78 if( pIt->second.first != Self::Uint )
83 pIt->second.second = ss.str( );
86 // -------------------------------------------------------------------------
87 void cpPlugins::Interface::Parameters::
88 SetValueAsReal( const std::string& name, const TReal& v )
90 TParameters::iterator pIt = this->m_Parameters.find( name );
91 if( pIt == this->m_Parameters.end( ) )
93 if( pIt->second.first != Self::Real )
98 pIt->second.second = ss.str( );
101 // -------------------------------------------------------------------------
102 void cpPlugins::Interface::Parameters::
103 SetValueAsIndex( const std::string& name, const TUint& n, ... )
105 TParameters::iterator pIt = this->m_Parameters.find( name );
106 if( pIt == this->m_Parameters.end( ) )
108 if( pIt->second.first != Self::Index )
112 va_start( v_lst, n );
114 std::stringstream ss;
115 for( TUint i = 0; i < n; ++i )
116 ss << va_arg( v_lst, long ) << ":";
119 pIt->second.second = ss.str( );
122 // -------------------------------------------------------------------------
123 void cpPlugins::Interface::Parameters::
124 SetValueAsPoint( const std::string& name, const TUint& n, ... )
126 TParameters::iterator pIt = this->m_Parameters.find( name );
127 if( pIt == this->m_Parameters.end( ) )
129 if( pIt->second.first != Self::Point )
133 va_start( v_lst, n );
135 std::stringstream ss;
136 for( TUint i = 0; i < n; ++i )
137 ss << va_arg( v_lst, double ) << ":";
140 pIt->second.second = ss.str( );
143 // -------------------------------------------------------------------------
144 const std::string& cpPlugins::Interface::Parameters::
145 GetValueAsString( const std::string& name ) const
147 static const std::string null_str = "";
148 TParameters::const_iterator pIt = this->m_Parameters.find( name );
149 if( pIt == this->m_Parameters.end( ) )
151 if( pIt->second.first != Self::String )
154 return( pIt->second.second );
157 // -------------------------------------------------------------------------
158 cpPlugins::Interface::Parameters::
159 TInt cpPlugins::Interface::Parameters::
160 GetValueAsInt( const std::string& name ) const
162 static const std::string null_str = "";
163 TParameters::const_iterator pIt = this->m_Parameters.find( name );
164 if( pIt == this->m_Parameters.end( ) )
166 if( pIt->second.first != Self::Int )
169 return( std::atoi( pIt->second.second.c_str( ) ) );
172 // -------------------------------------------------------------------------
173 cpPlugins::Interface::Parameters::
174 TUint cpPlugins::Interface::Parameters::
175 GetValueAsUint( const std::string& name ) const
177 static const std::string null_str = "";
178 TParameters::const_iterator pIt = this->m_Parameters.find( name );
179 if( pIt == this->m_Parameters.end( ) )
180 return( TUint( 0 ) );
181 if( pIt->second.first != Self::Uint )
182 return( TUint( 0 ) );
184 return( std::atoi( pIt->second.second.c_str( ) ) );
187 // -------------------------------------------------------------------------
188 cpPlugins::Interface::Parameters::
189 TReal cpPlugins::Interface::Parameters::
190 GetValueAsReal( const std::string& name ) const
192 static const std::string null_str = "";
193 TParameters::const_iterator pIt = this->m_Parameters.find( name );
194 if( pIt == this->m_Parameters.end( ) )
195 return( TReal( 0 ) );
196 if( pIt->second.first != Self::Real )
197 return( TReal( 0 ) );
199 return( std::atof( pIt->second.second.c_str( ) ) );
202 // -------------------------------------------------------------------------
203 void cpPlugins::Interface::Parameters::
204 GetValueAsStringList(
205 std::vector< std::string >& lst, const std::string& name
210 // -------------------------------------------------------------------------
211 void cpPlugins::Interface::Parameters::
212 GetValueAsIntList( std::vector< TInt >& lst, const std::string& name ) const
216 // -------------------------------------------------------------------------
217 void cpPlugins::Interface::Parameters::
218 GetValueAsUintList( std::vector< TUint >& lst, const std::string& name ) const
222 // -------------------------------------------------------------------------
223 void cpPlugins::Interface::Parameters::
224 GetValueAsRealList( std::vector< TReal >& lst, const std::string& name ) const