GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/gui/plugin-interface.hh Lines: 0 12 0.0 %
Date: 2020-05-14 11:23:33 Branches: 0 14 0.0 %

Line Branch Exec Source
1
// Copyright (c) 2015-2018, LAAS-CNRS
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 <QtGui>
21
#include <QWidget>
22
#include <iostream>
23
24
#include <gepetto/gui/dialog/dialogloadrobot.hh>
25
#include <gepetto/gui/dialog/dialogloadenvironment.hh>
26
27
namespace gepetto {
28
  namespace gui {
29
    const int DockKeyShortcutBase = Qt::CTRL + Qt::ALT;
30
31
    /// \ingroup plugin_cpp
32
    /// Base interface for C++ plugins.
33
    class PluginInterface {
34
      public:
35
        PluginInterface ()
36
          : errorMsg_ ("Not initalized")
37
          , isInit_ (false)
38
        {}
39
40
        virtual ~PluginInterface () {}
41
42
        virtual QString name () const = 0;
43
44
        void doInit ()
45
        {
46
          try {
47
            init ();
48
            isInit_ = true;
49
          } catch (const std::exception& e) {
50
            errorMsg_ = QString (e.what ());
51
          }
52
        }
53
54
        bool isInit () const
55
        {
56
          return isInit_;
57
        }
58
59
        const QString& errorMsg () const
60
        {
61
          return errorMsg_;
62
        }
63
64
      protected:
65
        virtual void init () = 0;
66
67
      private:
68
        QString errorMsg_;
69
        bool isInit_;
70
    };
71
72
    /// \ingroup plugin_cpp
73
    /// Interface to add actions to the joint tree.
74
    class JointModifierInterface {
75
      public:
76
        virtual ~JointModifierInterface () {}
77
78
        virtual QAction* action (const std::string& jointName) const = 0;
79
    };
80
81
    /// \ingroup plugin_cpp
82
    /// Interface to load robot models.
83
      class ModelInterface {
84
        public:
85
          virtual ~ModelInterface () {}
86
87
          virtual void loadRobotModel (DialogLoadRobot::RobotDefinition rd) = 0;
88
89
          virtual void loadEnvironmentModel (DialogLoadEnvironment::EnvironmentDefinition ed) = 0;
90
91
          virtual std::string getBodyFromJoint (const std::string& jointName) const = 0;
92
      };
93
94
    /// \ingroup plugin_cpp
95
    /// You must implement this interface is you have corba clients.
96
      class ConnectionInterface {
97
        public:
98
          virtual ~ConnectionInterface () {}
99
100
          virtual void openConnection () = 0;
101
102
          virtual void closeConnection () = 0;
103
      };
104
  } // namespace gui
105
} // namespace gepetto
106
107
Q_DECLARE_INTERFACE (gepetto::gui::PluginInterface, "gepetto-gui.plugins/0.0")
108
Q_DECLARE_INTERFACE (gepetto::gui::JointModifierInterface, "gepetto-gui.plugin.joint-modifier/0.0")
109
Q_DECLARE_INTERFACE (gepetto::gui::ModelInterface, "gepetto-gui.plugin.model/0.0")
110
Q_DECLARE_INTERFACE (gepetto::gui::ConnectionInterface, "gepetto-gui.plugin.connection/0.0")
111
112
113
114
#endif // GEPETTO_GUI_PLUGININTERFACE_HH