MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SortPlugins

Function SortPlugins

Source/Engine/Scripting/Plugins/PluginManager.cpp:91–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90 template<typename PluginType = Plugin>
91 Array<PluginType*> SortPlugins(Array<PluginType*> plugins, MClass* pluginLoadOrderAttribute, MField* typeField)
92 {
93 // Sort plugins
94 Array<PluginType*> newPlugins;
95 for (int i = 0; i < plugins.Count(); i++)
96 {
97 PluginType* plugin = plugins[i];
98 int32 insertIndex = -1;
99 for (int j = 0; j < newPlugins.Count(); j++)
100 {
101 // Get first instance where a game plugin needs another one before it
102 auto attribute = newPlugins[j]->GetClass()->GetAttribute(pluginLoadOrderAttribute);
103 if (attribute == nullptr || MCore::Object::GetClass(attribute) != pluginLoadOrderAttribute)
104 continue;
105
106 // Check if attribute references a valid class
107 MTypeObject* refType = nullptr;
108 typeField->GetValue(attribute, &refType);
109 if (refType == nullptr)
110 continue;
111
112 MType* type = INTERNAL_TYPE_OBJECT_GET(refType);
113 if (type == nullptr)
114 continue;
115 MClass* typeClass = MCore::Type::GetClass(type);
116
117 if (plugin->GetClass() == typeClass)
118 {
119 insertIndex = j;
120 break;
121 }
122 }
123 if (insertIndex == -1)
124 newPlugins.Add(plugin);
125 else
126 newPlugins.Insert(insertIndex, plugin);
127 }
128 return newPlugins;
129 }
130}
131
132using namespace PluginManagerImpl;

Callers 5

OnAssemblyUnloadingMethod · 0.85
InitializePluginsMethod · 0.85
DeinitializePluginsMethod · 0.85
InitializeGamePluginsMethod · 0.85

Calls 7

GetClassFunction · 0.50
CountMethod · 0.45
GetAttributeMethod · 0.45
GetClassMethod · 0.45
GetValueMethod · 0.45
AddMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected