]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
Editor finished
[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     /** \brief A complex pipeline
20      */
21     class cpPlugins_Interface_EXPORT Workspace
22     {
23     public:
24       typedef cpPlugins::Interface::Interface     TPlugins;
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 > TExposedPort;
33       typedef std::map< std::string, TExposedPort > TExposedPorts;
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       TPlugins* GetPlugins( );
47       const TPlugins* GetPlugins( ) const;
48       void SetPlugins( TPlugins* i );
49
50       // Workspace IO
51       std::string LoadWorkspace( const std::string& fname );
52       std::string SaveWorkspace( const std::string& fname ) const;
53
54       // Graph management
55       TGraph* GetGraph( );
56       const TGraph* GetGraph( ) const;
57
58       void Clear( );
59       void ClearConnections( );
60
61       // Filter management
62       TFilter* GetFilter( const std::string& name );
63       const TFilter* GetFilter( const std::string& name ) const;
64       bool HasFilter( const std::string& name ) const;
65       bool CreateFilter( const std::string& filter, const std::string& name );
66       bool RenameFilter(
67         const std::string& old_name, const std::string& new_name
68         );
69       void RemoveFilter( const std::string& name );
70
71       // Connection management
72       bool Connect(
73         const std::string& orig_filter, const std::string& dest_filter,
74         const std::string& output_name, const std::string& input_name
75         );
76       bool Connect( TData* input_object, const std::string& exposed_port );
77       void RemoveConnection(
78         const std::string& dest_filter, const std::string& input_name
79         );
80       void RemoveConnection( const std::string& exposed_port );
81       void RemoveConnections( const std::string& dest_filter );
82
83       // Graph reduction
84       bool Reduce( const std::string& name );
85       void ExposeInputPort(
86         const std::string& name,
87         const std::string& filter, const std::string& filter_input
88         );
89       void ExposeOutputPort(
90         const std::string& name,
91         const std::string& filter, const std::string& filter_output
92         );
93       void HideInputPort( const std::string& name );
94       void HideOutputPort( const std::string& name );
95
96       bool RenameExposedInputPort(
97         const std::string& old_name,
98         const std::string& new_name
99         );
100       bool RenameExposedOutputPort(
101         const std::string& old_name,
102         const std::string& new_name
103         );
104
105       const TExposedPorts& GetExposedInputPorts( ) const;
106       const TExposedPorts& GetExposedOutputPorts( ) const;
107
108       TData* GetExposedInput( const std::string& name );
109       const TData* GetExposedInput( const std::string& name ) const;
110       TData* GetExposedOutput( const std::string& name );
111       const TData* GetExposedOutput( const std::string& name ) const;
112
113       // Pipeline execution
114       std::string Execute( QWidget* p = NULL );
115       std::string Execute( const std::string& name, QWidget* p = NULL );
116
117     protected:
118       // Plugins interface
119       TPlugins* m_Plugins;
120
121       // Processing graph
122       typename TGraph::Pointer m_Graph;
123       TExposedPorts m_ExposedInputPorts;
124       TExposedPorts m_ExposedOutputPorts;
125     };
126
127   } // ecapseman
128
129 } // ecapseman
130
131 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
132
133 // eof - $RCSfile$