]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
Architecture updated.
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
1 #ifndef __cpPlugins__Interface__Workspace__h__
2 #define __cpPlugins__Interface__Workspace__h__
3
4 #include <cpPlugins/Interface/Plugins.h>
5 #include <cpPlugins/BaseObjects/DataObject.h>
6 #include <cpPlugins/BaseObjects/ProcessObject.h>
7 #include <itkObject.h>
8
9 class vtkRenderWindowInteractor;
10
11 namespace cpPlugins
12 {
13   namespace Interface
14   {
15     /** \brief A complex pipeline
16      */
17     class cpPlugins_EXPORT Workspace
18       : public itk::Object
19     {
20     public:
21       typedef Workspace                       Self;
22       typedef itk::Object                     Superclass;
23       typedef itk::SmartPointer< Self >       Pointer;
24       typedef itk::SmartPointer< const Self > ConstPointer;
25
26       typedef cpPlugins::BaseObjects::ProcessObject TProcess;
27       typedef cpPlugins::Interface::Plugins         TInterface;
28
29       typedef std::map< std::string, TProcess::Pointer > TFilters;
30       typedef
31         std::map< std::string, std::pair< std::string, std::string > >
32         TExposedPorts;
33
34     public:
35       itkNewMacro( Self );
36       itkTypeMacro( Workspace, itk::Object );
37
38     public:
39       // Workspace IO
40       void Load( const std::string& fname );
41       void Save( const std::string& fname ) const;
42
43       // Memory management
44       void Clear( );
45
46       // Filter management
47       std::vector< std::string > GetFiltersNames( ) const;
48       TProcess* GetFilter(
49         const std::string& name
50         );
51       const TProcess* GetFilter(
52         const std::string& name
53         ) const;
54       bool HasFilter( const std::string& name ) const;
55       TProcess* CreateFilter(
56         const std::string& category,
57         const std::string& filter,
58         const std::string& name
59         );
60       bool RenameFilter(
61         const std::string& old_name, const std::string& new_name
62         );
63       bool RemoveFilter( const std::string& name );
64
65       void SetPrintExecution( bool b );
66       void PrintExecutionOn( );
67       void PrintExecutionOff( );
68
69       // Interactors
70       void AddInteractor( vtkRenderWindowInteractor* iren );
71
72       // Exposed ports
73       const TExposedPorts& GetExposedInputs( ) const;
74       const TExposedPorts& GetExposedOutputs( ) const;
75       cpPlugins::BaseObjects::DataObject* GetExposedOutput(
76         const std::string& name
77         );
78       const cpPlugins::BaseObjects::DataObject* GetExposedOutput(
79         const std::string& name
80         ) const;
81       bool ExposeInput(
82         const std::string& name,
83         const std::string& filter, const std::string& filter_input
84         );
85       bool ExposeOutput(
86         const std::string& name,
87         const std::string& filter, const std::string& filter_output
88         );
89       void HideInput( const std::string& name );
90       void HideOutput( const std::string& name );
91       bool RenameExposedInput(
92         const std::string& old_name,
93         const std::string& new_name
94         );
95       bool RenameExposedOutput(
96         const std::string& old_name,
97         const std::string& new_name
98         );
99
100       // Connection management
101       std::vector< std::pair< std::string, std::string > > GetConnections(
102         const std::string& origin, const std::string& destination
103         ) const;
104       void Connect(
105         const std::string& orig_filter, const std::string& dest_filter,
106         const std::string& output_name, const std::string& input_name
107         );
108       void Connect(
109         cpPlugins::BaseObjects::DataObject* output,
110         const std::string& dest_filter, const std::string& input_name
111         );
112       void Connect(
113         cpPlugins::BaseObjects::DataObject* output,
114         const std::string& exposed_input_name
115         );
116       void Disconnect(
117         const std::string& orig_filter, const std::string& dest_filter,
118         const std::string& output_name, const std::string& input_name
119         );
120       void Disconnect(
121         const std::string& dest_filter, const std::string& input_name
122         );
123       void Disconnect( const std::string& dest_filter );
124
125       // Pipeline execution
126       void Execute( );
127       void Execute( const std::string& name );
128
129     protected:
130       Workspace( );
131       virtual ~Workspace( );
132
133     private:
134       // Purposely not implemented
135       Workspace( const Self& other );
136       Self& operator=( const Self& other );
137
138     protected:
139       TFilters m_Filters;
140       bool     m_PrintExecution;
141
142       TExposedPorts m_ExposedInputs;
143       TExposedPorts m_ExposedOutputs;
144
145       std::set< vtkRenderWindowInteractor* > m_Interactors;
146     };
147
148   } // ecapseman
149
150 } // ecapseman
151
152 #endif // __cpPlugins__Interface__Workspace__h__
153
154 // eof - $RCSfile$