]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/BaseObjects/Parameters.cxx
cfb5f83b220aaa3b0a8488887932aa2df34c8deb
[cpPlugins.git] / lib / cpPlugins / BaseObjects / Parameters.cxx
1 #include <cpPlugins/BaseObjects/Parameters.h>
2 #include <cpPlugins/BaseObjects/ProcessObject.h>
3 #include <cpPlugins/Utility.h>
4 #include <tinyxml2/tinyxml2.h>
5
6 // -------------------------------------------------------------------------
7 cpPlugins::BaseObjects::Parameters::
8 Parameters( )
9   : m_ProcessObject( NULL )
10 {
11   this->Clear( );
12 }
13
14 // -------------------------------------------------------------------------
15 cpPlugins::BaseObjects::Parameters::
16 ~Parameters( )
17 {
18 }
19
20 // -------------------------------------------------------------------------
21 cpPlugins::BaseObjects::ProcessObject* cpPlugins::BaseObjects::Parameters::
22 GetProcessObject( )
23 {
24   return( this->m_ProcessObject );
25 }
26
27 // -------------------------------------------------------------------------
28 const
29 cpPlugins::BaseObjects::ProcessObject* cpPlugins::BaseObjects::Parameters::
30 GetProcessObject( ) const
31 {
32   return( this->m_ProcessObject );
33 }
34
35 // -------------------------------------------------------------------------
36 void cpPlugins::BaseObjects::Parameters::
37 SetProcessObject( cpPlugins::BaseObjects::ProcessObject* po )
38 {
39   this->m_ProcessObject = po;
40 }
41
42 // -------------------------------------------------------------------------
43 void cpPlugins::BaseObjects::Parameters::
44 Modified( ) const
45 {
46   if( this->m_ProcessObject != NULL )
47     this->m_ProcessObject->Modified( );
48 }
49
50 // -------------------------------------------------------------------------
51 void cpPlugins::BaseObjects::Parameters::
52 Clear( )
53 {
54   this->m_Parameters.clear( );
55   this->Modified( );
56 }
57
58 // -------------------------------------------------------------------------
59 void cpPlugins::BaseObjects::Parameters::
60 GetNames( std::vector< std::string >& container ) const
61 {
62   container.clear( );
63   TParameters::const_iterator i = this->m_Parameters.begin( );
64   for( ; i != this->m_Parameters.end( ); ++i )
65     container.push_back( i->first );
66 }
67
68 // -------------------------------------------------------------------------
69 cpPlugins::BaseObjects::Parameters::
70 Type cpPlugins::BaseObjects::Parameters::
71 GetType( const std::string& name ) const
72 {
73   auto i = this->m_Parameters.find( name );
74   if( i != this->m_Parameters.end( ) )
75     return( i->second.first );
76   else
77     return( Self::NoType );
78 }
79
80 // -------------------------------------------------------------------------
81 #define cpPlugins_BaseObjects_Parameters_TypeAsString( Y )      \
82   if( i->second.first == Self::Y )                              \
83     return( #Y )
84
85 std::string cpPlugins::BaseObjects::Parameters::
86 GetTypeAsString( const std::string& name ) const
87 {
88   auto i = this->m_Parameters.find( name );
89   cpPlugins_BaseObjects_Parameters_TypeAsString( String );
90   else cpPlugins_BaseObjects_Parameters_TypeAsString( Bool );
91   else cpPlugins_BaseObjects_Parameters_TypeAsString( Int );
92   else cpPlugins_BaseObjects_Parameters_TypeAsString( Uint );
93   else cpPlugins_BaseObjects_Parameters_TypeAsString( Real );
94   else cpPlugins_BaseObjects_Parameters_TypeAsString( OpenFileName );
95   else cpPlugins_BaseObjects_Parameters_TypeAsString( SaveFileName );
96   else cpPlugins_BaseObjects_Parameters_TypeAsString( PathName );
97   else cpPlugins_BaseObjects_Parameters_TypeAsString( StringList );
98   else cpPlugins_BaseObjects_Parameters_TypeAsString( BoolList );
99   else cpPlugins_BaseObjects_Parameters_TypeAsString( IntList );
100   else cpPlugins_BaseObjects_Parameters_TypeAsString( UintList );
101   else cpPlugins_BaseObjects_Parameters_TypeAsString( RealList );
102   else cpPlugins_BaseObjects_Parameters_TypeAsString( OpenFileNameList );
103   else cpPlugins_BaseObjects_Parameters_TypeAsString( SaveFileNameList );
104   else cpPlugins_BaseObjects_Parameters_TypeAsString( PathNameList );
105   else cpPlugins_BaseObjects_Parameters_TypeAsString( Choices );
106   else return( "NoType" );
107 }
108
109 // -------------------------------------------------------------------------
110 #define cpPlugins_BaseObjects_Parameters_TypeFromString( Y, str )   \
111   if( str == std::string( #Y ) )                                    \
112     return( Self::Y )
113
114 cpPlugins::BaseObjects::Parameters::
115 Type cpPlugins::BaseObjects::Parameters::
116 GetTypeFromString( const std::string& t )
117 {
118   cpPlugins_BaseObjects_Parameters_TypeFromString( String, t );
119   else cpPlugins_BaseObjects_Parameters_TypeFromString( Bool, t );
120   else cpPlugins_BaseObjects_Parameters_TypeFromString( Int, t );
121   else cpPlugins_BaseObjects_Parameters_TypeFromString( Uint, t );
122   else cpPlugins_BaseObjects_Parameters_TypeFromString( Real, t );
123   else cpPlugins_BaseObjects_Parameters_TypeFromString( OpenFileName, t );
124   else cpPlugins_BaseObjects_Parameters_TypeFromString( SaveFileName, t );
125   else cpPlugins_BaseObjects_Parameters_TypeFromString( PathName, t );
126   else cpPlugins_BaseObjects_Parameters_TypeFromString( StringList, t );
127   else cpPlugins_BaseObjects_Parameters_TypeFromString( BoolList, t );
128   else cpPlugins_BaseObjects_Parameters_TypeFromString( IntList, t );
129   else cpPlugins_BaseObjects_Parameters_TypeFromString( UintList, t );
130   else cpPlugins_BaseObjects_Parameters_TypeFromString( RealList, t );
131   else cpPlugins_BaseObjects_Parameters_TypeFromString( OpenFileNameList, t );
132   else cpPlugins_BaseObjects_Parameters_TypeFromString( SaveFileNameList, t );
133   else cpPlugins_BaseObjects_Parameters_TypeFromString( PathNameList, t );
134   else cpPlugins_BaseObjects_Parameters_TypeFromString( Choices, t );
135   else return( Self::NoType );
136 }
137
138 // -------------------------------------------------------------------------
139 std::string cpPlugins::BaseObjects::Parameters::
140 GetString( const std::string& name, bool force ) const
141 {
142   auto i = this->m_Parameters.find( name );
143   if( i != this->m_Parameters.end( ) )
144   {
145     if( i->second.first == Self::String || force )
146       return( i->second.second );
147     else
148       return( "" );
149   }
150   else
151     return( "" );
152 }
153
154 // -------------------------------------------------------------------------
155 void cpPlugins::BaseObjects::Parameters::
156 SetString( const std::string& name, const std::string& v, bool force )
157 {
158   auto i = this->m_Parameters.find( name );
159   if( i != this->m_Parameters.end( ) )
160   {
161     if( i->second.first == Self::String || force )
162     {
163       if( i->second.second != v )
164       {
165         i->second.second = v;
166         this->Modified( );
167
168       } // fi
169
170     } // fi
171
172   } // fi
173 }
174
175 // -------------------------------------------------------------------------
176 void cpPlugins::BaseObjects::Parameters::
177 ConfigureAsChoices(
178   const std::string& name, const std::vector< std::string >& choices
179   )
180 {
181   // It is invalid not to give choices when configuring
182   if( choices.size( ) == 0 )
183     return;
184
185   std::stringstream str_choices;
186   str_choices << choices[ 0 ];
187   for( unsigned int i = 1; i < choices.size( ); ++i )
188     str_choices << "#" << choices[ i ];
189   str_choices << "@";
190   this->m_Parameters[ name ] =
191     TParameter( Self::Choices, str_choices.str( ) );
192   this->Modified( );
193 }
194
195 // -------------------------------------------------------------------------
196 void cpPlugins::BaseObjects::Parameters::
197 ConfigureAsRealTypesChoices( const std::string& name )
198 {
199   std::vector< std::string > choices;
200   choices.push_back( "float" );
201   choices.push_back( "double" );
202   this->ConfigureAsChoices( name, choices );
203 }
204
205 // -------------------------------------------------------------------------
206 void cpPlugins::BaseObjects::Parameters::
207 ConfigureAsIntTypesChoices( const std::string& name )
208 {
209   std::vector< std::string > choices;
210   choices.push_back( "char" );
211   choices.push_back( "uchar" );
212   choices.push_back( "short" );
213   choices.push_back( "ushort" );
214   choices.push_back( "int" );
215   choices.push_back( "uint" );
216   choices.push_back( "long" );
217   choices.push_back( "ulong" );
218   this->ConfigureAsChoices( name, choices );
219 }
220
221 // -------------------------------------------------------------------------
222 void cpPlugins::BaseObjects::Parameters::
223 ConfigureAsScalarTypesChoices( const std::string& name )
224 {
225   std::vector< std::string > choices;
226   choices.push_back( "char" );
227   choices.push_back( "uchar" );
228   choices.push_back( "short" );
229   choices.push_back( "ushort" );
230   choices.push_back( "int" );
231   choices.push_back( "uint" );
232   choices.push_back( "long" );
233   choices.push_back( "ulong" );
234   choices.push_back( "float" );
235   choices.push_back( "double" );
236   this->ConfigureAsChoices( name, choices );
237 }
238
239 // -------------------------------------------------------------------------
240 std::vector< std::string > cpPlugins::BaseObjects::Parameters::
241 GetChoices( const std::string& name ) const
242 {
243   std::vector< std::string > choices;
244
245   TParameters::const_iterator i = this->m_Parameters.find( name );
246   if( i != this->m_Parameters.end( ) )
247   {
248     if( i->second.first == Self::Choices )
249     {
250       std::istringstream str_choices( i->second.second );
251       std::string real_choices;
252       std::getline( str_choices, real_choices, '@' );
253       std::istringstream str( real_choices );
254       std::string token;
255       while( std::getline( str, token, '#' ) )
256         choices.push_back( token );
257
258     } // fi
259
260   } // fi
261   return( choices );
262 }
263
264 // -------------------------------------------------------------------------
265 std::string cpPlugins::BaseObjects::Parameters::
266 GetSelectedChoice( const std::string& name ) const
267 {
268   auto i = this->m_Parameters.find( name );
269   if( i != this->m_Parameters.end( ) )
270   {
271     if( i->second.first == Self::Choices )
272     {
273       std::istringstream str_choices( i->second.second );
274       std::string real_choice;
275       std::getline( str_choices, real_choice, '@' );
276       std::getline( str_choices, real_choice, '@' );
277       return( real_choice );
278     }
279     else
280       return( "" );
281   }
282   else
283     return( "" );
284 }
285
286 // -------------------------------------------------------------------------
287 bool cpPlugins::BaseObjects::Parameters::
288 SetSelectedChoice( const std::string& name, const std::string& choice )
289 {
290   auto i = this->m_Parameters.find( name );
291   if( i != this->m_Parameters.end( ) )
292   {
293     if( i->second.first == Self::Choices )
294     {
295       std::istringstream str_choices( i->second.second );
296       std::string choices;
297       std::getline( str_choices, choices, '@' );
298       if( choices.find( choice ) != std::string::npos )
299       {
300         std::stringstream new_choices;
301         new_choices << choices << "@" << choice;
302         i->second.second = new_choices.str( );
303         this->Modified( );
304         return( true );
305       }
306       else
307         return( false );
308     }
309     else
310       return( false );
311   }
312   else
313     return( false );
314 }
315
316 // -------------------------------------------------------------------------
317 std::string cpPlugins::BaseObjects::Parameters::
318 GetAcceptedFileExtensions( const std::string& name ) const
319 {
320   auto i = this->m_AcceptedFileExtensions.find( name );
321   if( i != this->m_AcceptedFileExtensions.end( ) )
322     return( i->second );
323   else
324     return( "" );
325 }
326
327 // -------------------------------------------------------------------------
328 void cpPlugins::BaseObjects::Parameters::
329 SetAcceptedFileExtensions(
330   const std::string& name, const std::string& extensions
331   )
332 {
333   auto i = this->m_Parameters.find( name );
334   if( i != this->m_Parameters.end( ) )
335   {
336     bool is_valid = ( i->second.first == Self::OpenFileName );
337     is_valid     |= ( i->second.first == Self::SaveFileName );
338     is_valid     |= ( i->second.first == Self::OpenFileNameList );
339     is_valid     |= ( i->second.first == Self::SaveFileNameList );
340     if( is_valid )
341       this->m_AcceptedFileExtensions[ name ] = extensions;
342
343   } // fi
344 }
345
346 // -------------------------------------------------------------------------
347 bool cpPlugins::BaseObjects::Parameters::
348 ToXML(
349   tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* parent_elem
350   ) const
351 {
352   if( parent_elem == NULL )
353     return( false );
354
355   auto pIt = this->m_Parameters.begin( );
356   for( ; pIt != this->m_Parameters.end( ); ++pIt )
357   {
358     tinyxml2::XMLElement* p = doc->NewElement( "Parameter" );
359     p->SetAttribute( "Name", pIt->first.c_str( ) );
360     p->SetAttribute( "Value", pIt->second.second.c_str( ) );
361     p->SetAttribute( "Type", this->GetTypeAsString( pIt->first ).c_str( ) );
362     parent_elem->InsertEndChild( p );
363
364   } // rof
365   return( true );
366 }
367
368 // -------------------------------------------------------------------------
369 bool cpPlugins::BaseObjects::Parameters::
370 FromXML( const tinyxml2::XMLElement* filter_elem )
371 {
372   const tinyxml2::XMLElement* param =
373     filter_elem->FirstChildElement( "Parameter" );
374   bool ret = false;
375   while( param != NULL )
376   {
377     const char* param_name = param->Attribute( "Name" );
378     const char* param_type = param->Attribute( "Type" );
379     if( param_name != NULL && param_type != NULL )
380     {
381       TParameter value;
382       value.second = param->Attribute( "Value" );
383       value.first = Self::GetTypeFromString( param_type );
384       this->m_Parameters[ param_name ] = value;
385
386     } // fi
387     param = param->NextSiblingElement( "Parameter" );
388     ret = true;
389
390   } // elihw
391   this->Modified( );
392   return( ret );
393 }
394
395 // -------------------------------------------------------------------------
396 cpPlugins::BaseObjects::Parameters::
397 TParameters& cpPlugins::BaseObjects::Parameters::
398 GetRawParameters( )
399 {
400   return( this->m_Parameters );
401 }
402
403 // -------------------------------------------------------------------------
404 const cpPlugins::BaseObjects::Parameters::
405 TParameters& cpPlugins::BaseObjects::Parameters::
406 GetRawParameters( ) const
407 {
408   return( this->m_Parameters );
409 }
410
411 // -------------------------------------------------------------------------
412 #define cpPlugins_BaseObjects_Parameters_Configure_Code( Y )            \
413   void cpPlugins::BaseObjects::Parameters::                             \
414   ConfigureAs##Y( const std::string& name, const T##Y& init )           \
415   {                                                                     \
416     this->_Configure< Y >( name );                                      \
417     this->Set##Y( name, init );                                         \
418   }                                                                     \
419   bool cpPlugins::BaseObjects::Parameters::                             \
420   Has##Y( const std::string& name ) const                               \
421   { return( this->_Has< Y >( name ) ); }
422
423 // -------------------------------------------------------------------------
424 #define cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Y )        \
425   void cpPlugins::BaseObjects::Parameters::                             \
426   ConfigureAs##Y##List( const std::string& name )                       \
427   { this->_Configure< Y##List >( name ); }                              \
428   bool cpPlugins::BaseObjects::Parameters::                             \
429   Has##Y##List( const std::string& name ) const                         \
430   { return( this->_Has< Y##List >( name ) ); }
431
432 // -------------------------------------------------------------------------
433 #define cpPlugins_BaseObjects_Parameters_GetSet_Code( Y )               \
434   cpPlugins::BaseObjects::Parameters::T##Y                              \
435   cpPlugins::BaseObjects::Parameters::                                  \
436   Get##Y( const std::string& name ) const                               \
437   { return( this->_Get< T##Y, Y >( name ) ); }                          \
438   void cpPlugins::BaseObjects::Parameters::Set##Y(                      \
439     const std::string& name, const T##Y& v                              \
440     )                                                                   \
441   { this->_Set< T##Y, Y >( name, v ); }
442
443 // -------------------------------------------------------------------------
444 #define cpPlugins_BaseObjects_Parameters_GetSetList_Code( Y )           \
445   std::vector< cpPlugins::BaseObjects::Parameters::T##Y >               \
446   cpPlugins::BaseObjects::Parameters::                                  \
447   Get##Y##List( const std::string& name ) const                         \
448   { return( this->_GetList< T##Y, Y##List >( name ) ); }                \
449   void cpPlugins::BaseObjects::Parameters::AddTo##Y##List(              \
450     const std::string& name,                                            \
451     const cpPlugins::BaseObjects::Parameters::T##Y& v                   \
452     )                                                                   \
453   { this->_AddToList< T##Y, Y##List >( name, v ); }                     \
454   void cpPlugins::BaseObjects::Parameters::                             \
455   Clear##Y##List( const std::string& name )                             \
456   { this->_ClearList< Y##List >( name ); }
457
458 // -------------------------------------------------------------------------
459 cpPlugins_BaseObjects_Parameters_Configure_Code( String );
460 cpPlugins_BaseObjects_Parameters_Configure_Code( Bool );
461 cpPlugins_BaseObjects_Parameters_Configure_Code( Int );
462 cpPlugins_BaseObjects_Parameters_Configure_Code( Uint );
463 cpPlugins_BaseObjects_Parameters_Configure_Code( Real );
464 cpPlugins_BaseObjects_Parameters_Configure_Code( OpenFileName );
465 cpPlugins_BaseObjects_Parameters_Configure_Code( SaveFileName );
466 cpPlugins_BaseObjects_Parameters_Configure_Code( PathName );
467
468 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( String );
469 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Bool );
470 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Int );
471 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Uint );
472 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Real );
473 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( OpenFileName );
474 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( SaveFileName );
475 cpPlugins_BaseObjects_Parameters_ConfigureList_Code( PathName );
476
477 cpPlugins_BaseObjects_Parameters_GetSet_Code( Bool );
478 cpPlugins_BaseObjects_Parameters_GetSet_Code( Int );
479 cpPlugins_BaseObjects_Parameters_GetSet_Code( Uint );
480 cpPlugins_BaseObjects_Parameters_GetSet_Code( Real );
481 cpPlugins_BaseObjects_Parameters_GetSet_Code( OpenFileName );
482 cpPlugins_BaseObjects_Parameters_GetSet_Code( SaveFileName );
483 cpPlugins_BaseObjects_Parameters_GetSet_Code( PathName );
484
485 cpPlugins_BaseObjects_Parameters_GetSetList_Code( String );
486 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Bool );
487 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Int );
488 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Uint );
489 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Real );
490 cpPlugins_BaseObjects_Parameters_GetSetList_Code( PathName );
491
492 // -------------------------------------------------------------------------
493 std::vector< cpPlugins::BaseObjects::Parameters::TOpenFileName >
494 cpPlugins::BaseObjects::Parameters::
495 GetOpenFileNameList( const std::string& name ) const
496 {
497   return( this->_GetList< TOpenFileName, OpenFileNameList >( name ) );
498 }
499
500 // -------------------------------------------------------------------------
501 void cpPlugins::BaseObjects::Parameters::
502 AddToOpenFileNameList(
503   const std::string& name,
504   const cpPlugins::BaseObjects::Parameters::TOpenFileName& v
505   )
506 {
507   auto i = this->m_Parameters.find( name );
508   if( i != this->m_Parameters.end( ) )
509   {
510     if( i->second.first == OpenFileNameList )
511     {
512       auto pos = v.find_last_of( "/\\" );
513       if( i->second.second == "" )
514         i->second.second = v.substr( 0, pos );
515       i->second.second += std::string( "#" );
516       i->second.second += v.substr( pos + 1 );
517       this->Modified( );
518
519     } // fi
520
521   } // fi
522 }
523
524 // -------------------------------------------------------------------------
525 void cpPlugins::BaseObjects::Parameters::
526 ClearOpenFileNameList( const std::string& name )
527 {
528   this->_ClearList< OpenFileNameList >( name );
529 }
530
531 // -------------------------------------------------------------------------
532 std::vector< cpPlugins::BaseObjects::Parameters::TSaveFileName >
533 cpPlugins::BaseObjects::Parameters::
534 GetSaveFileNameList( const std::string& name ) const
535 {
536   return( this->_GetList< TSaveFileName, SaveFileNameList >( name ) );
537 }
538
539 // -------------------------------------------------------------------------
540 void cpPlugins::BaseObjects::Parameters::
541 AddToSaveFileNameList(
542   const std::string& name,
543   const cpPlugins::BaseObjects::Parameters::TSaveFileName& v
544   )
545 {
546   auto i = this->m_Parameters.find( name );
547   if( i != this->m_Parameters.end( ) )
548   {
549     if( i->second.first == SaveFileNameList )
550     {
551       auto pos = v.find_last_of( "/\\" );
552       if( i->second.second == "" )
553         i->second.second = v.substr( 0, pos );
554       i->second.second += std::string( "#" );
555       i->second.second += v.substr( pos + 1 );
556       this->Modified( );
557
558     } // fi
559
560   } // fi
561 }
562
563 // -------------------------------------------------------------------------
564 void cpPlugins::BaseObjects::Parameters::
565 ClearSaveFileNameList( const std::string& name )
566 {
567   this->_ClearList< SaveFileNameList >( name );
568 }
569
570 // -------------------------------------------------------------------------
571 template< unsigned int _Enum >
572 void cpPlugins::BaseObjects::Parameters::
573 _Configure( const std::string& name )
574 {
575   this->m_Parameters[ name ] = TParameter( ( Self::Type )( _Enum ), "" );
576   this->Modified( );
577 }
578
579 // -------------------------------------------------------------------------
580 template< unsigned int _Enum >
581 bool cpPlugins::BaseObjects::Parameters::
582 _Has( const std::string& name ) const
583 {
584   auto i = this->m_Parameters.find( name );
585   if( i != this->m_Parameters.end( ) )
586     return( i->second.first == ( Self::Type )( _Enum ) );
587   else
588     return( false );
589 }
590
591 // -------------------------------------------------------------------------
592 template< class _Type, unsigned int _Enum >
593 _Type cpPlugins::BaseObjects::Parameters::
594 _Get( const std::string& name ) const
595 {
596   auto i = this->m_Parameters.find( name );
597   if( i != this->m_Parameters.end( ) )
598   {
599     if( i->second.first == ( Self::Type )( _Enum ) )
600     {
601       if( typeid( _Type ) != typeid( std::string ) )
602       {
603         std::istringstream tok_str( i->second.second );
604         _Type v;
605         tok_str >> v;
606         return( v );
607       }
608       else
609       {
610         const _Type* ptr =
611           reinterpret_cast< const _Type* >( &( i->second.second ) );
612         return( *ptr );
613
614       } // fi
615
616     } // fi
617
618   } // fi
619   return( _Type( 0 ) );
620 }
621
622 // -------------------------------------------------------------------------
623 template< class _Type, unsigned int _Enum >
624 void cpPlugins::BaseObjects::Parameters::
625 _Set( const std::string& name, const _Type& v )
626 {
627   auto i = this->m_Parameters.find( name );
628   if( i != this->m_Parameters.end( ) )
629   {
630     if( i->second.first == ( Self::Type )( _Enum ) )
631     {
632       if( typeid( _Type ) != typeid( std::string ) )
633       {
634         std::stringstream str;
635         str << v;
636         if( i->second.second != str.str( ) )
637         {
638           i->second.second = str.str( );
639           this->Modified( );
640
641         } // fi
642       }
643       else
644       {
645         const std::string* str = reinterpret_cast< const std::string* >( &v );
646         if( i->second.second != *str )
647         {
648           i->second.second = *str;
649           this->Modified( );
650
651         } // fi
652
653       } // fi
654
655     } // fi
656
657   } // fi
658
659 }
660
661 // -------------------------------------------------------------------------
662 template< class _Type, unsigned int _Enum >
663 std::vector< _Type > cpPlugins::BaseObjects::Parameters::
664 _GetList( const std::string& name ) const
665 {
666   std::vector< _Type > lst;
667   std::vector< std::string >* slst =
668     reinterpret_cast< std::vector< std::string >* >( &lst );
669   auto i = this->m_Parameters.find( name );
670   if( i != this->m_Parameters.end( ) )
671   {
672     if( i->second.first == ( Self::Type )( _Enum ) )
673     {
674       std::vector< std::string > tokens;
675       cpPlugins::Tokenize( tokens, i->second.second, "#" );
676       for( auto t = tokens.begin( ); t != tokens.end( ); ++t )
677       {
678         if( typeid( _Type ) != typeid( std::string ) )
679         {
680           std::istringstream tok_str( *t );
681           _Type v;
682           tok_str >> v;
683           lst.push_back( v );
684         }
685         else
686           slst->push_back( *t );
687
688       } // rof
689
690     } // fi
691
692   } // fi
693   return( lst );
694 }
695
696 // -------------------------------------------------------------------------
697 template< class _Type, unsigned int _Enum >
698 void cpPlugins::BaseObjects::Parameters::
699 _AddToList( const std::string& name, const _Type& v )
700 {
701   auto i = this->m_Parameters.find( name );
702   if( i != this->m_Parameters.end( ) )
703   {
704     if( i->second.first == ( Self::Type )( _Enum ) )
705     {
706       std::stringstream str;
707       if( i->second.second != "" )
708         str << i->second.second << "#";
709       str << v;
710       i->second.second = str.str( );
711       this->Modified( );
712
713     } // fi
714
715   } // fi
716 }
717
718 // -------------------------------------------------------------------------
719 template< unsigned int _Enum >
720 void cpPlugins::BaseObjects::Parameters::
721 _ClearList( const std::string& name )
722 {
723   auto i = this->m_Parameters.find( name );
724   if( i != this->m_Parameters.end( ) )
725   {
726     if( i->second.first == ( Self::Type )( _Enum ) )
727     {
728       if( i->second.second != "" )
729       {
730         i->second.second = "";
731         this->Modified( );
732
733       } // fi
734
735     } // fi
736
737   } // fi
738 }
739
740 // eof - $RCSfile$