]> 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       typedef std::pair< std::string, std::string > TGlobalPort;
33       typedef std::map< std::string, TGlobalPort >  TGlobalPorts;
34
35       // Graph type
36       typedef std::pair< std::string, std::string > TConnection;
37       typedef
38         cpExtensions::DataStructures::
39         Graph< TObject::Pointer, TConnection, std::string > TGraph;
40
41     public:
42       Workspace( );
43       virtual ~Workspace( );
44
45       // Plugins management
46       TInterface* GetInterface( );
47       void SetInterface( TInterface* i );
48
49       // Workspace IO
50       std::string LoadWorkspace( const std::string& fname );
51       std::string SaveWorkspace( const std::string& fname ) const;
52
53       // Graph management
54       void Clear( );
55       TGraph* GetGraph( );
56       const TGraph* GetGraph( ) const;
57       bool CreateFilter( const std::string& filter, const std::string& name );
58       bool Connect(
59         const std::string& orig_filter, const std::string& dest_filter,
60         const std::string& output_name,
61         const std::string& input_name
62         );
63       bool Connect( const std::string& i, const std::string& o );
64       TParameters* GetParameters( const std::string& name );
65       const TParameters* GetParameters( const std::string& name ) const;
66       TFilter* GetFilter( const std::string& name );
67       const TFilter* GetFilter( const std::string& name ) const;
68       bool HasFilter( const std::string& name ) const;
69
70       // Graph reduction
71       bool Reduce( const std::string& name );
72       void AddInputPort(
73         const std::string& name,
74         const std::string& filter, const std::string& filter_input
75         );
76       void AddOutputPort(
77         const std::string& name,
78         const std::string& filter, const std::string& filter_output
79         );
80       void ClearInputPorts( );
81       void ClearOutputPorts( );
82
83       // Pipeline execution
84       std::string Execute( );
85       std::string Execute( const std::string& name, QWidget* p = NULL );
86
87     protected:
88       void _UpdateLoadedPluginsInformation( );
89
90     protected:
91       // Plugins interface
92       TInterface* m_Interface;
93
94       // Processing graph
95       typename TGraph::Pointer m_Graph;
96       TGlobalPorts m_InputPorts;
97       TGlobalPorts m_OutputPorts;
98     };
99
100   } // ecapseman
101
102 } // ecapseman
103
104 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
105
106 // eof - $RCSfile$