]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Plugins.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.h
1 #ifndef __cpPlugins__Interface__Plugins__h__
2 #define __cpPlugins__Interface__Plugins__h__
3
4 #include <cpPlugins/Config.h>
5 #include <cpPlugins/BaseObjects/ProcessObject.h>
6 #include <itkObject.h>
7
8 namespace cpPlugins
9 {
10   namespace Interface
11   {
12     /**
13      */
14     class cpPlugins_EXPORT Plugins
15       : public itk::Object
16     {
17     public:
18       typedef Plugins                         Self;
19       typedef itk::Object                     Superclass;
20       typedef itk::SmartPointer< Self >       Pointer;
21       typedef itk::SmartPointer< const Self > ConstPointer;
22
23       typedef void* ( *TCreator )( );
24       typedef std::map< std::string, void* > TLibraries;
25       struct TCreatorData
26       {
27         std::string PluginName;
28         void*       LibraryHandle;
29         TCreator    Creator;
30       };
31       typedef std::map< std::string, TCreatorData > TFilterData;
32       typedef std::map< std::string, TFilterData >  TFilters;
33       typedef std::set< std::string >               TStrings;
34
35       typedef cpPlugins::BaseObjects::ProcessObject TProcess;
36
37     public:
38       itkTypeMacro( Plugins, itk::Object );
39       itkGetConstMacro( Paths, TStrings );
40
41     public:
42       static Pointer New( );
43       virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE;
44       Pointer Clone( ) const;
45
46       TStrings GetLibraries( ) const;
47       TStrings GetPlugins( ) const;
48       TStrings GetCategories( ) const;
49       TStrings GetFilters( const std::string& category ) const;
50
51       void AddEnvironments( const std::string& env );
52       void LoadEnvironments( );
53       void LoadPaths( const std::string& dir );
54       void SavePaths( const std::string& dir ) const;
55
56       void LoadFile( const std::string& fname );
57       void LoadPlugin( const std::string& pname );
58       void LoadDirectory( const std::string& dirname );
59       void GuessPlugins( );
60
61       TProcess::Pointer CreateProcessObject(
62         const std::string& category, const std::string& name
63         );
64
65     protected:
66       Plugins( );
67       virtual ~Plugins( );
68       virtual void PrintSelf(
69         std::ostream& os, itk::Indent indent
70         ) const cpPlugins_OVERRIDE;
71
72     private:
73       // Purposely not implemented
74       Plugins( const Self& other );
75       Self& operator=( const Self& other );
76
77     protected:
78       TStrings   m_Paths;
79       TLibraries m_Libraries;
80       TLibraries m_Plugins;
81       TFilters   m_Filters;
82     };
83
84   } // ecapseman
85
86 } // ecapseman
87
88 #endif // __cpPlugins__Interface__Plugins__h__
89
90 // eof - $RCSfile$