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