SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SCIRunPythonModule.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/SCIRunPythonModule.h
29 
30 #ifndef ENGINE_PYTHON_SCIRUNPYTHONMODULE_H
31 #define ENGINE_PYTHON_SCIRUNPYTHONMODULE_H
32 
33 #include <boost/python.hpp>
37 
38 BOOST_PYTHON_MODULE(SCIRunPythonAPI)
39 {
40  using namespace SCIRun;
41 
42  boost::python::class_<PyPort, boost::shared_ptr<PyPort>, boost::noncopyable>("SCIRun::PyPort", boost::python::no_init)
43  .add_property("name", &PyPort::name)
44  .add_property("type", &PyPort::type)
45  .add_property("isInput", &PyPort::isInput)
46  .def(boost::python::self >> boost::python::self)
47  .def("connect", &PyPort::connect)
48  ;
49 
50  boost::python::class_<PyPorts, boost::shared_ptr<PyPorts>, boost::noncopyable>("SCIRun::PyPorts", boost::python::no_init)
51  .def("__getattr__", &PyPorts::getattr)
52  .def("__getitem__", &PyPorts::getitem)
53  .def("__len__", &PyPorts::size)
54  ;
55 
56  boost::python::class_<PyModule, boost::shared_ptr<PyModule>, boost::noncopyable>("SCIRun::PyModule", boost::python::no_init)
57  .add_property("id", &PyModule::id)
58  .add_property("stateVars", &PyModule::stateVars)
59  .add_property("input", &PyModule::input)
60  .add_property("output", &PyModule::output)
61  .def("showUI", &PyModule::showUI)
62  .def("hideUI", &PyModule::hideUI)
63  .def("__getattr__", &PyModule::getattr)
64  .def("__setattr__", &PyModule::setattr)
65  ;
66 
67  boost::python::def("addModule", &NetworkEditorPythonAPI::addModule);
68  boost::python::def("removeModule", &NetworkEditorPythonAPI::removeModule);
69  boost::python::def("modules", &NetworkEditorPythonAPI::modules);
70  boost::python::def("executeAll", &NetworkEditorPythonAPI::executeAll);
71  boost::python::def("saveNetwork", &NetworkEditorPythonAPI::saveNetwork);
72  boost::python::def("loadNetwork", &NetworkEditorPythonAPI::loadNetwork);
73  boost::python::def("quit", &NetworkEditorPythonAPI::quit);
74 }
75 
76 #endif
static std::string loadNetwork(const std::string &filename)
Definition: NetworkEditorPythonAPI.cc:131
virtual size_t size() const =0
static std::string quit(bool force)
Definition: NetworkEditorPythonAPI.cc:141
BOOST_PYTHON_MODULE(interpreter)
Definition: PythonInterpreter.cc:194
static std::vector< boost::shared_ptr< PyModule > > modules()
Definition: NetworkEditorPythonAPI.cc:106
virtual void setattr(const std::string &name, boost::python::object object)=0
virtual boost::shared_ptr< PyPort > getattr(const std::string &name)=0
virtual void showUI()=0
virtual std::vector< std::string > stateVars() const =0
virtual boost::shared_ptr< class PyPorts > output()=0
virtual std::string name() const =0
static boost::shared_ptr< PyModule > addModule(const std::string &name)
Definition: NetworkEditorPythonAPI.cc:78
virtual bool isInput() const =0
static std::string removeModule(const std::string &id)
Definition: NetworkEditorPythonAPI.cc:93
virtual boost::shared_ptr< class PyPorts > input()=0
static std::string saveNetwork(const std::string &filename)
Definition: NetworkEditorPythonAPI.cc:121
virtual boost::shared_ptr< PyPort > getitem(int index)=0
static std::string executeAll()
Definition: NetworkEditorPythonAPI.cc:111
virtual void connect(const PyPort &other) const =0
virtual std::string type() const =0
virtual std::string id() const =0
virtual void hideUI()=0
virtual boost::python::object getattr(const std::string &name)=0