]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Loader.h
yet another refactoring
[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 > >
27       TFiltersToLibrariesReferences;
28
29     public:
30       Loader( );
31       virtual ~Loader( );
32
33       void Register( const std::string& filename );
34       void RegisterFromDirectory( const std::string& dirname );
35       void GuessEnvironment( const std::string& dirname );
36       void SaveEnvironment( const std::string& dirname );
37       void UnRegister( const std::string& filename );
38       void UnRegisterAll( );
39
40       std::map< std::string, std::set< std::string > > GetFilters( ) const;
41
42       cpPlugins::Pipeline::ProcessObject::Pointer CreateFilter(
43         const std::string& category, const std::string& filter,
44         const std::string& name = ""
45         );
46
47     protected:
48       static TLibraries m_Libraries;
49       static TFiltersToLibrariesReferences m_References;
50
51     public:
52       friend std::ostream& operator<<( std::ostream& o, const Loader& l )
53         {
54           o << "cpPlugins:" << std::endl;
55           for( auto c : l.m_References )
56           {
57             o << "  + " << c.first << std::endl;
58             for( auto f : c.second )
59               o << "  |--> " << f.first << " (" << f.second << ")" << std::endl;
60
61           } // rof
62           return( o );
63         }
64     };
65
66   } // ecapseman
67
68 } // ecapseman
69
70 #endif // __cpPlugins__Interface__Loader__h__
71
72 // eof - $RCSfile$