]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface.h
Code cleaning
[cpPlugins.git] / lib / cpPlugins / Interface.h
1 #ifndef __CPPLUGINS__INTERFACE__H__
2 #define __CPPLUGINS__INTERFACE__H__
3
4 #include <cpPlugins/Config.h>
5 #include <cpPlugins/ProcessObject.h>
6 #include <map>
7 #include <set>
8 #include <utility>
9 #include <vector>
10
11 /* TODO
12    #include <string>
13 */
14
15 namespace cpPlugins
16 {
17   /**
18    */
19   class cpPlugins_EXPORT Interface
20   {
21   public:
22     typedef Interface Self;
23
24     typedef void* ( *TCreator )( );
25     typedef std::map< std::string, void* > TLibraries;
26     struct TCreatorData
27     {
28       std::string PluginName;
29       void*       LibraryHandle;
30       TCreator    Creator;
31     };
32     typedef std::map< std::string, std::map< std::string, TCreatorData > > TFilters;
33
34     /* TODO
35        typedef std::pair< std::string, TCreator >               TDynFunc;
36        typedef std::map< std::string, TDynFunc >                TDynFilter;
37        typedef std::map< std::string, TDynFilter >              TDynFilters;
38        typedef std::pair< std::string, void* >                  TDynFileInfo;
39        typedef std::map< std::string, TDynFileInfo >            TDynLibraries;
40     */
41
42   public:
43     Interface( );
44     virtual ~Interface( );
45
46     const std::set< std::string >& GetPaths( ) const;
47     std::set< std::string > GetLibraries( ) const;
48     std::set< std::string > GetPlugins( ) const;
49     std::set< std::string > GetCategories( ) const;
50     std::set< std::string > GetFilters( const std::string& category ) const;
51
52     void UpdateEnvironments( const std::string& new_environment );
53     void LoadEnvironment( );
54     void LoadFile( const std::string& fname );
55     void LoadPlugin( const std::string& pname );
56     void LoadDirectory( const std::string& dirname );
57     void GuessPlugins( );
58
59     cpPlugins::ProcessObject::Pointer CreateProcessObject(
60       const std::string& category, const std::string& name
61       );
62
63   protected:
64     std::set< std::string > m_Paths;
65     TLibraries m_Libraries;
66     TLibraries m_Plugins;
67     TFilters m_Filters;
68
69
70     /* TODO
71        const TFilters& GetFilters( );
72
73        void UpdatePaths( );
74        void GuessAccesiblePlugins( );
75        void LoadPlugin( const std::string& name );
76        void LoadPluginDir( const std::string& dirname );
77        void LoadPluginFile( const std::string& filename );
78        void UnloadAll( );
79
80        ProcessObject::Pointer Create(
81        const std::string& category, const std::string& name
82        );
83        std::string GetPluginName(
84        const std::string& category, const std::string& name
85        ) const;
86        std::string GetPluginName( const ProcessObject* obj ) const;
87        std::set< std::string > GetPlugins( ) const;
88
89        protected:
90        static void* _DLOpen( const std::string& fname, std::string& error );
91        static const char* _DLGetName( void* hnd );
92        static TFilters _DLGetFilters( void* hnd );
93        static TCreator _DLGetCreator(
94        void* hnd, const std::string& category, const std::string& name
95        );
96        static void _DLClose( void* hnd );
97
98        protected:
99        std::vector< std::string > m_Paths;
100        TDynLibraries m_DynLibraries;
101        TDynFilters   m_DynFilters;
102        TFilters      m_Filters;
103
104        static unsigned int InterfacesCount;
105     */
106   };
107
108 } // ecapseman
109
110 #endif // __CPPLUGINS__INTERFACE__H__
111
112 // eof - $RCSfile$