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