@@ -0,0 +1,117 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗ | |
|
3 | ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗ | |
|
4 | ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝ | |
|
5 | ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗ | |
|
6 | ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║ | |
|
7 | ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ | |
|
8 | ||
|
9 | -- This file is a part of the SOC Explorer Software | |
|
10 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | |
|
11 | -- | |
|
12 | -- This program is free software; you can redistribute it and/or modify | |
|
13 | -- it under the terms of the GNU General Public License as published by | |
|
14 | -- the Free Software Foundation; either version 2 of the License, or | |
|
15 | -- (at your option) any later version. | |
|
16 | -- | |
|
17 | -- This program is distributed in the hope that it will be useful, | |
|
18 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
19 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
20 | -- GNU General Public License for more details. | |
|
21 | -- | |
|
22 | -- You should have received a copy of the GNU General Public License | |
|
23 | -- along with this program; if not, write to the Free Software | |
|
24 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
25 | -------------------------------------------------------------------------------*/ | |
|
26 | /*-- Author : Alexis Jeandet | |
|
27 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
|
28 | ----------------------------------------------------------------------------*/ | |
|
29 | ||
|
30 | #include "pluginmanager.h" | |
|
31 | #include <QDir> | |
|
32 | #include <QLibrary> | |
|
33 | #include <QPluginLoader> | |
|
34 | #include <socexplorerengine.h> | |
|
35 | ||
|
36 | void PluginManager::loadPluginMetaData(const QString &pluginPath) | |
|
37 | { | |
|
38 | if(!this->plugins_metada_cache.contains(pluginPath)) | |
|
39 | { | |
|
40 | if (QLibrary::isLibrary(pluginPath)) | |
|
41 | { | |
|
42 | QPluginLoader pluginLoader{pluginPath}; | |
|
43 | if(pluginLoader.isLoaded()) | |
|
44 | { | |
|
45 | auto metadata = pluginLoader.metaData().value("MetaData").toObject(); | |
|
46 | for (auto key:pluginKeys::all) | |
|
47 | { | |
|
48 | if(metadata.contains(key)) | |
|
49 | this->plugins_metada_cache[pluginPath][key] = metadata.value(key).toString(); | |
|
50 | } | |
|
51 | } | |
|
52 | ||
|
53 | } | |
|
54 | } | |
|
55 | } | |
|
56 | ||
|
57 | bool PluginManager::isPlugin(const QString &pluginPath)const | |
|
58 | { | |
|
59 | if(!this->plugins_metada_cache.contains(pluginPath)) | |
|
60 | { | |
|
61 | if (QLibrary::isLibrary(pluginPath)) | |
|
62 | { | |
|
63 | QPluginLoader pluginLoader{pluginPath}; | |
|
64 | if(pluginLoader.isLoaded()) | |
|
65 | { | |
|
66 | return true; | |
|
67 | } | |
|
68 | } | |
|
69 | } | |
|
70 | return false; | |
|
71 | } | |
|
72 | ||
|
73 | ||
|
74 | PluginManager::PluginManager(const QStringList &folderList) | |
|
75 | :folderList(folderList) | |
|
76 | { | |
|
77 | scanFolders(); | |
|
78 | } | |
|
79 | ||
|
80 | ISocexplorerPlugin *PluginManager::makeInstance(const QString& pluginName) | |
|
81 | { | |
|
82 | auto plugin = resolvePluginName(pluginName); | |
|
83 | if (QLibrary::isLibrary(plugin)) | |
|
84 | { | |
|
85 | QPluginLoader pluginLoader{plugin}; | |
|
86 | if (auto pluginInstance = qobject_cast<ISocexplorerPlugin *>(pluginLoader.instance())) { | |
|
87 | return pluginInstance; | |
|
88 | } | |
|
89 | } | |
|
90 | return Q_NULLPTR; | |
|
91 | } | |
|
92 | ||
|
93 | ||
|
94 | void PluginManager::scanFolders() | |
|
95 | { | |
|
96 | QDir dir; | |
|
97 | QStringList filters{"*.so", "*.dll"}; | |
|
98 | pluginTable.clear(); | |
|
99 | for(auto&& folder:folderList) | |
|
100 | { | |
|
101 | dir.setPath(folder); | |
|
102 | dir.setFilter(QDir::Files); | |
|
103 | dir.setNameFilters(filters); | |
|
104 | QFileInfoList list = dir.entryInfoList(); | |
|
105 | for (auto&& fileInfo:list) | |
|
106 | { | |
|
107 | auto path = fileInfo.filePath(); | |
|
108 | SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ path,3); | |
|
109 | if(isPlugin(path)) | |
|
110 | { | |
|
111 | loadPluginMetaData(path); | |
|
112 | auto name = plugins_metada_cache[path][pluginKeys::Name]; | |
|
113 | pluginTable[name].append(path); | |
|
114 | } | |
|
115 | } | |
|
116 | } | |
|
117 | } |
@@ -0,0 +1,122 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗ | |
|
3 | ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗ | |
|
4 | ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝ | |
|
5 | ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗ | |
|
6 | ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║ | |
|
7 | ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ | |
|
8 | ||
|
9 | -- This file is a part of the SOC Explorer Software | |
|
10 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | |
|
11 | -- | |
|
12 | -- This program is free software; you can redistribute it and/or modify | |
|
13 | -- it under the terms of the GNU General Public License as published by | |
|
14 | -- the Free Software Foundation; either version 2 of the License, or | |
|
15 | -- (at your option) any later version. | |
|
16 | -- | |
|
17 | -- This program is distributed in the hope that it will be useful, | |
|
18 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
19 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
20 | -- GNU General Public License for more details. | |
|
21 | -- | |
|
22 | -- You should have received a copy of the GNU General Public License | |
|
23 | -- along with this program; if not, write to the Free Software | |
|
24 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
25 | -------------------------------------------------------------------------------*/ | |
|
26 | /*-- Author : Alexis Jeandet | |
|
27 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
|
28 | ----------------------------------------------------------------------------*/ | |
|
29 | #ifndef PLUGINLOADER_H | |
|
30 | #define PLUGINLOADER_H | |
|
31 | #include <isocexplorerplugin.h> | |
|
32 | #include <QHash> | |
|
33 | #include <QStringLiteral> | |
|
34 | ||
|
35 | template<typename T> | |
|
36 | auto loadMetadata(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache); | |
|
37 | ||
|
38 | template<> | |
|
39 | auto loadMetadata<QString>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache) | |
|
40 | { | |
|
41 | if(plugins_metada_cache.contains(pluginName)) | |
|
42 | { | |
|
43 | return plugins_metada_cache[pluginName][name]; | |
|
44 | } | |
|
45 | return QString(); | |
|
46 | } | |
|
47 | ||
|
48 | template<> | |
|
49 | auto loadMetadata<int>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache) | |
|
50 | { | |
|
51 | if(plugins_metada_cache.contains(pluginName)) | |
|
52 | { | |
|
53 | return plugins_metada_cache[pluginName][name].toInt(); | |
|
54 | } | |
|
55 | return -1; | |
|
56 | } | |
|
57 | ||
|
58 | template<> | |
|
59 | auto loadMetadata<bool>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache) | |
|
60 | { | |
|
61 | if(plugins_metada_cache.contains(pluginName)) | |
|
62 | { | |
|
63 | return bool(plugins_metada_cache[pluginName][name].toInt()); | |
|
64 | } | |
|
65 | return false; | |
|
66 | } | |
|
67 | ||
|
68 | namespace pluginKeys | |
|
69 | { | |
|
70 | const auto Name=QStringLiteral("Name"); | |
|
71 | const auto Author=QStringLiteral("Author"); | |
|
72 | const auto Version=QStringLiteral("Version"); | |
|
73 | const auto Description=QStringLiteral("Description"); | |
|
74 | const auto CanBeRoot=QStringLiteral("root"); | |
|
75 | const auto CanBeChild=QStringLiteral("child"); | |
|
76 | const auto VID=QStringLiteral("VID"); | |
|
77 | const auto PID=QStringLiteral("PID"); | |
|
78 | ||
|
79 | const auto all={Name, Author, Version, Description, CanBeRoot, CanBeChild, VID, PID}; | |
|
80 | }; | |
|
81 | ||
|
82 | class PluginManager | |
|
83 | { | |
|
84 | void loadPluginMetaData(const QString &pluginPath); | |
|
85 | bool isPlugin(const QString &pluginPath)const; | |
|
86 | ||
|
87 | QString resolvePluginName(const QString &pluginName)const | |
|
88 | { | |
|
89 | if( plugins_metada_cache.contains(pluginName)) | |
|
90 | return pluginName; | |
|
91 | else if (pluginTable.contains(pluginName)) { | |
|
92 | return pluginTable[pluginName].last(); | |
|
93 | } | |
|
94 | return QString(); | |
|
95 | } | |
|
96 | public: | |
|
97 | PluginManager(const QStringList& folderList); | |
|
98 | ISocexplorerPlugin* makeInstance(const QString &pluginName); | |
|
99 | ||
|
100 | #define METADATA_GETTER(type, name)\ | |
|
101 | type plugin##name(const QString &pluginName)const{return loadMetadata<type>(pluginKeys::name, resolvePluginName(pluginName), plugins_metada_cache);} | |
|
102 | ||
|
103 | METADATA_GETTER(QString, Name) | |
|
104 | METADATA_GETTER(QString, Author) | |
|
105 | METADATA_GETTER(QString, Description) | |
|
106 | METADATA_GETTER(QString, Version) | |
|
107 | ||
|
108 | METADATA_GETTER(bool, CanBeRoot) | |
|
109 | METADATA_GETTER(bool, CanBeChild) | |
|
110 | ||
|
111 | METADATA_GETTER(int, VID) | |
|
112 | METADATA_GETTER(int, PID) | |
|
113 | ||
|
114 | void scanFolders(); | |
|
115 | private: | |
|
116 | QHash<QString, QHash<QString,QString>> plugins_metada_cache; | |
|
117 | QHash<QString, QStringList> pluginTable; | |
|
118 | ||
|
119 | QStringList folderList; | |
|
120 | }; | |
|
121 | ||
|
122 | #endif // PLUGINLOADER_H |
@@ -0,0 +1,334 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗ | |
|
3 | ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗ | |
|
4 | ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝ | |
|
5 | ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗ | |
|
6 | ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║ | |
|
7 | ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ | |
|
8 | ||
|
9 | -- This file is a part of the SOC Explorer Software | |
|
10 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | |
|
11 | -- | |
|
12 | -- This program is free software; you can redistribute it and/or modify | |
|
13 | -- it under the terms of the GNU General Public License as published by | |
|
14 | -- the Free Software Foundation; either version 2 of the License, or | |
|
15 | -- (at your option) any later version. | |
|
16 | -- | |
|
17 | -- This program is distributed in the hope that it will be useful, | |
|
18 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
19 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
20 | -- GNU General Public License for more details. | |
|
21 | -- | |
|
22 | -- You should have received a copy of the GNU General Public License | |
|
23 | -- along with this program; if not, write to the Free Software | |
|
24 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
25 | -------------------------------------------------------------------------------*/ | |
|
26 | /*-- Author : Alexis Jeandet | |
|
27 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
|
28 | ----------------------------------------------------------------------------*/ | |
|
29 | #ifndef ISOCEXPLORERPLUGIN_H | |
|
30 | #define ISOCEXPLORERPLUGIN_H | |
|
31 | #include <QtPlugin> | |
|
32 | #include <QWidget> | |
|
33 | #include <QAction> | |
|
34 | #include <QDockWidget> | |
|
35 | #include <QMainWindow> | |
|
36 | #include <QList> | |
|
37 | #include <QMenu> | |
|
38 | #include <socexplorer.h> | |
|
39 | #include <QObject> | |
|
40 | #include <QVariant> | |
|
41 | #include <QVariantList> | |
|
42 | #include <malloc.h> | |
|
43 | #include <QFile> | |
|
44 | #include <stdint.h> | |
|
45 | #include <QTextStream> | |
|
46 | #include <abstractbinfile.h> | |
|
47 | #include <srec/srecfile.h> | |
|
48 | #include <BinFile/binaryfile.h> | |
|
49 | ||
|
50 | class ISocexplorerPlugin : public QDockWidget | |
|
51 | { | |
|
52 | Q_OBJECT | |
|
53 | public: | |
|
54 | //! Default plugin constructor, any plugin should call this constructor. | |
|
55 | ISocexplorerPlugin(QWidget *parent = Q_NULLPTR,bool createPyObject=true):QDockWidget(parent) | |
|
56 | { | |
|
57 | Q_UNUSED(createPyObject) | |
|
58 | closeAction=Q_NULLPTR; | |
|
59 | menu=Q_NULLPTR; | |
|
60 | ChildsMenu=Q_NULLPTR; | |
|
61 | this->Connected = false; | |
|
62 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar); | |
|
63 | } | |
|
64 | //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces. | |
|
65 | virtual bool isConnected(){return this->Connected;} | |
|
66 | //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found | |
|
67 | //! hardware while board enumeration. | |
|
68 | virtual uint64_t baseAddress(){return this->BaseAddress;} | |
|
69 | //! Sets the base address of the current instance, for example if your plugin is supposed to drive | |
|
70 | //! an UART it will correspond to the address of it's first register. This address have at least to | |
|
71 | //! be set by SocExplorer and it can be user accessible if you want. | |
|
72 | virtual void setBaseAddress(uint64_t baseAddress){this->BaseAddress = baseAddress;} | |
|
73 | ||
|
74 | QList<ISocexplorerPlugin*> childs; | |
|
75 | ISocexplorerPlugin* parent; | |
|
76 | QAction* closeAction; | |
|
77 | QString instanceName(){return _instanceName;} | |
|
78 | QString instance(){return instanceName();} | |
|
79 | QMenu* menu; | |
|
80 | QMenu* ChildsMenu; | |
|
81 | ||
|
82 | signals: | |
|
83 | //! Signal emited each time the plugin is about to be closed. | |
|
84 | void closePlugin(ISocexplorerPlugin* driver); | |
|
85 | void activateSig(bool flag); | |
|
86 | void registerObject(QObject* object,const QString& instanceName); | |
|
87 | ||
|
88 | public slots: | |
|
89 | virtual int registermenu(QMenu* menu) | |
|
90 | { | |
|
91 | this->menu = menu->addMenu(this->_instanceName); | |
|
92 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
|
93 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
|
94 | this->ChildsMenu = this->menu->addMenu(QString("Childs")); | |
|
95 | for(int i=0;i<this->childs.count();i++) | |
|
96 | { | |
|
97 | this->childs.at(i)->registermenu(this->ChildsMenu); | |
|
98 | } | |
|
99 | emit this->registerObject((QObject*)this,this->instanceName()); | |
|
100 | return 0; | |
|
101 | } | |
|
102 | virtual void postInstantiationTrigger(){} | |
|
103 | //! Write slot this is the way your children plugins ask you for writing data. | |
|
104 | //! If your plugin is supposed to have childern drivers you should implement this methode. | |
|
105 | //! By default this methode forward the write request to the parent plugin. | |
|
106 | //! \param Value Pointer the data buffer. | |
|
107 | //! \param count Number of 32 bits words you should to write. | |
|
108 | //! \param address Address from where you should to start to write. | |
|
109 | //! \return Quantity of 32 bits words writtens. | |
|
110 | virtual unsigned int Write(unsigned int* Value, int count, uint64_t address) | |
|
111 | { | |
|
112 | if(parent!=Q_NULLPTR) | |
|
113 | { | |
|
114 | return parent->Write(Value,count,address); | |
|
115 | } | |
|
116 | return 0; | |
|
117 | } | |
|
118 | ||
|
119 | void Write(uint64_t address, QList<QVariant> dataList) | |
|
120 | { | |
|
121 | unsigned int data[dataList.count()]; | |
|
122 | for(int i = 0;i<dataList.count();i++) | |
|
123 | { | |
|
124 | data[i] = (unsigned int)dataList.at(i).toUInt(); | |
|
125 | } | |
|
126 | Write(data,dataList.count(),address); | |
|
127 | } | |
|
128 | //! Read slot this is the way your children plugins ask you for reading data. | |
|
129 | //! If your plugin is supposed to have childern drivers you should implement this methode. | |
|
130 | //! By default this methode forward the write request to the parent plugin. | |
|
131 | //! \param Value Pointer the data buffer. | |
|
132 | //! \param count Number of 32 bits words you should to read. | |
|
133 | //! \param address Address from where you should to start to read. | |
|
134 | //! \return Quantity of 32 bits words read. | |
|
135 | virtual unsigned int Read(unsigned int* Value, int count, uint64_t address) | |
|
136 | { | |
|
137 | if(parent!=Q_NULLPTR) | |
|
138 | { | |
|
139 | return parent->Read(Value,count,address); | |
|
140 | } | |
|
141 | return 0; | |
|
142 | } | |
|
143 | QVariantList Read(uint64_t address, int count) | |
|
144 | { | |
|
145 | unsigned int data[count]; | |
|
146 | QVariantList result; | |
|
147 | Read(data,count,address); | |
|
148 | for(int i = 0;i<count;i++) | |
|
149 | { | |
|
150 | result.append(QVariant(static_cast<int>(data[i]))); | |
|
151 | } | |
|
152 | return result; | |
|
153 | } | |
|
154 | ||
|
155 | virtual void closeMe(){emit this->closePlugin(this);} | |
|
156 | ||
|
157 | virtual void activate(bool flag) | |
|
158 | { | |
|
159 | this->setEnabled(flag); | |
|
160 | emit this->activateSig(flag); | |
|
161 | } | |
|
162 | ||
|
163 | virtual void setInstanceName(const QString& newName) | |
|
164 | { | |
|
165 | this->_instanceName = newName; | |
|
166 | if(this->menu) | |
|
167 | this->menu->setTitle(this->_instanceName); | |
|
168 | this->setWindowTitle(newName); | |
|
169 | this->setObjectName(newName); | |
|
170 | } | |
|
171 | ||
|
172 | virtual bool dumpMemory(uint64_t address, unsigned int count, QString file) | |
|
173 | { | |
|
174 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
|
175 | if(buffer!=NULL) | |
|
176 | { | |
|
177 | this->Read(buffer,count,address); | |
|
178 | QFile outfile(file); | |
|
179 | if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text)) | |
|
180 | return false; | |
|
181 | QTextStream out(&outfile); | |
|
182 | for(int i=0;(unsigned int)i<count;i++) | |
|
183 | out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n"; | |
|
184 | free(buffer); | |
|
185 | out.flush(); | |
|
186 | outfile.close(); | |
|
187 | return true; | |
|
188 | } | |
|
189 | return false; | |
|
190 | } | |
|
191 | ||
|
192 | virtual bool dumpMemory(uint64_t address,unsigned int count,QString file,const QString& format) | |
|
193 | { | |
|
194 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
|
195 | if(buffer!=NULL) | |
|
196 | { | |
|
197 | this->Read(buffer,count,address); | |
|
198 | if(!format.compare("srec",Qt::CaseInsensitive)) | |
|
199 | { | |
|
200 | //need to convert from in memory endianness to file endianness | |
|
201 | //SREC is always big endian | |
|
202 | #if __BYTE_ORDER == __LITTLE_ENDIAN | |
|
203 | for(int l=0;l<(count);l++) | |
|
204 | { | |
|
205 | buffer[l] = socexplorerBswap32(buffer[l]); | |
|
206 | } | |
|
207 | #elif __BYTE_ORDER == __BIG_ENDIAN | |
|
208 | ||
|
209 | #endif | |
|
210 | codeFragment fragment((char*)buffer,count*4,address); | |
|
211 | srecFile::toSrec(QList<codeFragment*>()<<&fragment,file); | |
|
212 | } | |
|
213 | if(!format.compare("bin",Qt::CaseInsensitive)) | |
|
214 | { | |
|
215 | //beware this format is not portable from a big endian host to a litle endian one | |
|
216 | codeFragment fragment((char*)buffer,count*4,address); | |
|
217 | binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file); | |
|
218 | } | |
|
219 | if(!format.compare("hexa",Qt::CaseInsensitive)) | |
|
220 | { | |
|
221 | QFile outfile(file); | |
|
222 | if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text)) | |
|
223 | return false; | |
|
224 | QTextStream out(&outfile); | |
|
225 | for(int i=0;(unsigned int)i<count;i++) | |
|
226 | out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n"; | |
|
227 | free(buffer); | |
|
228 | out.flush(); | |
|
229 | outfile.close(); | |
|
230 | } | |
|
231 | return true; | |
|
232 | } | |
|
233 | return false; | |
|
234 | } | |
|
235 | ||
|
236 | virtual bool memSet(uint64_t address, int value, unsigned int count) | |
|
237 | { | |
|
238 | unsigned int* buffer = static_cast<unsigned int*>(malloc(count*sizeof(unsigned int))); | |
|
239 | if(buffer!=Q_NULLPTR) | |
|
240 | { | |
|
241 | memset(static_cast<void*>(buffer),value,count*sizeof(unsigned int)); | |
|
242 | this->Write(buffer,count,address); | |
|
243 | free(buffer ); | |
|
244 | return true; | |
|
245 | } | |
|
246 | return false; | |
|
247 | } | |
|
248 | ||
|
249 | virtual bool loadbin(uint64_t address,QString file) | |
|
250 | { | |
|
251 | QFile infile(file); | |
|
252 | if (!infile.open(QIODevice::ReadOnly)) | |
|
253 | return false; | |
|
254 | uint32_t* buffer = (uint32_t*)malloc(infile.size()); | |
|
255 | if(buffer!=NULL) | |
|
256 | { | |
|
257 | infile.read((char*)buffer,infile.size()); | |
|
258 | for(int i=0;i<(infile.size()/4);i++) | |
|
259 | { | |
|
260 | buffer[i] = socexplorerBswap32(buffer[i]); | |
|
261 | } | |
|
262 | this->Write(buffer,infile.size()/4,address); | |
|
263 | free(buffer); | |
|
264 | return true; | |
|
265 | } | |
|
266 | return false; | |
|
267 | ||
|
268 | } | |
|
269 | ||
|
270 | virtual bool loadfile(abstractBinFile* file) | |
|
271 | { | |
|
272 | { | |
|
273 | if(file->isopened()) | |
|
274 | { | |
|
275 | QList<codeFragment*> fragments= file->getFragments(); | |
|
276 | for(int i=0;i<fragments.count();i++) | |
|
277 | { | |
|
278 | int size = fragments.at(i)->size/4; | |
|
279 | // TODO fixme, should be the oposite | |
|
280 | #if __BYTE_ORDER == __LITTLE_ENDIAN | |
|
281 | if(!file->litleendian) | |
|
282 | { | |
|
283 | uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size); | |
|
284 | memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size); | |
|
285 | if(buffer!=NULL) | |
|
286 | { | |
|
287 | for(int l=0;l<(size);l++) | |
|
288 | { | |
|
289 | buffer[l] = socexplorerBswap32(buffer[l]); | |
|
290 | } | |
|
291 | this->Write(buffer,size,fragments.at(i)->address); | |
|
292 | free(buffer); | |
|
293 | } | |
|
294 | } | |
|
295 | else | |
|
296 | { | |
|
297 | this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address); | |
|
298 | } | |
|
299 | #elif __BYTE_ORDER == __BIG_ENDIAN | |
|
300 | if(file->litleendian) | |
|
301 | { | |
|
302 | uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size); | |
|
303 | memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size); | |
|
304 | if(buffer!=NULL) | |
|
305 | { | |
|
306 | for(int l=0;l<(size);l++) | |
|
307 | { | |
|
308 | buffer[l] = socexplorerBswap32(buffer[l]); | |
|
309 | } | |
|
310 | this->Write(buffer,size,fragments.at(i)->address); | |
|
311 | free(buffer); | |
|
312 | } | |
|
313 | } | |
|
314 | else | |
|
315 | { | |
|
316 | this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address); | |
|
317 | } | |
|
318 | #endif | |
|
319 | } | |
|
320 | } | |
|
321 | return true; | |
|
322 | } | |
|
323 | } | |
|
324 | ISocexplorerPlugin* parentPlugin(){return this->parent;} | |
|
325 | ISocexplorerPlugin* toPlugin(){return static_cast<ISocexplorerPlugin*>(this);} | |
|
326 | protected: | |
|
327 | QString _instanceName; | |
|
328 | uint64_t BaseAddress; | |
|
329 | bool Connected; | |
|
330 | }; | |
|
331 | ||
|
332 | Q_DECLARE_INTERFACE(ISocexplorerPlugin, "socexplorer.plugins.ISocexplorerPlugin") | |
|
333 | ||
|
334 | #endif // ISOCEXPLORERPLUGIN_H |
@@ -1,186 +1,189 | |||
|
1 | 1 | SOCEXPLORER_ROOT = \"$${PWD}/../..\" |
|
2 | 2 | |
|
3 | 3 | include($${PWD}/../../build_cfg/socexplorer.pri) |
|
4 | 4 | |
|
5 | 5 | TARGET = socexplorerengine$${DEBUG_EXT} |
|
6 | 6 | TEMPLATE = lib |
|
7 | 7 | |
|
8 | 8 | #more verbose plugin loader to debug plugin loading issues such as dependencies issues |
|
9 | 9 | SOCEXPLORER_PLUGIN_LOADER="custom" |
|
10 | 10 | |
|
11 | 11 | SOCEXPLORER_CHAGESETNUM=$$system(hg id) |
|
12 | 12 | isEmpty(SOCEXPLORER_CHAGESETNUM){ |
|
13 | 13 | SOCEXPLORER_CHAGESETNUM=c459540a6dbdcbb4e17f204685fce02c070ba971+ |
|
14 | 14 | } |
|
15 | 15 | SOCEXPLORER_CHAGESETNUMSTR = '\\"$${SOCEXPLORER_CHAGESETNUM}\\"' |
|
16 | 16 | SOCEXPLORER_BRANCH=$$system(hg branch) |
|
17 | 17 | isEmpty(SOCEXPLORER_BRANCH){ |
|
18 | 18 | SOCEXPLORER_BRANCH=default |
|
19 | 19 | } |
|
20 | 20 | SOCEXPLORER_BRANCHSTR = '\\"$${SOCEXPLORER_BRANCH}\\"' |
|
21 | 21 | |
|
22 | 22 | DEFINES += SOCEXPLORER_VERSION="\"\\\"0.7.0"\\\"\" |
|
23 | 23 | DEFINES += SOCEXPLORER_CHAGESET=\"$${SOCEXPLORER_CHAGESETNUMSTR}\" |
|
24 | 24 | DEFINES += SOCEXPLORER_BRANCH=\"$${SOCEXPLORER_BRANCHSTR}\" |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | message("Building SOCEXPLORER changeset $${SOCEXPLORER_CHAGESETNUM}") |
|
28 | 28 | |
|
29 | 29 | DEFINES += SOCEXPLORER_EXPORTS |
|
30 | 30 | |
|
31 | 31 | include ( plugins/socexplorerplugin.prf ) |
|
32 | 32 | include ( PeripheralWidget/PeripheralWidget.pri) |
|
33 | 33 | |
|
34 | 34 | win32:CONFIG += dll |
|
35 | 35 | win32:CONFIG -= static |
|
36 | 36 | win32:LIBS+=-L$${SOCEXPLORER_ROOT}/bin/win32 -lsocexplorercommon$${DEBUG_EXT} |
|
37 | 37 | |
|
38 | 38 | contains(SOCEXPLORER_PLUGIN_LOADER,"custom") |
|
39 | 39 | { |
|
40 | 40 | unix:LIBS+= -ldl |
|
41 | 41 | unix:DEFINES += SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
42 | 42 | unix:HEADERS += \ |
|
43 | 43 | pluginloader/unix/unixpluginloader.h |
|
44 | 44 | unix:SOURCES += \ |
|
45 | 45 | pluginloader/unix/unixpluginloader.cpp |
|
46 | 46 | } |
|
47 | 47 | |
|
48 | 48 | target.path = $$[QT_INSTALL_LIBS] |
|
49 | 49 | isEmpty(target.path) { |
|
50 | 50 | error(can\'t get QT_INSTALL_LIBS) |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | header.path = $$[QT_INSTALL_HEADERS]/SocExplorer |
|
54 | 54 | header.files = engine/socexplorerengine.h \ |
|
55 | 55 | pluginloader/pluginscache.h \ |
|
56 | 56 | plugins/socexplorerplugin.h \ |
|
57 | 57 | proxy/socexplorerproxy.h \ |
|
58 | 58 | engine/socexplorerxmlfile.h \ |
|
59 | 59 | SOC/socexplorerenumdevice.h \ |
|
60 | 60 | XmlEngine/XMLmodel.h \ |
|
61 | 61 | XmlEngine/XMLdata.h \ |
|
62 | 62 | XmlEngine/xmldriver.h \ |
|
63 | 63 | SOC/socmodel.h \ |
|
64 | 64 | SOC/registerdata.h \ |
|
65 | 65 | SOC/socclk.h \ |
|
66 | 66 | PeripheralWidget/src/peripheralwidget.h \ |
|
67 | 67 | PeripheralWidget/src/registerwidget.h \ |
|
68 | 68 | PeripheralWidget/src/socregsviewer.h \ |
|
69 | 69 | PeripheralWidget/src/socregsviewernew.h \ |
|
70 | 70 | memtester/memtester.h \ |
|
71 | 71 | engine/socexplorersettings.h \ |
|
72 | 72 | engine/socexplorersettingsdialog.h \ |
|
73 | 73 | engine/socexplorergui.h\ |
|
74 | 74 | engine/socexplorerconfigkeys.h |
|
75 | 75 | |
|
76 | 76 | |
|
77 | 77 | |
|
78 | 78 | isEmpty(header.path) { |
|
79 | 79 | error(can\'t get QT_INSTALL_HEADERS) |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | pluginif.files = pluginsInterface/*.h \ |
|
83 | 83 | pluginsInterface/*.cpp |
|
84 | 84 | |
|
85 | 85 | pluginif.path = $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface |
|
86 | 86 | |
|
87 | 87 | |
|
88 | 88 | INSTALLS += target header pluginif |
|
89 | 89 | |
|
90 | 90 | INCLUDEPATH += engine \ |
|
91 | 91 | pluginloader \ |
|
92 | 92 | pluginsInterface \ |
|
93 | 93 | proxy \ |
|
94 | 94 | plugins \ |
|
95 | 95 | pluginManagerWdgt \ |
|
96 | 96 | ../common \ |
|
97 | 97 | ../common/genericBinaryFiles \ |
|
98 | 98 | ../ \ |
|
99 | 99 | RegisterMVS \ |
|
100 | 100 | XmlEngine \ |
|
101 | 101 | SOC \ |
|
102 | 102 | PeripheralWidget/src \ |
|
103 | 103 | memtester |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | HEADERS += \ |
|
107 | 107 | pluginloader/pluginscache.h \ |
|
108 | 108 | pluginloader/pluginloader.h \ |
|
109 | 109 | pluginManagerWdgt/plugintree.h \ |
|
110 | 110 | pluginManagerWdgt/pluginmanagerWDGT.h \ |
|
111 | 111 | pluginManagerWdgt/pluginlist.h \ |
|
112 | 112 | pluginManagerWdgt/plugininfoswdgt.h \ |
|
113 | 113 | XmlEngine/XMLmodel.h \ |
|
114 | 114 | XmlEngine/XMLdata.h \ |
|
115 | 115 | SOC/socmodel.h \ |
|
116 | 116 | SOC/registerdata.h \ |
|
117 | 117 | XmlEngine/xmldriver.h \ |
|
118 | 118 | PeripheralWidget/src/peripheralwidget.h \ |
|
119 | 119 | PeripheralWidget/src/registerwidget.h \ |
|
120 | 120 | PeripheralWidget/src/socregsviewer.h \ |
|
121 | 121 | SOC/socclk.h \ |
|
122 | 122 | engine/socexplorerengine.h \ |
|
123 | 123 | engine/socexplorerxmlfile.h \ |
|
124 | 124 | plugins/socexplorerplugin.h \ |
|
125 | 125 | pluginsInterface/socexplorerplugininterface.h \ |
|
126 | 126 | pluginsInterface/socexplorerplugininterface_global.h \ |
|
127 | 127 | proxy/socexplorerproxy.h \ |
|
128 | 128 | SOC/socexplorerenumdevice.h \ |
|
129 | 129 | PySocExplorerEngine.h \ |
|
130 | 130 | memtester/memtester.h\ |
|
131 | 131 | PeripheralWidget/src/socregsviewernew.h \ |
|
132 | 132 | PeripheralWidget/src/collapsableperipheralwidget.h \ |
|
133 | 133 | engine/socexplorersettings.h \ |
|
134 | 134 | engine/socexplorersettingsdialog.h \ |
|
135 | 135 | engine/socexplorergui.h \ |
|
136 | engine/socexplorerconfigkeys.h | |
|
136 | engine/socexplorerconfigkeys.h \ | |
|
137 | pluginsInterface/isocexplorerplugin.h \ | |
|
138 | pluginloaderV2/pluginmanager.h | |
|
137 | 139 | |
|
138 | 140 | |
|
139 | 141 | |
|
140 | 142 | |
|
141 | 143 | |
|
142 | 144 | |
|
143 | 145 | SOURCES += \ |
|
144 | 146 | pluginloader/pluginscache.cpp \ |
|
145 | 147 | pluginloader/pluginloader.cpp \ |
|
146 | 148 | pluginManagerWdgt/plugintree.cpp \ |
|
147 | 149 | pluginManagerWdgt/pluginmanagerWDGT.cpp \ |
|
148 | 150 | pluginManagerWdgt/pluginlist.cpp \ |
|
149 | 151 | pluginManagerWdgt/plugininfoswdgt.cpp \ |
|
150 | 152 | XmlEngine/XMLmodel.cpp \ |
|
151 | 153 | XmlEngine/XMLdata.cpp \ |
|
152 | 154 | SOC/socmodel.cpp \ |
|
153 | 155 | SOC/registerdata.cpp \ |
|
154 | 156 | XmlEngine/xmldriver.cpp \ |
|
155 | 157 | PeripheralWidget/src/peripheralwidget.cpp \ |
|
156 | 158 | PeripheralWidget/src/registerwidget.cpp \ |
|
157 | 159 | PeripheralWidget/src/socregsviewer.cpp \ |
|
158 | 160 | SOC/socclk.cpp \ |
|
159 | 161 | engine/socexplorerengine.cpp \ |
|
160 | 162 | engine/socexplorerxmlfile.cpp \ |
|
161 | 163 | proxy/socexplorerproxy.cpp \ |
|
162 | 164 | SOC/socexplorerenumdevice.cpp \ |
|
163 | 165 | plugins/socexplorerplugin.cpp \ |
|
164 | 166 | memtester/memtester.cpp \ |
|
165 | 167 | PeripheralWidget/src/socregsviewernew.cpp \ |
|
166 | 168 | PeripheralWidget/src/collapsableperipheralwidget.cpp \ |
|
167 | 169 | engine/socexplorersettings.cpp \ |
|
168 | 170 | engine/socexplorersettingsdialog.cpp \ |
|
169 | engine/socexplorergui.cpp | |
|
171 | engine/socexplorergui.cpp \ | |
|
172 | pluginloaderV2/pluginmanager.cpp | |
|
170 | 173 | |
|
171 | 174 | |
|
172 | 175 | OTHER_FILES += \ |
|
173 | 176 | plugins/socexplorerplugin.cpp \ |
|
174 | 177 | pluginsInterface/socexplorerplugininterface.cpp \ |
|
175 | 178 | plugins/socexplorerplugin.prf \ |
|
176 | 179 | pythongenerator.sh \ |
|
177 | 180 | pythonQtgeneratorCfg.txt |
|
178 | 181 | |
|
179 | 182 | FORMS += \ |
|
180 | 183 | PeripheralWidget/src/socregsviewernew.ui \ |
|
181 | 184 | PeripheralWidget/src/collapsableperipheralwidget.ui \ |
|
182 | 185 | engine/socexplorersettingsdialog.ui |
|
183 | 186 | |
|
184 | 187 | |
|
185 | 188 | RESOURCES += \ |
|
186 | 189 | PeripheralWidget/ressources/peripheralwidget.qrc |
@@ -1,531 +1,468 | |||
|
1 | 1 | #include "pluginloader.h" |
|
2 | 2 | #include <QDir> |
|
3 | 3 | #include <QFile> |
|
4 | 4 | #include <QFileInfoList> |
|
5 | 5 | #include <QFileInfo> |
|
6 | 6 | #include <QString> |
|
7 | 7 | #include <QStringList> |
|
8 | 8 | #include <QLabel> |
|
9 | 9 | #include <QSettings> |
|
10 | 10 | #include <QApplication> |
|
11 | 11 | #include <QCoreApplication> |
|
12 | 12 | #include <socexplorerengine.h> |
|
13 | 13 | #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
14 | 14 | #include "unix/unixpluginloader.h" |
|
15 | 15 | #endif |
|
16 | 16 | #include <socexplorerengine.h> |
|
17 | 17 | #include <socexplorersettings.h> |
|
18 | 18 | |
|
19 | 19 | pluginloader* pluginloader::_self = NULL; |
|
20 | 20 | PluginsCache* pluginloader::_cache = NULL; |
|
21 | 21 | QStringList* pluginloader::_folderList = NULL; |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | pluginloader::pluginloader() |
|
25 | 25 | { |
|
26 | 26 | _cache = new PluginsCache(); |
|
27 | 27 | _folderList = new QStringList(); |
|
28 | 28 | _folderList->append(SocExplorerEngine::pluginFolders()); |
|
29 | 29 | scanFolders(); |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | void pluginloader::scanFolders() |
|
33 | 33 | { |
|
34 | 34 | QDir dir; |
|
35 | 35 | QStringList filters; |
|
36 | 36 | filters <<"*.so"<< "*.dll"; |
|
37 | 37 | _cache->flush(); |
|
38 | 38 | for(int d=0;d<_folderList->count();d++) |
|
39 | 39 | { |
|
40 | 40 | dir.setPath(_folderList->at(d)); |
|
41 | 41 | dir.setFilter(QDir::Files); |
|
42 | 42 | dir.setNameFilters(filters); |
|
43 | 43 | QFileInfoList list = dir.entryInfoList(); |
|
44 | 44 | for (int i = 0; i < list.size(); ++i) |
|
45 | 45 | { |
|
46 | 46 | QFileInfo fileInfo = list.at(i); |
|
47 | 47 | SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ fileInfo.filePath(),3); |
|
48 | 48 | if(checklibrary(fileInfo.filePath())!=0) |
|
49 | 49 | { |
|
50 | 50 | _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath())); |
|
51 | 51 | } |
|
52 | 52 | } |
|
53 | 53 | } |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | int pluginloader::p_checklibraryQlib(const QString fileName) |
|
57 | 57 | { |
|
58 | 58 | QLibrary* lib = new QLibrary; |
|
59 | 59 | lib->setFileName(fileName); |
|
60 | 60 | lib->setLoadHints(QLibrary::PreventUnloadHint); |
|
61 | 61 | lib->load(); |
|
62 | 62 | if(!lib->isLoaded()) |
|
63 | 63 | { |
|
64 | 64 | SocExplorerEngine::message("pluginloader::p_checklibraryQlib",lib->errorString(),3); |
|
65 | 65 | lib->~QLibrary(); |
|
66 | 66 | lib = new QLibrary(fileName); |
|
67 | 67 | lib->load(); |
|
68 | 68 | } |
|
69 | 69 | delete lib; |
|
70 | 70 | if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject")) |
|
71 | 71 | { |
|
72 | 72 | if(QLibrary::resolve(fileName,"socexplorerpluginpid")) |
|
73 | 73 | { |
|
74 | 74 | if(QLibrary::resolve(fileName,"socexplorerpluginvid")) |
|
75 | 75 | { |
|
76 | 76 | if(QLibrary::resolve(fileName,"socexplorerpluginVersion")) |
|
77 | 77 | { |
|
78 | 78 | if(QLibrary::resolve(fileName,"socexplorerpluginAuthor")) |
|
79 | 79 | { |
|
80 | 80 | if(QLibrary::resolve(fileName,"socexplorerpluginDescription")) |
|
81 | 81 | { |
|
82 | 82 | return 1; |
|
83 | 83 | } |
|
84 | 84 | } |
|
85 | 85 | } |
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | } |
|
89 | 89 | return 0; |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | int pluginloader::p_checklibraryCustom(const QString fileName) |
|
93 | 93 | { |
|
94 | 94 | #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
95 | 95 | unixPluginLoader lib(fileName); |
|
96 | 96 | if(NULL!=lib.resolve("socexplorerpluginCreateObject")) |
|
97 | 97 | { |
|
98 | 98 | if(NULL!=lib.resolve("socexplorerpluginpid")) |
|
99 | 99 | { |
|
100 | 100 | if(NULL!=lib.resolve("socexplorerpluginvid")) |
|
101 | 101 | { |
|
102 | 102 | if(NULL!=lib.resolve("socexplorerpluginVersion")) |
|
103 | 103 | { |
|
104 | 104 | if(NULL!=lib.resolve("socexplorerpluginAuthor")) |
|
105 | 105 | { |
|
106 | 106 | if(NULL!=lib.resolve("socexplorerpluginDescription")) |
|
107 | 107 | { |
|
108 | 108 | return 1; |
|
109 | 109 | } |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | } |
|
113 | 113 | } |
|
114 | 114 | } |
|
115 | 115 | #endif |
|
116 | 116 | return 0; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name) |
|
120 | 120 | { |
|
121 | 121 | QString* libfile= _cacheLookup(Name); |
|
122 | 122 | if(libfile==NULL)return NULL; |
|
123 | 123 | QLibrary* lib = new QLibrary(*libfile); |
|
124 | 124 | delete libfile; |
|
125 | 125 | socexplorerpluginCreateObjectT newDrvr = NULL; |
|
126 | 126 | newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject"); |
|
127 | 127 | if(newDrvr==NULL) |
|
128 | 128 | { |
|
129 | 129 | return NULL; |
|
130 | 130 | } |
|
131 | 131 | return (socexplorerplugin*) newDrvr(); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name) |
|
135 | 135 | { |
|
136 | 136 | #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
137 | 137 | QString* libfile= _cacheLookup(Name); |
|
138 | 138 | if(libfile==NULL)return NULL; |
|
139 | 139 | unixPluginLoader lib(*libfile); |
|
140 | 140 | delete libfile; |
|
141 | 141 | socexplorerpluginCreateObjectT newDrvr = NULL; |
|
142 | 142 | newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject"); |
|
143 | 143 | if(newDrvr==NULL) |
|
144 | 144 | { |
|
145 | 145 | return NULL; |
|
146 | 146 | } |
|
147 | 147 | return (socexplorerplugin*) newDrvr(); |
|
148 | 148 | #endif |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan) |
|
152 | 152 | { |
|
153 | 153 | if(_self==NULL) |
|
154 | 154 | { |
|
155 | 155 | init(); |
|
156 | 156 | return _cache->listDrivers(); |
|
157 | 157 | } |
|
158 | 158 | if(rescan) |
|
159 | 159 | { |
|
160 | 160 | scanFolders(); |
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | return _cache->listDrivers(); |
|
164 | 164 | } |
|
165 | 165 | |
|
166 | 166 | |
|
167 | 167 | void pluginloader::init() |
|
168 | 168 | { |
|
169 | 169 | if(_self==NULL) |
|
170 | 170 | { |
|
171 | 171 | _self=new pluginloader(); |
|
172 | 172 | } |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | |
|
176 | 176 | pluginloader* pluginloader::self() |
|
177 | 177 | { |
|
178 | 178 | if(_self==NULL) |
|
179 | 179 | { |
|
180 | 180 | init(); |
|
181 | 181 | } |
|
182 | 182 | return _self; |
|
183 | 183 | } |
|
184 | 184 | |
|
185 | 185 | bool pluginloader::isvalid(QString Name) |
|
186 | 186 | { |
|
187 | 187 | if(_self==NULL)init(); |
|
188 | 188 | QString* libfile= _cacheLookup(Name); |
|
189 | 189 | if(libfile==NULL)return false; |
|
190 | 190 | else |
|
191 | 191 | { |
|
192 | 192 | delete libfile; |
|
193 | 193 | return true; |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | int pluginloader::checklibrary(const QString fileName) |
|
199 | 199 | { |
|
200 | 200 | #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
201 | 201 | return _self->p_checklibraryCustom(fileName); |
|
202 | 202 | #else |
|
203 | 203 | return _self->p_checklibraryQlib(fileName); |
|
204 | 204 | #endif |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | |
|
208 | 208 | |
|
209 | 209 | |
|
210 | 210 | |
|
211 | 211 | socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name) |
|
212 | 212 | { |
|
213 | 213 | #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER |
|
214 | 214 | return _self->p_newsocexplorerpluginCustom(Name); |
|
215 | 215 | #else |
|
216 | 216 | return _self->p_newsocexplorerpluginQlib(Name); |
|
217 | 217 | #endif |
|
218 | 218 | } |
|
219 | 219 | |
|
220 | ||
|
221 | QString pluginloader::getlibTypeStr(QString Name) | |
|
222 | { | |
|
223 | if(_self==NULL)init(); | |
|
224 | QString* libfile= _cacheLookup(Name); | |
|
225 | if(libfile==NULL)return NULL; | |
|
226 | QLibrary* lib = new QLibrary(*libfile); | |
|
227 | delete libfile; | |
|
228 | lib->load(); | |
|
229 | if(lib->isLoaded()) | |
|
230 | { | |
|
231 | socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType"); | |
|
232 | if(plugintype!=NULL) | |
|
233 | { | |
|
234 | pluginT type = plugintype(); | |
|
235 | switch(type) | |
|
236 | { | |
|
237 | case ComDriverT: | |
|
238 | ////lib->unload(); | |
|
239 | lib->~QLibrary(); | |
|
240 | return QObject::tr("Comunaication Driver Plugin."); | |
|
241 | break; | |
|
242 | case PerifDriverT: | |
|
243 | ////lib->unload(); | |
|
244 | lib->~QLibrary(); | |
|
245 | return QObject::tr("Periferial Driver Plugin."); | |
|
246 | break; | |
|
247 | default: | |
|
248 | ////lib->unload(); | |
|
249 | lib->~QLibrary(); | |
|
250 | return QObject::tr("Unknow Plugin."); | |
|
251 | break; | |
|
252 | } | |
|
253 | } | |
|
254 | } | |
|
255 | lib->~QLibrary(); | |
|
256 | return QObject::tr("Can't load Plugin."); | |
|
257 | } | |
|
258 | ||
|
259 | ||
|
260 | ||
|
261 | ||
|
262 | pluginT pluginloader::getlibType(QString Name) | |
|
263 | { | |
|
264 | if(_self==NULL)init(); | |
|
265 | QString* libfile= _cacheLookup(Name); | |
|
266 | if(libfile==NULL)return (pluginT)NULL; | |
|
267 | QLibrary* lib = new QLibrary(*libfile); | |
|
268 | delete libfile; | |
|
269 | lib->load(); | |
|
270 | if(lib->isLoaded()) | |
|
271 | { | |
|
272 | socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType"); | |
|
273 | if(plugintype!=NULL) | |
|
274 | { | |
|
275 | return plugintype(); | |
|
276 | } | |
|
277 | } | |
|
278 | lib->~QLibrary(); | |
|
279 | return -1; | |
|
280 | } | |
|
281 | ||
|
282 | ||
|
283 | 220 | QString pluginloader::getlibVersion(const QString Name) |
|
284 | 221 | { |
|
285 | 222 | if(_self==NULL)init(); |
|
286 | 223 | QString* libfile= _cacheLookup(Name); |
|
287 | 224 | if(libfile==NULL)return NULL; |
|
288 | 225 | QLibrary* lib = new QLibrary(*libfile); |
|
289 | 226 | delete libfile; |
|
290 | 227 | lib->load(); |
|
291 | 228 | if(lib->isLoaded()) |
|
292 | 229 | { |
|
293 | 230 | socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion"); |
|
294 | 231 | if(pluginversion!=NULL) |
|
295 | 232 | { |
|
296 | 233 | QString version = pluginversion(); |
|
297 | 234 | ////lib->unload(); |
|
298 | 235 | lib->~QLibrary(); |
|
299 | 236 | return version; |
|
300 | 237 | } |
|
301 | 238 | } |
|
302 | 239 | lib->~QLibrary(); |
|
303 | 240 | return QObject::tr("Can't load Plugin."); |
|
304 | 241 | } |
|
305 | 242 | |
|
306 | 243 | |
|
307 | 244 | |
|
308 | 245 | QString pluginloader::getlibPIDstr(const QString Name) |
|
309 | 246 | { |
|
310 | 247 | return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16)); |
|
311 | 248 | } |
|
312 | 249 | |
|
313 | 250 | QString pluginloader::getlibVIDstr(const QString Name) |
|
314 | 251 | { |
|
315 | 252 | return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16)); |
|
316 | 253 | } |
|
317 | 254 | |
|
318 | 255 | |
|
319 | 256 | |
|
320 | 257 | int pluginloader::libcanbechild(const QString Name) |
|
321 | 258 | { |
|
322 | 259 | if(_self==NULL)init(); |
|
323 | 260 | QString* libfile= _cacheLookup(Name); |
|
324 | 261 | if(libfile==NULL)return (int)NULL; |
|
325 | 262 | QLibrary* lib = new QLibrary(*libfile); |
|
326 | 263 | delete libfile; |
|
327 | 264 | lib->load(); |
|
328 | 265 | if(lib->isLoaded()) |
|
329 | 266 | { |
|
330 | 267 | socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild"); |
|
331 | 268 | if(canbechild!=NULL) |
|
332 | 269 | { |
|
333 | 270 | int value = canbechild(); |
|
334 | 271 | ////lib->unload(); |
|
335 | 272 | //lib->~QLibrary(); |
|
336 | 273 | return value; |
|
337 | 274 | } |
|
338 | 275 | } |
|
339 | 276 | //lib->~QLibrary(); |
|
340 | 277 | return 0; |
|
341 | 278 | } |
|
342 | 279 | |
|
343 | 280 | |
|
344 | 281 | |
|
345 | 282 | |
|
346 | 283 | int pluginloader::libcanberoot(const QString Name) |
|
347 | 284 | { |
|
348 | 285 | if(_self==NULL)init(); |
|
349 | 286 | QString* libfile= _cacheLookup(Name); |
|
350 | 287 | if(libfile==NULL)return (int)NULL; |
|
351 | 288 | QLibrary* lib = new QLibrary(*libfile); |
|
352 | 289 | delete libfile; |
|
353 | 290 | lib->load(); |
|
354 | 291 | if(lib->isLoaded()) |
|
355 | 292 | { |
|
356 | 293 | socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot"); |
|
357 | 294 | if(canberoot!=NULL) |
|
358 | 295 | { |
|
359 | 296 | int value = canberoot(); |
|
360 | 297 | ////lib->unload(); |
|
361 | 298 | //lib->~QLibrary(); |
|
362 | 299 | return value; |
|
363 | 300 | } |
|
364 | 301 | } |
|
365 | 302 | delete lib; |
|
366 | 303 | //lib->~QLibrary(); |
|
367 | 304 | return 0; |
|
368 | 305 | } |
|
369 | 306 | |
|
370 | 307 | int pluginloader::getlibVID(const QString Name) |
|
371 | 308 | { |
|
372 | 309 | if(_self==NULL)init(); |
|
373 | 310 | QString* libfile= _cacheLookup(Name); |
|
374 | 311 | if(libfile==NULL)return 0; |
|
375 | 312 | QString file(*libfile); |
|
376 | 313 | delete libfile; |
|
377 | 314 | return _getlibVID(file); |
|
378 | 315 | } |
|
379 | 316 | |
|
380 | 317 | |
|
381 | 318 | int pluginloader::getlibPID(const QString Name) |
|
382 | 319 | { |
|
383 | 320 | if(_self==NULL)init(); |
|
384 | 321 | QString* libfile= _cacheLookup(Name); |
|
385 | 322 | if(libfile==NULL)return 0; |
|
386 | 323 | QString file(*libfile); |
|
387 | 324 | delete libfile; |
|
388 | 325 | return _getlibPID(file); |
|
389 | 326 | } |
|
390 | 327 | |
|
391 | 328 | QString pluginloader::getlibAuthor(const QString Name) |
|
392 | 329 | { |
|
393 | 330 | if(_self==NULL)init(); |
|
394 | 331 | QString* libfile= _cacheLookup(Name); |
|
395 | 332 | if(libfile==NULL)return NULL; |
|
396 | 333 | QLibrary* lib = new QLibrary(*libfile); |
|
397 | 334 | delete libfile; |
|
398 | 335 | lib->load(); |
|
399 | 336 | if(lib->isLoaded()) |
|
400 | 337 | { |
|
401 | 338 | socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor"); |
|
402 | 339 | if(pluginauthor!=NULL) |
|
403 | 340 | { |
|
404 | 341 | QString author = pluginauthor(); |
|
405 | 342 | ////lib->unload(); |
|
406 | 343 | lib->~QLibrary(); |
|
407 | 344 | return author; |
|
408 | 345 | } |
|
409 | 346 | } |
|
410 | 347 | lib->~QLibrary(); |
|
411 | 348 | return QObject::tr("Can't load Plugin."); |
|
412 | 349 | } |
|
413 | 350 | |
|
414 | 351 | QString pluginloader::getlibName(const QString Name) |
|
415 | 352 | { |
|
416 | 353 | if(_self==NULL)init(); |
|
417 | 354 | QString* libfile= _cacheLookup(Name); |
|
418 | 355 | if(libfile==NULL)return QString(""); |
|
419 | 356 | QString file(*libfile); |
|
420 | 357 | delete libfile; |
|
421 | 358 | return _getlibName(file); |
|
422 | 359 | } |
|
423 | 360 | |
|
424 | 361 | QString pluginloader::getlibDescription(const QString Name) |
|
425 | 362 | { |
|
426 | 363 | if(_self==NULL)init(); |
|
427 | 364 | QString* libfile= _cacheLookup(Name); |
|
428 | 365 | if(libfile==NULL)return NULL; |
|
429 | 366 | QLibrary* lib = new QLibrary(*libfile); |
|
430 | 367 | delete libfile; |
|
431 | 368 | lib->load(); |
|
432 | 369 | if(lib->isLoaded()) |
|
433 | 370 | { |
|
434 | 371 | socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription"); |
|
435 | 372 | if(plugindescription!=NULL) |
|
436 | 373 | { |
|
437 | 374 | QString description = plugindescription(); |
|
438 | 375 | ////lib->unload(); |
|
439 | 376 | lib->~QLibrary(); |
|
440 | 377 | return description; |
|
441 | 378 | } |
|
442 | 379 | } |
|
443 | 380 | lib->~QLibrary(); |
|
444 | 381 | return QObject::tr("Can't load Plugin."); |
|
445 | 382 | } |
|
446 | 383 | |
|
447 | 384 | QString pluginloader::getlibDir(const QString Name) |
|
448 | 385 | { |
|
449 | 386 | if(_self==NULL)init(); |
|
450 | 387 | return *_cacheLookup(Name); |
|
451 | 388 | } |
|
452 | 389 | |
|
453 | 390 | QString pluginloader::_getlibName(const QString fileName) |
|
454 | 391 | { |
|
455 | 392 | QLibrary* lib = new QLibrary(fileName); |
|
456 | 393 | lib->load(); |
|
457 | 394 | if(lib->isLoaded()) |
|
458 | 395 | { |
|
459 | 396 | socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName"); |
|
460 | 397 | if(pluginName!=NULL) |
|
461 | 398 | { |
|
462 | 399 | QString name = pluginName(); |
|
463 | 400 | //lib->unload(); |
|
464 | 401 | lib->~QLibrary(); |
|
465 | 402 | return name; |
|
466 | 403 | } |
|
467 | 404 | } |
|
468 | 405 | lib->~QLibrary(); |
|
469 | 406 | return QObject::tr("Can't load Plugin."); |
|
470 | 407 | } |
|
471 | 408 | |
|
472 | 409 | int pluginloader::_getlibPID(const QString fileName) |
|
473 | 410 | { |
|
474 | 411 | QLibrary* lib = new QLibrary(fileName); |
|
475 | 412 | lib->load(); |
|
476 | 413 | if(lib->isLoaded()) |
|
477 | 414 | { |
|
478 | 415 | socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid"); |
|
479 | 416 | if(pluginpid!=NULL) |
|
480 | 417 | { |
|
481 | 418 | int pid = pluginpid(); |
|
482 | 419 | //lib->unload(); |
|
483 | 420 | lib->~QLibrary(); |
|
484 | 421 | return pid; |
|
485 | 422 | } |
|
486 | 423 | } |
|
487 | 424 | lib->~QLibrary(); |
|
488 | 425 | return 0; |
|
489 | 426 | } |
|
490 | 427 | |
|
491 | 428 | int pluginloader::_getlibVID(const QString fileName) |
|
492 | 429 | { |
|
493 | 430 | QLibrary* lib = new QLibrary(fileName); |
|
494 | 431 | lib->load(); |
|
495 | 432 | if(lib->isLoaded()) |
|
496 | 433 | { |
|
497 | 434 | socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid"); |
|
498 | 435 | if(pluginvid!=NULL) |
|
499 | 436 | { |
|
500 | 437 | int vid = pluginvid(); |
|
501 | 438 | //lib->unload(); |
|
502 | 439 | lib->~QLibrary(); |
|
503 | 440 | return vid; |
|
504 | 441 | } |
|
505 | 442 | } |
|
506 | 443 | lib->~QLibrary(); |
|
507 | 444 | return 0; |
|
508 | 445 | } |
|
509 | 446 | |
|
510 | 447 | QString* pluginloader::_cacheLookup(const QString Name) |
|
511 | 448 | { |
|
512 | 449 | QString* libfile= new QString(_cache->first(Name)); |
|
513 | 450 | if(!QFile::exists(*libfile)) |
|
514 | 451 | { |
|
515 | 452 | scanFolders(); |
|
516 | 453 | *libfile = _cache->first(Name); |
|
517 | 454 | if(QFile::exists(*libfile))return libfile; |
|
518 | 455 | } |
|
519 | 456 | else |
|
520 | 457 | { |
|
521 | 458 | return libfile; |
|
522 | 459 | } |
|
523 | 460 | delete libfile; |
|
524 | 461 | return NULL; |
|
525 | 462 | } |
|
526 | 463 | |
|
527 | 464 | /*QString findlib(QString name) |
|
528 | 465 | { |
|
529 | 466 | |
|
530 | 467 | }*/ |
|
531 | 468 |
@@ -1,89 +1,87 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef PLUGINLOADER_H |
|
23 | 23 | #define PLUGINLOADER_H |
|
24 | 24 | |
|
25 | 25 | #include <QString> |
|
26 | 26 | #include <QLibrary> |
|
27 | 27 | #include <QObject> |
|
28 | 28 | #include <QStringList> |
|
29 | 29 | #include <socexplorerplugininterface.h> |
|
30 | 30 | #include <socexplorerplugin.h> |
|
31 | 31 | #include <pluginscache.h> |
|
32 | 32 | /* |
|
33 | 33 | Debug |
|
34 | 34 | */ |
|
35 | 35 | #include <stdio.h> |
|
36 | 36 | |
|
37 | 37 | #define loadlib(filename) QLibrary* lib = new QLibrary((fileName));\ |
|
38 | 38 | lib->load();\ |
|
39 | 39 | if(!lib->isLoaded())\ |
|
40 | 40 | {\ |
|
41 | 41 | return 0;\ |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | class pluginloader |
|
46 | 46 | { |
|
47 | 47 | |
|
48 | 48 | private: |
|
49 | 49 | static pluginloader* _self; |
|
50 | 50 | static PluginsCache* _cache; |
|
51 | 51 | static QStringList* _folderList; |
|
52 | 52 | ~pluginloader(); |
|
53 | 53 | pluginloader(); |
|
54 | 54 | public: |
|
55 | 55 | |
|
56 | 56 | static void init(); |
|
57 | 57 | static pluginloader* self(); |
|
58 | 58 | |
|
59 | 59 | static int checklibrary(const QString fileName); |
|
60 | 60 | static bool isvalid(QString Name); |
|
61 | 61 | static socexplorerplugin* newsocexplorerplugin(const QString Name); |
|
62 | static QString getlibTypeStr(QString Name); | |
|
63 | static pluginT getlibType(QString Name); | |
|
64 | 62 | static QString getlibVersion(const QString Name); |
|
65 | 63 | static QString getlibPIDstr(const QString Name); |
|
66 | 64 | static QString getlibVIDstr(const QString Name); |
|
67 | 65 | static int getlibPID(const QString Name); |
|
68 | 66 | static int getlibVID(const QString Name); |
|
69 | 67 | static int libcanbechild(const QString Name); |
|
70 | 68 | static int libcanberoot(const QString Name); |
|
71 | 69 | static QString getlibAuthor(const QString Name); |
|
72 | 70 | static QString getlibName(const QString Name); |
|
73 | 71 | static QString getlibDescription(const QString Name); |
|
74 | 72 | static QString getlibDir(const QString Name); |
|
75 | 73 | static QString findlib(QString name); |
|
76 | 74 | static QList<PluginsCacheItem *> listAvailiables(bool rescan=true); |
|
77 | 75 | static void scanFolders(); |
|
78 | 76 | static void showCache(){_cache->show();} |
|
79 | 77 | private: |
|
80 | 78 | int p_checklibraryQlib(const QString fileName); |
|
81 | 79 | int p_checklibraryCustom(const QString fileName); |
|
82 | 80 | socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name); |
|
83 | 81 | socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name); |
|
84 | 82 | static QString* _cacheLookup(const QString Name); |
|
85 | 83 | static QString _getlibName(const QString fileName); |
|
86 | 84 | static int _getlibPID(const QString fileName); |
|
87 | 85 | static int _getlibVID(const QString fileName); |
|
88 | 86 | }; |
|
89 | 87 | #endif |
@@ -1,74 +1,73 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the socexplorer Software |
|
3 | 3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef SOCEXPLORERPLUGININTERFACE_H |
|
23 | 23 | #define SOCEXPLORERPLUGININTERFACE_H |
|
24 | 24 | |
|
25 | 25 | #include "socexplorerplugininterface_global.h" |
|
26 | 26 | #include <QString> |
|
27 | 27 | #include <QtGlobal> |
|
28 | #include <QtPlugin> | |
|
28 | 29 | |
|
29 | #define ComDriverT 1 | |
|
30 | #define PerifDriverT 2 | |
|
31 | 30 | typedef int pluginT; |
|
32 | 31 | |
|
33 | 32 | typedef void* (*socexplorerpluginCreateObjectT)(); |
|
34 | 33 | typedef pluginT (*socexplorerpluginTypeT)(); |
|
35 | 34 | typedef int (*socexplorerpluginpidT)(); |
|
36 | 35 | typedef int (*socexplorerpluginvidT)(); |
|
37 | 36 | typedef int (*socexplorerplugincanberootT)(); |
|
38 | 37 | typedef int (*socexplorerplugincanbechildT)(); |
|
39 | 38 | typedef QString (*socexplorerpluginNameT)(); |
|
40 | 39 | typedef QString (*socexplorerpluginVersionT)(); |
|
41 | 40 | typedef QString (*socexplorerpluginAuthorT)(); |
|
42 | 41 | typedef QString (*socexplorerpluginDescriptionT)(); |
|
43 | 42 | |
|
44 | 43 | extern "C" |
|
45 | 44 | { |
|
46 | 45 | #ifndef QT_ENSURE_STACK_ALIGNED_FOR_SSE |
|
47 | 46 | #define QT_ENSURE_STACK_ALIGNED_FOR_SSE |
|
48 | 47 | #endif |
|
49 | 48 | //! \header This the C interface socexplorer uses to load dynamically any plugin, a C interface is the |
|
50 | 49 | //! easyest way to manually resolve functions in a dynamic library. |
|
51 | 50 | |
|
52 | 51 | //! \fn socexplorerpluginCreateObject Plugin constructor. |
|
53 | 52 | LIBSOCEXPLORERPLUGIN_EXPORT void* socexplorerpluginCreateObject()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
54 | 53 | //! \fn socexplorerpluginpid Plugin's PID. |
|
55 | 54 | LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginpid()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
56 | 55 | //! \fn socexplorerpluginvid Plugin's VID. |
|
57 | 56 | LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginvid()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
58 | 57 | //! \fn socexplorerplugincanberoot Tells if the plugin can be a root plugin. |
|
59 | 58 | LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanberoot()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
60 | 59 | //! \fn socexplorerplugincanberoot Tells if the plugin can be a child plugin. |
|
61 | 60 | LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanbechild()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
62 | 61 | //! \fn socexplorerpluginType Gives the plugin's type, not used yet. |
|
63 | 62 | LIBSOCEXPLORERPLUGIN_EXPORT pluginT socexplorerpluginType()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
64 | 63 | //! \fn socexplorerpluginVersion Gives the plugin's version. |
|
65 | 64 | LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginVersion()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
66 | 65 | //! \fn socexplorerpluginName Gives the plugin's name. |
|
67 | 66 | LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginName()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
68 | 67 | //! \fn socexplorerpluginAuthor Gives the plugin's author. |
|
69 | 68 | LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginAuthor()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
70 | 69 | //! \fn socexplorerpluginDescription Gives the plugin's description. |
|
71 | 70 | LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginDescription()QT_ENSURE_STACK_ALIGNED_FOR_SSE; |
|
72 | 71 | } |
|
73 | 72 | |
|
74 | 73 | #endif // SOCEXPLORERPLUGININTERFACE_H |
General Comments 0
You need to be logged in to leave comments.
Login now