Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

ActionExtension.h 3.67 KB
Newer Older
1
/*****************************************************************************
2
3
4
 * $CAMITK_LICENCE_BEGIN$
 *
 * CamiTK - Computer Assisted Medical Intervention ToolKit
saubatn's avatar
saubatn committed
5
 * (c) 2001-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * Visit http://camitk.imag.fr for more information
 *
 * This file is part of CamiTK.
 *
 * CamiTK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * CamiTK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with CamiTK.  If not, see <http://www.gnu.org/licenses/>.
 *
 * $CAMITK_LICENCE_END$
 ****************************************************************************/
25
26
27
28
29
30
31


#ifndef ACTION_EXTENSION_H
#define ACTION_EXTENSION_H


#include "CamiTKAPI.h"
32

33
34
35
36
// -- QT stuff
#include <QtPlugin>
#include <QPluginLoader>
#include <QObject>
37
#include <QTranslator>
38

39
namespace camitk {
40
class Action;
41

42
// a bit simplistic, but greatly simply syntax (and explanation)
43
44
45
// to be used in an ActionExtension register method
#define registerNewAction(X) registerAction(new X(this))

46
/**
47
48
 * @ingroup group_sdk_libraries_core_action
 *
49
50
 * @brief
 * This class describes what is a generic Action extension.
51
* To add a ActionExtension to CamiTK core, write a new class that inherits from this class.
52
*
53
* The following methods HAVE to be redefined in your subclass:
54
55
56
57
58
* - getName: return the name of your extension
* - getDescription: return a small description
* - init: a simple enough method, just call registerNewAction(MyAction) for any
*   MyAction class inheriting from camitk::Action
*
59
* @see BasicMeshExtension For an example of an extension registering more than one actions
60
61
62
63
64
*/
class CAMITK_API ActionExtension : public QObject {

protected :
    /// constructor
65
    ActionExtension() {};
66
67
68

public :
    /// destructor
69
    virtual ~ActionExtension();
70

71
    /// returns the action extension name (to be overriden in your ActionExtension)
72
73
    virtual QString getName() = 0;

74
    /// returns the action extension small description (to be overriden in your ActionExtension)
75
    virtual QString getDescription() = 0;
76
77
78

    /// this method should just call registerNewAction(MyAction) for any MyAction class you need to register by this extension
    virtual void init() = 0;
79
80
81

    /// get the list of actions registered y this extension
    const ActionList & getActions();
82

83
84
85
86
87
88
89
90
91
92
93
94
95
    /// set the file path (once loaded as a dynamic library)
    void setLocation(const QString loc) {
        dynamicLibraryFileName = loc;
    }

    /// get the file path (location of the .dll/.so/.dylib) of this plugin
    QString getLocation() const {
        return dynamicLibraryFileName;
    }

    /// Load, for the selected langage (asked to the Application), the associated .qm file
    void initResources();

96
97
98
protected:
    /// register an action instance
    void registerAction(Action *);
99
100
101

    /// the list of actions
    ActionList actions;
102
103

private:
104
105
    /// the shared lib (.so, .dll or .dylib) used to instanciate the ComponentExtension subclass instance
    QString dynamicLibraryFileName;
106
107
108

	/// Provide internationalization support for text output.
	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