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