Computer Assited Medical Intervention Tool Kit  version 4.0
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-2016 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 
27 #ifndef ACTION_EXTENSION_H
28 #define ACTION_EXTENSION_H
29 
30 
31 #include "CamiTKAPI.h"
32 
33 // -- QT stuff
34 #include <QtPlugin>
35 #include <QPluginLoader>
36 #include <QObject>
37 #include <QTranslator>
38 
39 namespace camitk {
40 class Action;
41 
42 // a bit simplistic, but greatly simply syntax (and explanation)
43 // to be used in an ActionExtension register method
44 #define registerNewAction(X) registerAction(new X(this))
45 
61 class CAMITK_API ActionExtension : public QObject {
62 
63 protected :
66 
67 public :
69  virtual ~ActionExtension();
70 
72  virtual QString getName() = 0;
73 
75  virtual QString getDescription() = 0;
76 
78  virtual void init() = 0;
79 
81  const ActionList & getActions();
82 
84  void setLocation(const QString loc) {
85  dynamicLibraryFileName = loc;
86  }
87 
89  QString getLocation() const {
90  return dynamicLibraryFileName;
91  }
92 
94  void initResources();
95 
96 protected:
98  void registerAction(Action *);
99 
102 
103 private:
106 
108  QTranslator* translator;
109 };
110 
111 }
112 // -------------------- declare the interface for QPluginLoader --------------------
113 Q_DECLARE_INTERFACE(camitk::ActionExtension, "TIMC-IMAG. Action Extension/2.1") //TODO use variable from CMake?
114 
115 
116 #endif //ACTION_EXTENSION_H
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:208
QString dynamicLibraryFileName
the shared lib (.so, .dll or .dylib) used to instanciate the ComponentExtension subclass instance ...
Definition: ActionExtension.h:105
ActionList actions
the list of actions
Definition: ActionExtension.h:101
QString getLocation() const
get the file path (location of the .dll/.so/.dylib) of this plugin
Definition: ActionExtension.h:89
Definition: Action.cpp:40
CAMITK_API QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:95
void setLocation(const QString loc)
set the file path (once loaded as a dynamic library)
Definition: ActionExtension.h:84
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes what is a generic Action extension.
Definition: ActionExtension.h:61
QTranslator * translator
Provide internationalization support for text output.
Definition: ActionExtension.h:108
ActionExtension()
constructor
Definition: ActionExtension.h:65