]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
XML IO added. Workspace singleton added to simplify pipeline definition and execution.
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
1 #ifndef __CPPLUGINS__INTERFACE__WORKSPACE__H__
2 #define __CPPLUGINS__INTERFACE__WORKSPACE__H__
3
4 #include <cpPlugins/Interface/Interface.h>
5 #include <cpPlugins/Interface/DataObject.h>
6 #include <cpPlugins/Interface/ProcessObject.h>
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 namespace cpPlugins
13 {
14   namespace Interface
15   {
16     /**
17      */
18     class cpPlugins_Interface_EXPORT Workspace
19     {
20     public:
21       typedef cpPlugins::Interface::Interface     TInterface;
22       typedef cpPlugins::Interface::Object        TObject;
23       typedef cpPlugins::Interface::ProcessObject TFilter;
24       typedef cpPlugins::Interface::DataObject    TData;
25       typedef TFilter::TParameters                TParameters;
26
27       // Various types
28       typedef std::set< std::string > TStringContainer;
29
30       // Graph types
31       typedef std::map< std::string, TObject::Pointer > TVertices;
32       typedef std::pair< std::string, std::string >     TConnection;
33       typedef std::vector< TConnection >                TConnections;
34       typedef std::map< std::string, TConnections >     TAdjMatrixRow;
35       typedef std::map< std::string, TAdjMatrixRow >    TAdjMatrix;
36
37     public:
38       Workspace( );
39       virtual ~Workspace( );
40
41       // Plugins management
42       bool LoadPluginsPath( const std::string& path, bool r = false );
43       bool LoadPlugins( const std::string& fname );
44       const TStringContainer& GetLoadedPlugins( ) const;
45       void GetLoadedPluginCategories( TStringContainer& categories ) const;
46       void GetLoadedPluginFilters( TStringContainer& filters ) const;
47       const TStringContainer& GetLoadedPluginFilters(
48         const std::string& category
49         ) const;
50
51       // Workspace IO
52       std::string LoadWorkspace( const std::string& fname );
53       std::string SaveWorkspace( const std::string& fname ) const;
54
55       // Graph management
56       bool CreateFilter( const std::string& filter, const std::string& name );
57       bool Connect(
58         const std::string& orig_filter, const std::string& dest_filter,
59         const std::string& output_name,
60         const std::string& input_name
61         );
62       TParameters* GetParameters( const std::string& name );
63       const TParameters* GetParameters( const std::string& name ) const;
64
65       // Graph reduction
66       bool Reduce( const std::string& name );
67
68       // Pipeline execution
69       std::string Execute( );
70       std::string Execute( const std::string& name );
71
72     protected:
73       void _UpdateLoadedPluginsInformation( );
74
75     protected:
76       // Plugins interface
77       TInterface       m_Interface;
78       std::string      m_LastLoadedPlugin;
79       TStringContainer m_LoadedPlugins;
80       std::map< std::string, TStringContainer > m_LoadedFilters;
81
82       // Processing graph
83       TVertices  m_Vertices;
84       TAdjMatrix m_AdjMatrix;
85     };
86
87   } // ecapseman
88
89 } // ecapseman
90
91 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
92
93 // eof - $RCSfile$