Computer Assited Medical Intervention Tool Kit  version 4.1
ActionExtension.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef ACTION_EXTENSION_H
27 #define ACTION_EXTENSION_H
28 
29 #include "CamiTKAPI.h"
30 
31 // -- QT stuff
32 #include <QtPlugin>
33 #include <QPluginLoader>
34 #include <QObject>
35 #include <QTranslator>
36 
37 namespace camitk {
38 class Action;
39 
40 // a bit simplistic, but greatly simply syntax (and explanation)
41 // to be used in an ActionExtension register method
42 #define registerNewAction(X) registerAction(new X(this))
43 
59 class CAMITK_API ActionExtension : public QObject {
60 
61 protected :
63  ActionExtension() {};
64 
65 public :
67  ~ActionExtension() override;
68 
70  virtual QString getName() = 0;
71 
73  virtual QString getDescription() = 0;
74 
76  virtual void init() = 0;
77 
79  const ActionList& getActions();
80 
82  void setLocation(const QString loc) {
83  dynamicLibraryFileName = loc;
84  }
85 
87  QString getLocation() const {
88  return dynamicLibraryFileName;
89  }
90 
92  void initResources();
93 
94 protected:
96  void registerAction(Action*);
97 
99  ActionList actions;
100 
101 private:
103  QString dynamicLibraryFileName;
104 
106  QTranslator* translator{nullptr};
107 };
108 
109 }
110 // -------------------- declare the interface for QPluginLoader --------------------
111 Q_DECLARE_INTERFACE(camitk::ActionExtension, "TIMC-IMAG. Action Extension/2.1") //TODO use variable from CMake?
112 
113 
114 #endif //ACTION_EXTENSION_H
CamiTKAPI.h
camitk::Application::getSelectedLanguage
static QString getSelectedLanguage()
Returns for the current CamiTK application, the selected language (stored in its ....
Definition: Application.cpp:1232
CAMITK_INFO
#define CAMITK_INFO(MSG)
Log for info verbosity (the second most verbose one) The msg will appear only if the user asked for I...
Definition: Log.h:256
camitk::Action::getName
QString getName() const
get the name of the action
Definition: Action.h:332
Action.h
camitk::ActionList
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:94
ActionExtension.h
camitk::ActionExtension::translator
QTranslator * translator
Provide internationalization support for text output.
Definition: ActionExtension.h:127
Log.h
camitk::Action
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:228
camitk::ActionExtension::registerAction
void registerAction(Action *)
register an action instance
Definition: ActionExtension.cpp:97
camitk::ActionExtension::initResources
void initResources()
Load, for the selected langage (asked to the Application), the associated .qm file.
Definition: ActionExtension.cpp:60
camitk::ActionExtension
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ActionExtension.h:80
camitk::ActionExtension::getActions
const ActionList & getActions()
get the list of actions registered y this extension
Definition: ActionExtension.cpp:103
Core.h
camitk::ActionExtension::actions
ActionList actions
the list of actions
Definition: ActionExtension.h:120
camitk::ActionExtension::getLocation
QString getLocation() const
get the file path (location of the .dll/.so/.dylib) of this plugin
Definition: ActionExtension.h:108
camitk::ActionExtension::~ActionExtension
~ActionExtension() override
destructor
Definition: ActionExtension.cpp:81
Application.h
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:48
camitk
Definition: Action.cpp:36