GCC Code Coverage Report


Directory: ./
File: include/gepetto/gui/plugin-interface.hh
Date: 2024-08-14 11:04:57
Exec Total Coverage
Lines: 0 10 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 // Copyright (c) 2015-2022, LAAS-CNRS, Heriot-Watt University
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef GEPETTO_GUI_PLUGININTERFACE_HH
18 #define GEPETTO_GUI_PLUGININTERFACE_HH
19
20 #include <gepetto/gui/fwd.hh>
21 // This include must be include before any other Qt include for GLDEBUGPROC
22 #include <QOpenGLContext>
23 #include <QWidget>
24 #include <gepetto/gui/dialog/dialogloadenvironment.hh>
25 #include <gepetto/gui/dialog/dialogloadrobot.hh>
26 #include <iostream>
27
28 namespace gepetto {
29 namespace gui {
30 const int DockKeyShortcutBase = Qt::CTRL + Qt::ALT;
31
32 /// \ingroup plugin_cpp
33 /// Base interface for C++ plugins.
34 class PluginInterface {
35 public:
36 PluginInterface() : errorMsg_("Not initalized"), isInit_(false) {}
37
38 virtual ~PluginInterface() {}
39
40 virtual QString name() const = 0;
41
42 void doInit() {
43 try {
44 init();
45 isInit_ = true;
46 } catch (const std::exception& e) {
47 errorMsg_ = QString(e.what());
48 }
49 }
50
51 bool isInit() const { return isInit_; }
52
53 const QString& errorMsg() const { return errorMsg_; }
54
55 protected:
56 virtual void init() = 0;
57
58 private:
59 QString errorMsg_;
60 bool isInit_;
61 };
62
63 /// \ingroup plugin_cpp
64 /// Interface to add actions to the joint tree.
65 class JointModifierInterface {
66 public:
67 virtual ~JointModifierInterface() {}
68
69 virtual QAction* action(const std::string& jointName) const = 0;
70 };
71
72 /// \ingroup plugin_cpp
73 /// Interface to load robot models.
74 class ModelInterface {
75 public:
76 virtual ~ModelInterface() {}
77
78 virtual void loadRobotModel(DialogLoadRobot::RobotDefinition rd) = 0;
79
80 virtual void loadEnvironmentModel(
81 DialogLoadEnvironment::EnvironmentDefinition ed) = 0;
82
83 virtual std::string getBodyFromJoint(const std::string& jointName) const = 0;
84 };
85
86 /// \ingroup plugin_cpp
87 /// You must implement this interface is you have corba clients.
88 class ConnectionInterface {
89 public:
90 virtual ~ConnectionInterface() {}
91
92 virtual void openConnection() = 0;
93
94 virtual void closeConnection() = 0;
95 };
96 } // namespace gui
97 } // namespace gepetto
98
99 Q_DECLARE_INTERFACE(gepetto::gui::PluginInterface, "gepetto-gui.plugins/0.0")
100 Q_DECLARE_INTERFACE(gepetto::gui::JointModifierInterface,
101 "gepetto-gui.plugin.joint-modifier/0.0")
102 Q_DECLARE_INTERFACE(gepetto::gui::ModelInterface,
103 "gepetto-gui.plugin.model/0.0")
104 Q_DECLARE_INTERFACE(gepetto::gui::ConnectionInterface,
105 "gepetto-gui.plugin.connection/0.0")
106
107 #endif // GEPETTO_GUI_PLUGININTERFACE_HH
108