Debian Codegraph @

src/Gui/CommandActionPy.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2023 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
5 * *
6 * This file is part of FreeCAD. *
7 * *
8 * FreeCAD is free software: you can redistribute it and/or modify it *
9 * under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation, either version 2.1 of the *
11 * License, or (at your option) any later version. *
12 * *
13 * FreeCAD is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with FreeCAD. If not, see *
20 * <https://www.gnu.org/licenses/>. *
21 * *
22 **************************************************************************/
23
24 #ifndef GUI_COMMANDACTIONPY_H
25 #define GUI_COMMANDACTIONPY_H
26
27 #include <CXX/Extensions.hxx>
28
29
30 namespace Gui
31 {
32 class Command;
33
34 class CommandActionPy: public Py::PythonClass<CommandActionPy>
35 {
36 public:
37 static void init_type();
38
39 CommandActionPy(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kdws);
40 ~CommandActionPy() override;
41
42 Py::Object getCommand();
43
44 protected:
45 static PyObject* descriptorGetter(PyObject* self, PyObject* obj, PyObject* type);
46 static int descriptorSetter(PyObject* self, PyObject* obj, PyObject* value);
47 Py::Object repr() override;
48 Py::Object getattro(const Py::String& attr) override;
49 int setattro(const Py::String& attr_, const Py::Object& value) override;
50
51 Py::Object getAction();
52
53 private:
54 std::string cmdName;
55 Command* cmd = nullptr;
56 };
57
58 } // namespace Gui
59
60 #endif // GUI_COMMANDACTIONPY_H