ITK  6.0.0
Insight Toolkit
itkPyCommand.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkPyCommand_h
20 #define itkPyCommand_h
21 
22 #include "itkCommand.h"
23 
24 // The python header defines _POSIX_C_SOURCE without a preceding #undef
25 #undef _POSIX_C_SOURCE
26 #undef _XOPEN_SOURCE
27 #include "Python.h"
28 
29 namespace itk
30 {
31 
44 class PyCommand : public Command
45 {
46 public:
48  using Self = PyCommand;
49 
52 
54  itkOverrideGetNameOfClassMacro(PyCommand);
55 
57  itkNewMacro(Self);
58 
64  void
65  SetCommandCallable(PyObject * obj);
66 
67  PyObject *
69 
70  void
71  Execute(Object *, const EventObject &) override;
72  void
73  Execute(const Object *, const EventObject &) override;
74 
75 protected:
76  PyCommand();
77  ~PyCommand();
78  void
79  PyExecute();
80  PyCommand(const Self &); // Not implemented.
81  PyCommand &
82  operator=(const Self &); // Not implemented.
83 
84 private:
85  PyObject * m_Object;
86  PyObject * m_EmptyArgumentList;
87 };
88 
89 
90 } // namespace itk
91 
92 #endif // _itkPyCommand_h
itk::PyCommand::PyCommand
PyCommand()
itk::PyCommand::GetCommandCallable
PyObject * GetCommandCallable()
itk::SmartPointer< Self >
itk::Command
Superclass for callback/observer methods.
Definition: itkCommand.h:45
itk::PyCommand::operator=
PyCommand & operator=(const Self &)
itk::PyCommand::PyExecute
void PyExecute()
itk::PyCommand::m_EmptyArgumentList
PyObject * m_EmptyArgumentList
Definition: itkPyCommand.h:86
itk::PyCommand::Execute
void Execute(Object *, const EventObject &) override
itk::PyCommand::~PyCommand
~PyCommand()
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:58
itk::PyCommand::m_Object
PyObject * m_Object
Definition: itkPyCommand.h:85
itkCommand.h
itk::PyCommand
Command subclass that calls a Python callable object, e.g. a Python function.
Definition: itkPyCommand.h:44
itk::PyCommand::SetCommandCallable
void SetCommandCallable(PyObject *obj)