SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NetworkEditorPythonInterface.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9  License for the specific language governing rights and limitations under
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 /// @todo Documentation Dataflow/Engine/Python/NetworkEditorPythonInterface.cc
29 
30 #ifndef ENGINE_PYTHON_NETWORKEDITORPYTHONINTERFACE_H
31 #define ENGINE_PYTHON_NETWORKEDITORPYTHONINTERFACE_H
32 
33 #include <vector>
34 #include <boost/python.hpp>
35 #include <boost/enable_shared_from_this.hpp>
38 
39 namespace SCIRun
40 {
41 
43  {
44  public:
45  virtual ~PyModule() {}
46  virtual std::string id() const = 0;
47  virtual void showUI() = 0;
48  virtual void hideUI() = 0;
49  virtual void reset() = 0;
50 
51  //state
52  virtual boost::python::object getattr(const std::string& name) = 0;
53  virtual void setattr(const std::string& name, boost::python::object object) = 0;
54  virtual std::vector<std::string> stateVars() const = 0;
55 
56  //ports
57  virtual boost::shared_ptr<class PyPorts> output() = 0;
58  virtual boost::shared_ptr<class PyPorts> input() = 0;
59  };
60 
61  class SCISHARE PyPort : public boost::enable_shared_from_this<PyPort>
62  {
63  public:
64  virtual ~PyPort() {}
65  virtual std::string name() const = 0;
66  virtual std::string type() const = 0;
67  virtual bool isInput() const = 0;
68  virtual void connect(const PyPort& other) const = 0;
69  };
70 
72  {
73  public:
74  virtual ~PyConnection() {}
75  virtual std::string id() const = 0;
76  };
77 
78  SCISHARE boost::shared_ptr<PyPort> operator>>(const PyPort& from, const PyPort& to);
79 
81  {
82  public:
83  virtual ~PyPorts() {}
84  //by name
85  virtual boost::shared_ptr<PyPort> getattr(const std::string& name) = 0;
86  //by index
87  virtual boost::shared_ptr<PyPort> getitem(int index) = 0;
88 
89  virtual size_t size() const = 0;
90  };
91 
92  /// @todo idea: write addmodule.ShowMesh in python
94  {
95  public:
96  virtual ~AddModule() {}
97  virtual boost::shared_ptr<PyModule> getattr(const std::string& name) = 0;
98  };
99 
101  {
102  public:
104  virtual boost::shared_ptr<PyModule> addModule(const std::string& name) = 0;
105  virtual std::string removeModule(const std::string& id) = 0;
106  virtual std::string executeAll(const Dataflow::Networks::ExecutableLookup* lookup) = 0;
107  virtual std::string saveNetwork(const std::string& filename) = 0;
108  virtual std::string loadNetwork(const std::string& filename) = 0;
109  virtual std::string quit(bool force) = 0;
110  };
111 
112 }
113 
114 #endif
Definition: NetworkEditorPythonInterface.h:42
#define SCISHARE
Definition: share.h:39
virtual ~NetworkEditorPythonInterface()
Definition: NetworkEditorPythonInterface.h:103
Definition: NetworkEditorPythonInterface.h:93
virtual ~AddModule()
Definition: NetworkEditorPythonInterface.h:96
Definition: NetworkEditorPythonInterface.h:61
Definition: NetworkEditorPythonInterface.h:71
const char * name[]
Definition: BoostGraphExampleTests.cc:87
virtual ~PyConnection()
Definition: NetworkEditorPythonInterface.h:74
virtual ~PyPort()
Definition: NetworkEditorPythonInterface.h:64
SCISHARE boost::shared_ptr< PyPort > operator>>(const PyPort &from, const PyPort &to)
Definition: NetworkEditorPythonAPI.cc:152
virtual ~PyPorts()
Definition: NetworkEditorPythonInterface.h:83
virtual ~PyModule()
Definition: NetworkEditorPythonInterface.h:45
Definition: NetworkEditorPythonInterface.h:100
Definition: NetworkInterface.h:48
Definition: NetworkEditorPythonInterface.h:80
int size
Definition: eabLatVolData.py:2