Merge branch 'ryzom/rites' into main/gingo-test
[ryzomcore.git] / studio / src / extension_system / plugin_spec.h
blob4f231488e6a8339abfeafa277f9d6333019cb1ff
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010-2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef PLUGINSPEC_H
22 #define PLUGINSPEC_H
24 #include "iplugin_spec.h"
26 #include <QtCore/QList>
27 #include <QtCore/QStringList>
28 #include <QtCore/QXmlStreamReader>
30 class QPluginLoader;
32 namespace ExtensionSystem
35 class PluginSpec: public IPluginSpec
37 public:
38 ~PluginSpec();
39 virtual QString name() const;
40 virtual QString version() const;
41 virtual QString vendor() const;
42 virtual QString description() const;
44 virtual QString location() const;
45 virtual QString filePath() const;
46 virtual QString fileName() const;
48 virtual IPlugin *plugin() const;
50 // state
51 virtual int state() const;
52 virtual bool hasError() const;
53 virtual QString errorString() const;
54 QList<PluginSpec *> dependencySpecs() const;
56 /// Enables/disables load this plugin after restart the program
57 virtual void setEnabled(bool enabled);
58 virtual bool isEnabled() const;
60 private:
61 PluginSpec();
63 bool setFileName(const QString &fileName);
64 bool setSpecFileName(const QString &specFileName);
65 bool readSpec();
66 void parseSpec(QXmlStreamReader &reader);
67 void parseDependency(QXmlStreamReader &reader);
68 bool loadLibrary();
69 bool resolveDependencies(const QList<PluginSpec *> &specs);
70 bool initializePlugin();
71 bool initializeExtensions();
72 void stop();
73 void kill();
75 /// Enables/disables load this plugin on startup the program
76 /// Method is used for disabling startup plugin by pluginmanager
77 void setEnabledStartup(bool enabled);
78 bool isEnabledStartup() const;
80 bool reportError(const QString &err);
82 QString m_location;
83 QString m_filePath;
84 QString m_fileName;
86 QString m_name;
87 QString m_version;
88 QString m_vendor;
89 QString m_description;
91 QString m_nameSpecFile;
92 QString m_prefix;
93 QString m_suffix;
94 int m_state;
95 bool m_enabled, m_enabledStartup;
96 bool m_hasError;
97 QString m_errorString;
98 QStringList m_dependencies;
100 IPlugin *m_plugin;
101 IPluginManager *m_pluginManager;
102 QList<PluginSpec *> m_dependencySpecs;
104 QPluginLoader *loader;
106 friend class PluginManager;
109 } // namespace ExtensionSystem
111 #endif // PLUGINSPEC_H