X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FPlugins.h;h=7b5d9beb72d5db028b6978e763b6d0f2ca6df104;hb=bfc16201a35d40fb90f8a354307dca5942fc0fcd;hp=5bf887cb46171689556ebca407814f317798f5e9;hpb=ad814fa27df55cd06a071e474e56efc27f9f8fa5;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Plugins.h b/lib/cpPlugins/Interface/Plugins.h index 5bf887c..7b5d9be 100644 --- a/lib/cpPlugins/Interface/Plugins.h +++ b/lib/cpPlugins/Interface/Plugins.h @@ -1,173 +1,90 @@ -#ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__ -#define __CPPLUGINS__INTERFACE__PLUGINS__H__ - -#include -#include -#include - -#include -#include -#include -#include - -// Some forward declarations -class vtkRenderWindowInteractor; -#ifdef cpPlugins_Interface_QT4 -class QWidget; -#else -typedef char QWidget; -#endif // cpPlugins_Interface_QT4 +#ifndef __cpPlugins__Interface__Plugins__h__ +#define __cpPlugins__Interface__Plugins__h__ + +#include +#include +#include namespace cpPlugins { namespace Interface { - // Some forward declarations - class BaseApplication; - /** */ - class cpPlugins_Interface_EXPORT Plugins + class cpPlugins_EXPORT Plugins + : public itk::Object { public: - typedef cpPlugins::Interface::Interface TInterface; - typedef cpPlugins::Interface::ProcessObject TProcessObject; - typedef cpPlugins::Interface::DataObject TDataObject; - typedef TProcessObject::TParameters TParameters; - - typedef std::set< std::string > TStringContainer; + typedef Plugins Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef void* ( *TCreator )( ); + typedef std::map< std::string, void* > TLibraries; + struct TCreatorData + { + std::string PluginName; + void* LibraryHandle; + TCreator Creator; + }; + typedef std::map< std::string, TCreatorData > TFilterData; + typedef std::map< std::string, TFilterData > TFilters; + typedef std::set< std::string > TStrings; + + typedef cpPlugins::BaseObjects::ProcessObject TProcess; public: - Plugins( ); - virtual ~Plugins( ); - - // Qt oriented methods - QWidget* GetWidget( ); - const QWidget* GetWidget( ) const; - void SetWidget( QWidget* widget ); - void BlockWidget( ); - void UnblockWidget( ); - void DialogLoadPlugins( ); - - // Connection to main application - BaseApplication* GetApplication( ); - const BaseApplication* GetApplication( ) const; - void SetApplication( BaseApplication* a ); - - // Plugins management - bool LoadPluginsPath( const std::string& path ); - bool LoadPlugins( const std::string& fname ); - bool LoadPluginsConfigurationFile( const std::string& fname ); - const TStringContainer& GetLoadedPlugins( ) const; - void GetLoadedCategories( TStringContainer& categories ) const; - void GetLoadedFilters( TStringContainer& filters ) const; - const TStringContainer& GetLoadedFilters( - const std::string& category - ) const; - - // Interactors - void AddInteractor( vtkRenderWindowInteractor* interactor ); - void RemoveInteractor( vtkRenderWindowInteractor* interactor ); - void ClearInteractors( ); - - // Data IO - bool HasImageReader( ) const; - bool HasDicomSeriesReader( ) const; - bool HasMeshReader( ) const; - bool HasImageWriter( ) const; - bool HasMeshWriter( ) const; - - std::string ReadImage( - const std::string& fname, const std::string& parent - ); - std::string ReadImage( - const std::vector< std::string >& fnames, const std::string& parent - ); - std::string ReadImage( const std::string& parent ); - std::string ReadDicomSeries( const std::string& parent ); - std::string ReadMesh( - const std::string& fname, const std::string& parent - ); - std::string ReadMesh( const std::string& parent ); + itkTypeMacro( Plugins, itk::Object ); + itkGetConstMacro( Paths, TStrings ); - bool WriteDataObject( - const std::string& fname, const std::string& name - ); - bool WriteDataObject( const std::string& name ); - - // Data objects - void ClearDataObjects( ); - void DeleteDataObject( const std::string& name ); - void GetDataObjects( TStringContainer& names ); - std::string GetParent( const std::string& name ) const; - void GetChildren( - TStringContainer& names, const std::string& name - ) const; - void GetRoots( TStringContainer& names ) const; - - template< class T > - inline T* GetData( const std::string& name ); - - template< class T > - inline const T* GetData( const std::string& name ) const; - - // Filter acces - bool ActivateFilter( const std::string& name ); - void DeactivateFilter( ); - bool HasActiveFilter( ) const; - bool IsActiveFilterInteractive( ) const; - void GetActiveFilterInputsNames( TStringContainer& names ) const; - void GetActiveFilterOutputsNames( TStringContainer& names ) const; - bool ConnectInputInActiveFilter( - const std::string& object_name, const std::string& input_name - ); - bool SetOutputNameInActiveFilter( - const std::string& new_object_name, const std::string& output_name - ); - TParameters* GetActiveFilterParameters( ); - const TParameters* GetActiveFilterParameters( ) const; - TProcessObject::DialogResult ConfigureActiveFilter( ); - bool UpdateActiveFilter( - TStringContainer& outputs, - const std::string& parent + public: + static Pointer New( ); + virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE; + Pointer Clone( ) const; + + TStrings GetLibraries( ) const; + TStrings GetPlugins( ) const; + TStrings GetCategories( ) const; + TStrings GetFilters( const std::string& category ) const; + + void AddEnvironments( const std::string& new_environment ); + void LoadEnvironments( ); + void SaveEnvironments( const std::string& dir ) const; + void OpenEnvironments( const std::string& dir ); + + void LoadFile( const std::string& fname ); + void LoadPlugin( const std::string& pname ); + void LoadDirectory( const std::string& dirname ); + void GuessPlugins( ); + + TProcess::Pointer CreateProcessObject( + const std::string& category, const std::string& name ); protected: - void _UpdateLoadedPluginsInformation( ); - bool _ActivateIOFilter( const std::string& filter ); - std::string _ReadData( const std::string& parent ); - bool _WriteData( const std::string& name ); - bool _InsertNewData( TDataObject* dobj, const std::string& parent ); + Plugins( ); + virtual ~Plugins( ); + virtual void PrintSelf( + std::ostream& os, itk::Indent indent + ) const cpPlugins_OVERRIDE; + + private: + // Purposely not implemented + Plugins( const Self& other ); + Self& operator=( const Self& other ); protected: - // MVC objects - QWidget* m_Widget; - BaseApplication* m_Application; - - // Plugins interface - TInterface m_Interface; - TStringContainer m_LoadedPlugins; - std::string m_LastLoadedPlugin; - std::map< std::string, TStringContainer > m_LoadedFilters; - - // Loaded filters - std::map< std::string, TProcessObject::Pointer > m_IOFilters; - TProcessObject::Pointer m_ActiveFilter; - - // Loaded data objects - typedef std::pair< std::string, TDataObject::Pointer > _TTreeNode; - std::map< std::string, _TTreeNode > m_DataObjects; - - // Associated interactors - std::set< vtkRenderWindowInteractor* > m_Interactors; + TStrings m_Paths; + TLibraries m_Libraries; + TLibraries m_Plugins; + TFilters m_Filters; }; } // ecapseman } // ecapseman -#include - -#endif // __CPPLUGINS__INTERFACE__PLUGINS__H__ +#endif // __cpPlugins__Interface__Plugins__h__ // eof - $RCSfile$