]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Loader.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Loader.h
1 #ifndef __cpPlugins__Interface__Loader__h__
2 #define __cpPlugins__Interface__Loader__h__
3
4 #include <cpPlugins/Config.h>
5 #include <cpPlugins/Pipeline/ProcessObject.h>
6 #include <iostream>
7 #include <map>
8 #include <vector>
9
10 namespace cpPlugins
11 {
12   namespace Interface
13   {
14     /**
15      */
16     class cpPlugins_EXPORT Loader
17     {
18     public:
19       typedef Loader Self;
20
21     public:
22       typedef void ( *TContentsFunc )( std::vector< std::string >* );
23       typedef void ( *TCreatorFunc )( itk::LightObject::Pointer& ptr, const std::string& c, const std::string& f );
24       typedef std::tuple< void*, TContentsFunc, TCreatorFunc > THandlers;
25       typedef std::map< std::string, THandlers > TLibraries;
26       typedef std::map< std::string, std::map< std::string, std::string > > TFiltersToLibrariesReferences;
27
28     public:
29       Loader( );
30       virtual ~Loader( );
31
32       void Register( const std::string& filename );
33       void RegisterFromDirectory( const std::string& dirname );
34       void GuessEnvironment( const std::string& dirname );
35       void SaveEnvironment( const std::string& dirname );
36       void UnRegister( const std::string& filename );
37       void UnRegisterAll( );
38
39       std::map< std::string, std::set< std::string > > GetFilters( ) const;
40
41       cpPlugins::Pipeline::ProcessObject::Pointer CreateFilter(
42         const std::string& category, const std::string& filter,
43         const std::string& name = ""
44         );
45
46     protected:
47       static TLibraries m_Libraries;
48       static TFiltersToLibrariesReferences m_References;
49
50     public:
51       friend std::ostream& operator<<( std::ostream& o, const Loader& l )
52         {
53           o << "cpPlugins:" << std::endl;
54           for( auto c : l.m_References )
55           {
56             o << "  + " << c.first << std::endl;
57             for( auto f : c.second )
58               o << "  |--> " << f.first << " (" << f.second << ")" << std::endl;
59
60           } // rof
61           return( o );
62         }
63     };
64
65   } // ecapseman
66
67 } // ecapseman
68
69 #endif // __cpPlugins__Interface__Loader__h__
70
71 // eof - $RCSfile$