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