]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
Pipeline editor added.
[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 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 type
31       typedef std::pair< std::string, std::string > TConnection;
32       typedef
33         cpExtensions::DataStructures::
34         Graph< TObject::Pointer, TConnection, std::string > TGraph;
35
36     public:
37       Workspace( );
38       virtual ~Workspace( );
39
40       // Plugins management
41       bool LoadPluginsPath( const std::string& path, bool r = false );
42       bool LoadPlugins( const std::string& fname );
43       const TStringContainer& GetLoadedPlugins( ) const;
44       void GetLoadedPluginCategories( TStringContainer& categories ) const;
45       void GetLoadedPluginFilters( TStringContainer& filters ) const;
46       const TStringContainer& GetLoadedPluginFilters(
47         const std::string& category
48         ) const;
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       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       TParameters* GetParameters( const std::string& name );
64       const TParameters* GetParameters( const std::string& name ) const;
65
66       // Graph reduction
67       bool Reduce( const std::string& name );
68
69       // Pipeline execution
70       std::string Execute( );
71       std::string Execute( const std::string& name );
72
73     protected:
74       void _UpdateLoadedPluginsInformation( );
75
76     protected:
77       // Plugins interface
78       TInterface       m_Interface;
79       std::string      m_LastLoadedPlugin;
80       TStringContainer m_LoadedPlugins;
81       std::map< std::string, TStringContainer > m_LoadedFilters;
82
83       // Processing graph
84       typename TGraph::Pointer m_Graph;
85     };
86
87   } // ecapseman
88
89 } // ecapseman
90
91 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
92
93 // eof - $RCSfile$