]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Plugins.cxx
More on graph editor
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.cxx
1 #include <cpPlugins/Interface/Plugins.h>
2
3 #include <stdexcept>
4
5 #include <cpPlugins/Interface/Image.h>
6 #include <cpPlugins/Interface/Mesh.h>
7
8 #ifdef cpPlugins_Interface_QT4
9
10 #include <QApplication>
11 #include <QFileDialog>
12 #include <QMessageBox>
13 #include <QWidget>
14
15 #ifdef _WIN32
16 #  define PLUGIN_PREFIX ""
17 #  define PLUGIN_EXT "dll"
18 #  define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
19 #else // Linux
20 #  define PLUGIN_PREFIX "lib"
21 #  define PLUGIN_EXT "so"
22 #  define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
23 #endif // _WIN32
24
25 #endif // cpPlugins_Interface_QT4
26
27 // -------------------------------------------------------------------------
28 cpPlugins::Interface::Plugins::
29 Plugins( )
30   : m_Widget( NULL ),
31     m_Application( NULL ),
32     m_LastLoadedPlugin( "" ),
33     m_ActiveFilter( NULL )
34 {
35 }
36
37 // -------------------------------------------------------------------------
38 cpPlugins::Interface::Plugins::
39 ~Plugins( )
40 {
41 }
42
43 // -------------------------------------------------------------------------
44 QWidget* cpPlugins::Interface::Plugins::
45 GetWidget( )
46 {
47   return( this->m_Widget );
48 }
49
50 // -------------------------------------------------------------------------
51 const QWidget* cpPlugins::Interface::Plugins::
52 GetWidget( ) const
53 {
54   return( this->m_Widget );
55 }
56
57 // -------------------------------------------------------------------------
58 void cpPlugins::Interface::Plugins::
59 SetWidget( QWidget* widget )
60 {
61   this->m_Widget = widget;
62 }
63
64 // -------------------------------------------------------------------------
65 void cpPlugins::Interface::Plugins::
66 BlockWidget( )
67 {
68 #ifdef cpPlugins_Interface_QT4
69   if( this->m_Widget != NULL )
70   {
71     QApplication::setOverrideCursor( Qt::WaitCursor );
72     this->m_Widget->setEnabled( false );
73
74   } // fi
75 #endif // cpPlugins_Interface_QT4
76 }
77
78 // -------------------------------------------------------------------------
79 void cpPlugins::Interface::Plugins::
80 UnblockWidget( )
81 {
82 #ifdef cpPlugins_Interface_QT4
83   if( this->m_Widget != NULL )
84   {
85     QApplication::restoreOverrideCursor( );
86     this->m_Widget->setEnabled( true );
87
88   } // fi
89 #endif // cpPlugins_Interface_QT4
90 }
91
92 // -------------------------------------------------------------------------
93 void cpPlugins::Interface::Plugins::
94 DialogLoadPlugins( )
95 {
96 #ifdef cpPlugins_Interface_QT4
97   if( this->m_Widget != NULL )
98   {
99     QFileDialog dialog( this->m_Widget );
100     dialog.setFileMode( QFileDialog::ExistingFile );
101     dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
102     dialog.setNameFilter( QFileDialog::tr( PLUGIN_REGEX ) );
103     dialog.setDefaultSuffix( QFileDialog::tr( PLUGIN_EXT ) );
104     if( !( dialog.exec( ) ) )
105       return;
106
107     std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
108     if( !( this->LoadPlugins( fname ) ) )
109       QMessageBox::critical(
110         this->m_Widget,
111         QMessageBox::tr( "Ignoring plugin" ),
112         QMessageBox::tr( fname.c_str( ) )
113         );
114
115   } // fi
116 #endif // cpPlugins_Interface_QT4
117 }
118
119 // -------------------------------------------------------------------------
120 cpPlugins::Interface::
121 BaseApplication* cpPlugins::Interface::Plugins::
122 GetApplication( )
123 {
124   return( this->m_Application );
125 }
126
127 // -------------------------------------------------------------------------
128 const cpPlugins::Interface::
129 BaseApplication* cpPlugins::Interface::Plugins::
130 GetApplication( ) const
131 {
132   return( this->m_Application );
133 }
134
135 // -------------------------------------------------------------------------
136 void cpPlugins::Interface::Plugins::
137 SetApplication( BaseApplication* a )
138 {
139   this->m_Application = a;
140 }
141
142 // -------------------------------------------------------------------------
143 bool cpPlugins::Interface::Plugins::
144 LoadPluginsPath( const std::string& path, bool r )
145 {
146   /* TODO
147   this->BlockWidget( );
148
149   // Load all plugins from given folder
150   std::list< std::string > files =
151     this->m_Interface.LoadFromFolder( path, r );
152
153   // Update a simple track
154   bool ret = false;
155   if( files.size( ) > 0 )
156   {
157     for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
158     {
159       this->m_LoadedPlugins.insert( *fIt );
160       this->m_LastLoadedPlugin = *fIt;
161       ret = true;
162
163     } // rof
164     this->_UpdateLoadedPluginsInformation( );
165
166   } // fi
167
168   this->UnblockWidget( );
169   return( ret );
170   */
171   return( false );
172 }
173
174 // -------------------------------------------------------------------------
175 bool cpPlugins::Interface::Plugins::
176 LoadPlugins( const std::string& fname )
177 {
178   this->BlockWidget( );
179
180   // Is it already loaded?
181   bool ret = true;
182   if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
183   {
184     // Was it succesfully loaded?
185     ret = this->m_Interface.Load( fname );
186
187     // Update a simple track
188     if( ret )
189     {
190       this->m_LoadedPlugins.insert( fname );
191       this->m_LastLoadedPlugin = fname;
192       this->_UpdateLoadedPluginsInformation( );
193
194     } // fi
195
196   } // fi
197
198   this->UnblockWidget( );
199   return( ret );
200 }
201
202 // -------------------------------------------------------------------------
203 bool cpPlugins::Interface::Plugins::
204 LoadPluginsConfigurationFile( const std::string& fname )
205 {
206   // Load file into a char buffer
207   std::ifstream in(
208     fname.c_str( ), std::ios::in | std::ios::binary | std::ios::ate
209     );
210   if( !in.is_open( ) )
211     return( false );
212
213   std::streampos size = in.tellg( );
214   char* buffer = new char[ size ];
215   in.seekg( 0, std::ios::beg );
216   in.read( buffer, size );
217   in.close( );
218
219   // Read stream
220   std::stringstream in_stream( buffer );
221   char line[ 4096 ];
222   while( in_stream )
223   {
224     in_stream.getline( line, 4096 );
225     this->LoadPlugins( line );
226
227   } // elihw
228   delete buffer;
229
230   return( true );
231 }
232
233 // -------------------------------------------------------------------------
234 const cpPlugins::Interface::Plugins::
235 TStringContainer& cpPlugins::Interface::Plugins::
236 GetLoadedPlugins( ) const
237 {
238   return( this->m_LoadedPlugins );
239 }
240
241 // -------------------------------------------------------------------------
242 void cpPlugins::Interface::Plugins::
243 GetLoadedCategories( TStringContainer& categories ) const
244 {
245   categories.clear( );
246   auto fIt = this->m_LoadedFilters.begin( );
247   for( ; fIt != this->m_LoadedFilters.end( ); ++fIt )
248     categories.insert( fIt->first );
249 }
250
251 // -------------------------------------------------------------------------
252 void cpPlugins::Interface::Plugins::
253 GetLoadedFilters( TStringContainer& filters ) const
254 {
255   filters.clear( );
256   auto pIt = this->m_LoadedFilters.begin( );
257   for( ; pIt != this->m_LoadedFilters.end( ); ++pIt )
258     for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt )
259       filters.insert( *fIt );
260 }
261
262 // -------------------------------------------------------------------------
263 const cpPlugins::Interface::Plugins::
264 TStringContainer& cpPlugins::Interface::Plugins::
265 GetLoadedFilters( const std::string& category ) const
266 {
267   static const TStringContainer EMPTY;
268   auto pIt = this->m_LoadedFilters.find( category );
269   if( pIt != this->m_LoadedFilters.end( ) )
270     return( pIt->second );
271   else
272     return( EMPTY );
273 }
274
275 // -------------------------------------------------------------------------
276 void cpPlugins::Interface::Plugins::
277 AddInteractor( vtkRenderWindowInteractor* interactor )
278 {
279   this->m_Interactors.insert( interactor );
280 }
281
282 // -------------------------------------------------------------------------
283 void cpPlugins::Interface::Plugins::
284 RemoveInteractor( vtkRenderWindowInteractor* interactor )
285 {
286   this->m_Interactors.erase( interactor );
287 }
288
289 // -------------------------------------------------------------------------
290 void cpPlugins::Interface::Plugins::
291 ClearInteractors( )
292 {
293   this->m_Interactors.clear( );
294 }
295
296 // -------------------------------------------------------------------------
297 #define cpPlugins_Plugins_HasMacro( F )                                 \
298   bool cpPlugins::Interface::Plugins::                                  \
299   Has##F( ) const                                                       \
300   {                                                                     \
301     return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \
302   }
303
304 cpPlugins_Plugins_HasMacro( ImageReader );
305 cpPlugins_Plugins_HasMacro( DicomSeriesReader );
306 cpPlugins_Plugins_HasMacro( MeshReader );
307 cpPlugins_Plugins_HasMacro( ImageWriter );
308 cpPlugins_Plugins_HasMacro( MeshWriter );
309
310 // -------------------------------------------------------------------------
311 std::string cpPlugins::Interface::Plugins::
312 ReadImage( const std::string& fname, const std::string& parent )
313 {
314   std::vector< std::string > fnames( 1, fname );
315   return( this->ReadImage( fnames, parent ) );
316 }
317
318 // -------------------------------------------------------------------------
319 std::string cpPlugins::Interface::Plugins::
320 ReadImage(
321   const std::vector< std::string >& fnames, const std::string& parent
322   )
323 {
324   // Load source
325   this->_ActivateIOFilter( "ImageReader" );
326
327   // Configure reader
328   TParameters* params = this->GetActiveFilterParameters( );
329   params->ClearStringList( "FileNames" );
330   for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt )
331     params->AddToStringList( "FileNames", *nIt );
332
333   // Execute filter
334   return( this->_ReadData( parent ) );
335 }
336
337 // -------------------------------------------------------------------------
338 std::string cpPlugins::Interface::Plugins::
339 ReadImage( const std::string& parent )
340 {
341   // Load source
342   this->_ActivateIOFilter( "ImageReader" );
343
344   // Try to configure source
345   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
346   {
347     this->DeactivateFilter( );
348     return( "" );
349
350   } // fi
351
352   // Execute filter
353   return( this->_ReadData( parent ) );
354 }
355
356 // -------------------------------------------------------------------------
357 std::string cpPlugins::Interface::Plugins::
358 ReadDicomSeries( const std::string& parent )
359 {
360   // Load source
361   this->_ActivateIOFilter( "DicomSeriesReader" );
362
363   // Try to configure source
364   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
365   {
366     this->DeactivateFilter( );
367     return( "" );
368
369   } // fi
370
371   // Execute filter
372   return( this->_ReadData( parent ) );
373 }
374
375 // -------------------------------------------------------------------------
376 std::string cpPlugins::Interface::Plugins::
377 ReadMesh( const std::string& fname, const std::string& parent )
378 {
379   // Load source
380   this->_ActivateIOFilter( "MeshReader" );
381
382   // Configure reader
383   TParameters* params = this->GetActiveFilterParameters( );
384   params->SetString( "FileName", fname );
385
386   // Execute filter
387   return( this->_ReadData( parent ) );
388 }
389
390 // -------------------------------------------------------------------------
391 std::string cpPlugins::Interface::Plugins::
392 ReadMesh( const std::string& parent )
393 {
394   // Load source
395   this->_ActivateIOFilter( "MeshReader" );
396
397   // Try to configure source
398   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
399   {
400     this->DeactivateFilter( );
401     return( "" );
402
403   } // fi
404
405   // Execute filter
406   return( this->_ReadData( parent ) );
407 }
408
409 // -------------------------------------------------------------------------
410 bool cpPlugins::Interface::Plugins::
411 WriteDataObject( const std::string& fname, const std::string& name )
412 {
413   typedef cpPlugins::Interface::Image _TImage;
414   typedef cpPlugins::Interface::Mesh  _TMesh;
415
416   // Activate sink
417   TDataObject* obj = this->GetData< TDataObject >( name );
418   if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
419     this->_ActivateIOFilter( "ImageWriter" );
420   else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
421     this->_ActivateIOFilter( "MeshWriter" );
422   else
423   {
424     this->DeactivateFilter( );
425     return( false );
426
427   } // fi
428
429   // Configure writer
430   TParameters* params = this->GetActiveFilterParameters( );
431   params->SetString( "FileName", fname );
432
433   // Execute filter
434   return( this->_WriteData( name ) );
435 }
436
437 // -------------------------------------------------------------------------
438 bool cpPlugins::Interface::Plugins::
439 WriteDataObject( const std::string& name )
440 {
441   typedef cpPlugins::Interface::Image _TImage;
442   typedef cpPlugins::Interface::Mesh  _TMesh;
443
444   // Activate sink
445   TDataObject* obj = this->GetData< TDataObject >( name );
446   if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
447     this->_ActivateIOFilter( "ImageWriter" );
448   else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
449     this->_ActivateIOFilter( "MeshWriter" );
450   else
451   {
452     this->DeactivateFilter( );
453     return( false );
454
455   } // fi
456
457   // Try to configure source
458   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
459   {
460     this->DeactivateFilter( );
461     return( false );
462
463   } // fi
464
465   // Execute filter
466   return( this->_WriteData( name ) );
467 }
468
469 // -------------------------------------------------------------------------
470 void cpPlugins::Interface::Plugins::
471 ClearDataObjects( )
472 {
473   this->m_DataObjects.clear( );
474 }
475
476 // -------------------------------------------------------------------------
477 void cpPlugins::Interface::Plugins::
478 DeleteDataObject( const std::string& name )
479 {
480   // Find and delete object
481   auto oIt = this->m_DataObjects.find( name );
482   if( oIt == this->m_DataObjects.end( ) )
483     return;
484   this->m_DataObjects.erase( oIt );
485
486   // Delete children
487   TStringContainer children;
488   this->GetChildren( children, name );
489   auto cIt = children.begin( );
490   for( ; cIt != children.end( ); ++cIt )
491     this->DeleteDataObject( *cIt );
492 }
493
494 // -------------------------------------------------------------------------
495 void cpPlugins::Interface::Plugins::
496 GetDataObjects( TStringContainer& names )
497 {
498   names.clear( );
499   auto oIt = this->m_DataObjects.begin( );
500   for( ; oIt != this->m_DataObjects.end( ); ++oIt )
501     names.insert( oIt->first );
502 }
503
504 // -------------------------------------------------------------------------
505 std::string cpPlugins::Interface::Plugins::
506 GetParent( const std::string& name ) const
507 {
508   // Find and delete object
509   auto oIt = this->m_DataObjects.find( name );
510   if( oIt != this->m_DataObjects.end( ) )
511     return( oIt->second.first );
512   else
513     return( "" );
514 }
515
516 // -------------------------------------------------------------------------
517 void cpPlugins::Interface::Plugins::
518 GetChildren( TStringContainer& names, const std::string& name ) const
519 {
520   names.clear( );
521   auto oIt = this->m_DataObjects.begin( );
522   for( ; oIt != this->m_DataObjects.end( ); ++oIt )
523     if( oIt->second.first == name )
524       names.insert( oIt->first );
525 }
526
527 // -------------------------------------------------------------------------
528 void cpPlugins::Interface::Plugins::
529 GetRoots( TStringContainer& names ) const
530 {
531   this->GetChildren( names, "" );
532 }
533
534 // -------------------------------------------------------------------------
535 bool cpPlugins::Interface::Plugins::
536 ActivateFilter( const std::string& name )
537 {
538   this->m_ActiveFilter = this->m_Interface.CreateObject( name );
539   if( this->m_ActiveFilter.IsNotNull( ) )
540   {
541     this->m_ActiveFilter->SetPlugins( this );
542     auto iIt = this->m_Interactors.begin( );
543     for( ; iIt != this->m_Interactors.end( ); ++iIt )
544       this->m_ActiveFilter->AddInteractor( *iIt );
545     return( true );
546   }
547   else
548     return( false );
549 }
550
551 // -------------------------------------------------------------------------
552 void cpPlugins::Interface::Plugins::
553 DeactivateFilter( )
554 {
555   if( this->m_ActiveFilter.IsNotNull( ) )
556     this->m_ActiveFilter->DisconnectOutputs( );
557   this->m_ActiveFilter = NULL;
558 }
559
560 // -------------------------------------------------------------------------
561 bool cpPlugins::Interface::Plugins::
562 HasActiveFilter( ) const
563 {
564   return( this->m_ActiveFilter.IsNotNull( ) );
565 }
566
567 // -------------------------------------------------------------------------
568 bool cpPlugins::Interface::Plugins::
569 IsActiveFilterInteractive( ) const
570 {
571   if( this->m_ActiveFilter.IsNotNull( ) )
572     return( this->m_ActiveFilter->GetInteractive( ) );
573   else
574     return( false );
575 }
576
577 // -------------------------------------------------------------------------
578 void cpPlugins::Interface::Plugins::
579 GetActiveFilterInputsNames( TStringContainer& names ) const
580 {
581   if( this->m_ActiveFilter.IsNotNull( ) )
582     this->m_ActiveFilter->GetInputsNames( names );
583 }
584
585 // -------------------------------------------------------------------------
586 void cpPlugins::Interface::Plugins::
587 GetActiveFilterOutputsNames( TStringContainer& names ) const
588 {
589   if( this->m_ActiveFilter.IsNotNull( ) )
590     this->m_ActiveFilter->GetOutputsNames( names );
591 }
592
593 // -------------------------------------------------------------------------
594 bool cpPlugins::Interface::Plugins::
595 ConnectInputInActiveFilter(
596   const std::string& object_name, const std::string& input_name
597   )
598 {
599   if( this->m_ActiveFilter.IsNotNull( ) )
600   {
601     TDataObject* dobj = this->GetData< TDataObject >( object_name );
602     if( dobj != NULL )
603     {
604       this->m_ActiveFilter->SetInput( input_name, dobj );
605       return( true );
606
607     } // fi
608
609   } // fi
610   return( false );
611 }
612
613 // -------------------------------------------------------------------------
614 bool cpPlugins::Interface::Plugins::
615 SetOutputNameInActiveFilter(
616   const std::string& new_object_name, const std::string& output_name
617   )
618 {
619   if( this->m_ActiveFilter.IsNotNull( ) )
620     return(
621       this->m_ActiveFilter->SetOutputObjectName(
622         new_object_name, output_name
623         )
624       );
625   else
626     return( false );
627 }
628
629 // -------------------------------------------------------------------------
630 cpPlugins::Interface::Plugins::
631 TParameters* cpPlugins::Interface::Plugins::
632 GetActiveFilterParameters( )
633 {
634   if( this->m_ActiveFilter.IsNotNull( ) )
635     return( this->m_ActiveFilter->GetParameters( ) );
636   else
637     return( NULL );
638 }
639
640 // -------------------------------------------------------------------------
641 const cpPlugins::Interface::Plugins::
642 TParameters* cpPlugins::Interface::Plugins::
643 GetActiveFilterParameters( ) const
644 {
645   if( this->m_ActiveFilter.IsNotNull( ) )
646     return( this->m_ActiveFilter->GetParameters( ) );
647   else
648     return( NULL );
649 }
650
651 // -------------------------------------------------------------------------
652 cpPlugins::Interface::Plugins::
653 TProcessObject::DialogResult cpPlugins::Interface::Plugins::
654 ConfigureActiveFilter( )
655 {
656   if( this->m_ActiveFilter.IsNotNull( ) )
657     return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) );
658   else
659     return( TProcessObject::DialogResult_Cancel );
660 }
661
662 // -------------------------------------------------------------------------
663 bool cpPlugins::Interface::Plugins::
664 UpdateActiveFilter( TStringContainer& outputs, const std::string& parent )
665 {
666   if( this->m_ActiveFilter.IsNull( ) )
667     return( false );
668   
669   // Execute filter
670   this->BlockWidget( );
671   std::string err = this->m_ActiveFilter->Update( );
672   this->UnblockWidget( );
673
674   // Associate outputs
675   outputs.clear( );
676   if( err == "" )
677   {
678     std::set< std::string > names;
679     this->m_ActiveFilter->GetOutputsNames( names );
680     for( auto oIt = names.begin( ); oIt != names.end( ); ++oIt )
681     {
682       TDataObject* dobj =
683         this->m_ActiveFilter->GetOutput< TDataObject >( *oIt );
684
685       if( std::string( dobj->GetName( ) ) == std::string( "" ) )
686         dobj->SetName(
687           this->m_ActiveFilter->GetName( ) + std::string( "_" ) + *oIt
688           );
689       this->_InsertNewData( dobj, parent );
690       outputs.insert( dobj->GetName( ) );
691
692     } // rof
693     // this->m_ActiveFilter->DisconnectOutputs( );
694     return( true );
695   }
696   else
697   {
698 #ifdef cpPlugins_Interface_QT4
699     if( this->m_Widget != NULL )
700       QMessageBox::critical(
701         this->m_Widget,
702         QMessageBox::tr( "Error reading image." ),
703         QMessageBox::tr( err.c_str( ) )
704         );
705     else
706       throw std::runtime_error(
707         std::string( "Error reading image: " ) + err
708         );
709 #else // cpPlugins_Interface_QT4
710     throw std::runtime_error(
711       std::string( "Error reading image: " ) + err
712       );
713 #endif // cpPlugins_Interface_QT4
714     return( false );
715
716   } // fi
717 }
718
719 // -------------------------------------------------------------------------
720 void cpPlugins::Interface::Plugins::
721 _UpdateLoadedPluginsInformation( )
722 {
723   this->m_LoadedFilters.clear( );
724   const TInterface::TClasses& cls = this->m_Interface.GetClasses( );
725   for( auto i = cls.begin( ); i != cls.end( ); ++i )
726   {
727     TProcessObject::Pointer o = this->m_Interface.CreateObject( i->first );
728     std::string name = o->GetClassName( );
729     std::string category = o->GetClassCategory( );
730
731     if(
732       category == "ImageReader" ||
733       category == "ImageWriter" ||
734       category == "MeshReader" ||
735       category == "MeshWriter" ||
736       category == "DicomSeriesReader"
737       )
738       this->m_IOFilters[ category ] = o;
739     else
740       this->m_LoadedFilters[ category ].insert( name );
741
742   } // rof
743 }
744
745 // -------------------------------------------------------------------------
746 bool cpPlugins::Interface::Plugins::
747 _ActivateIOFilter( const std::string& filter )
748 {
749   // Activate reader
750   auto fIt = this->m_IOFilters.find( filter );
751   if( fIt != this->m_IOFilters.end( ) )
752   {
753     this->m_ActiveFilter = fIt->second;
754     return( true );
755   }
756   else
757     return( false );
758 }
759
760 // -------------------------------------------------------------------------
761 std::string cpPlugins::Interface::Plugins::
762 _ReadData( const std::string& parent )
763 {
764   if( !( this->HasActiveFilter( ) ) )
765     return( "" );
766
767   TStringContainer outputs;
768   if( this->UpdateActiveFilter( outputs, parent ) )
769     return( *( outputs.begin( ) ) );
770   else
771     return( "" );
772 }
773
774 // ------------------------------------------------------------------------
775 bool cpPlugins::Interface::Plugins::
776 _WriteData( const std::string& name )
777 {
778   if( !( this->HasActiveFilter( ) ) )
779     return( false );
780
781   TStringContainer inputs;
782   this->GetActiveFilterInputsNames( inputs );
783   bool r = true;
784   for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )
785     r &= this->ConnectInputInActiveFilter( name, *iIt );
786
787   if( r )
788   {
789     TStringContainer outputs;
790     return( this->UpdateActiveFilter( outputs, "" ) );
791   }
792   else
793     return( false );
794 }
795
796 // -------------------------------------------------------------------------
797 bool cpPlugins::Interface::Plugins::
798 _InsertNewData( TDataObject* dobj, const std::string& parent )
799 {
800   if( parent != "" )
801   {
802     auto oIt = this->m_DataObjects.find( parent );
803     if( oIt == this->m_DataObjects.end( ) )
804       return( false );
805
806   } // fi
807   this->m_DataObjects[ dobj->GetName( ) ] = _TTreeNode( parent, dobj );
808   return( true );
809 }
810
811 // eof - $RCSfile$