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