Editor API
UnigineEditor public API
PluginInfo.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/EditorGlobal.h>
6 
7 #include <UnigineString.h>
8 
9 #include <QPluginLoader>
10 
11 
13 // Forward decl.
15 namespace Editor
16 {
17 class Plugin;
18 class PluginManager;
19 class PluginInfoPrivate;
20 }
21 
22 
23 namespace Editor
24 {
25 
27 struct EDITOR_API PluginDependency
28 {
30  enum class Type
31  {
33  REQUIRED,
35  OPTION
36  };
37 
38  Type type = Type::REQUIRED;
40  Unigine::String name;
42  Unigine::String version;
43 };
44 
48 class EDITOR_API PluginInfo
49 {
50 public:
52  enum class State
53  {
55  INVALID,
57  READ,
59  RESOLVED,
61  LOADED,
63  RUNNING,
65  STOPPED,
67  UNLOADED
68  };
69 
70  PluginInfo();
71  ~PluginInfo();
72 
74  const char *name() const;
76  const char *version() const;
78  const char *vendor() const;
80  const char *description() const;
82  const char *compatibleVersion() const;
84  Unigine::Vector<PluginDependency> dependencies() const;
85 
87  const char *absoluteFilePath() const;
88 
92  bool hasError() const;
94  const char *errorString() const;
95 
98  State state() const;
99 
103  bool isInstanceOf(const char *name, const char *version) const;
104 
106  Plugin *plugin() const;
107 
108 private:
109  PluginInfoPrivate *d;
110 
111  friend class PluginManagerPrivate;
112 };
113 
114 
115 } // namespace Editor
116 
117 Q_DECLARE_METATYPE(::Editor::PluginInfo *);
118 
119 namespace Unigine
120 {
121 
122 template<typename Type>
123 struct Hasher;
124 
125 template<>
127 {
128  using HashType = unsigned int;
129  UNIGINE_INLINE static HashType create(const ::Editor::PluginDependency &v)
130  {
131  return ::Unigine::Hasher<::Unigine::String>::create(v.name);
132  }
133 };
134 
135 } // namespace Unigine
136 
State
Current plugin state.
Definition: PluginInfo.h:52
Definition: Actions.h:11
Unigine::String version
Plugin version.
Definition: PluginInfo.h:42
Definition: Constants.h:69
Unigine::String name
Plugin name.
Definition: PluginInfo.h:40
This class it is responsible for plugin loading/unloading and contains all necessary plugin metadata ...
Definition: PluginInfo.h:48
Defines dependency on a plugin.
Definition: PluginInfo.h:27
static UNIGINE_INLINE HashType create(const ::Editor::PluginDependency &v)
Definition: PluginInfo.h:129
unsigned int HashType
Definition: PluginInfo.h:128
This class is used for plugin interface implementation when creating Editor plugins....
Definition: Plugin.h:17
Type
Plugin type. Defines whether the plugin is a required or an optional one.
Definition: PluginInfo.h:30
Definition: Constants.h:73