]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Interface.h
6dbcb4c7ebd1b32f4c7da2be3403fcb20523e55a
[cpPlugins.git] / lib / cpPlugins / Interface / Interface.h
1 #ifndef __CPPLUGINS__INTERFACE__INTERFACE__H__
2 #define __CPPLUGINS__INTERFACE__INTERFACE__H__
3
4 #include <map>
5 #include <string>
6 #include <vector>
7
8 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
9 #include <cpPlugins/Interface/Object.h>
10 #include <cpPlugins/Interface/ProcessObject.h>
11
12 // Some forward declarations
13 namespace pluma
14 {
15   class Pluma;
16 }
17
18 namespace cpPlugins
19 {
20   namespace Interface
21   {
22     // Some forward declarations
23     class ProcessObjectProvider;
24
25     /**
26      */
27     class cpPlugins_Interface_EXPORT Interface
28     {
29     public:
30       typedef Interface Self;
31       typedef std::vector< ProcessObjectProvider* > TProviders;
32       typedef std::map< std::string, unsigned int > TClass;
33       typedef std::map< std::string, TClass >       TClasses;
34       typedef
35         std::map< std::string, std::vector< std::string > >
36         TLoadedPlugins;
37
38       typedef TProviders::const_iterator TProvidersIterator;
39       typedef TClasses::const_iterator   TClassesIterator;
40
41     public:
42       Interface( );
43       virtual ~Interface( );
44
45       bool LoadDefaultConfiguration( const std::string& path );
46       bool SaveDefaultConfiguration( const std::string& path );
47
48       // Plugin access
49       TClasses& GetClasses( );
50       const TClasses& GetClasses( ) const;
51       TLoadedPlugins& GetLoadedPlugins( );
52       const TLoadedPlugins& GetLoadedPlugins( ) const;
53       ProcessObject::Pointer CreateObject( const std::string& name ) const;
54
55       // Interface to PLUMA
56       bool Load( const std::string& path );
57       bool Load( const std::string& folder, const std::string& name );
58       bool LoadFromFolder( const std::string& folder, bool r = false );
59       bool Unload( const std::string& name );
60       void UnloadAll( );
61       bool IsLoaded( const std::string& name ) const;
62
63     protected:
64       void _LoadClasses( );
65
66       static void _SepFName(
67         const std::string& path,
68         std::string& folder,
69         std::string& name
70         );
71
72     protected:
73       pluma::Pluma*  m_Pluma;
74       TProviders     m_Providers;
75       TClasses       m_Classes;
76       TLoadedPlugins m_LoadedPlugins;
77     };
78
79   } // ecapseman
80
81 } // ecapseman
82
83 #endif // __CPPLUGINS__INTERFACE__INTERFACE__H__
84
85 // eof - $RCSfile$