mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-05 12:35:06 +01:00
Add PluginDataPersistence
This commit is contained in:
parent
3b9f4a9a51
commit
db9b113eab
@ -4,19 +4,18 @@
|
|||||||
#include "PluginInformationFactory.h"
|
#include "PluginInformationFactory.h"
|
||||||
#include "PluginMetaInformationFactory.h"
|
#include "PluginMetaInformationFactory.h"
|
||||||
#include "PluginContainerPersistence.h"
|
#include "PluginContainerPersistence.h"
|
||||||
|
#include "PluginDataPersistence.h"
|
||||||
#include "DynamicLinkingHelper.h"
|
#include "DynamicLinkingHelper.h"
|
||||||
#include "common/plugin_defines.h"
|
#include "common/plugin_defines.h"
|
||||||
#include "PluginInformation.h"
|
#include "PluginInformation.h"
|
||||||
#include "RelocationData.h"
|
#include "RelocationData.h"
|
||||||
|
|
||||||
bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformation, PluginContainer &plugin) {
|
bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformation, PluginContainer &plugin) {
|
||||||
|
|
||||||
int32_t plugin_count = pluginInformation->number_used_plugins;
|
int32_t plugin_count = pluginInformation->number_used_plugins;
|
||||||
|
|
||||||
auto pluginName = plugin.getMetaInformation().getName();
|
auto pluginName = plugin.getMetaInformation().getName();
|
||||||
//auto pluginPath = plugin.getMetaInformation().getPath();
|
//auto pluginPath = plugin.getMetaInformation().getPath();
|
||||||
|
|
||||||
|
|
||||||
if (plugin_count >= MAXIMUM_PLUGINS - 1) {
|
if (plugin_count >= MAXIMUM_PLUGINS - 1) {
|
||||||
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!\n", MAXIMUM_PLUGINS, pluginName.c_str());
|
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!\n", MAXIMUM_PLUGINS, pluginName.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -167,10 +166,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
|||||||
auto pluginData = plugin.getPluginData();
|
auto pluginData = plugin.getPluginData();
|
||||||
auto plugin_data_data = &plugin_data->data;
|
auto plugin_data_data = &plugin_data->data;
|
||||||
|
|
||||||
plugin_data_data->buffer = (char *) pluginData.buffer;
|
PluginDataPersistence::save(plugin_data_data, pluginData);
|
||||||
plugin_data_data->bufferLength = pluginData.length;
|
|
||||||
plugin_data_data->memoryType = pluginData.memoryType;
|
|
||||||
plugin_data_data->heapHandle = (int) pluginData.heapHandle;
|
|
||||||
|
|
||||||
pluginInformation->number_used_plugins++;
|
pluginInformation->number_used_plugins++;
|
||||||
|
|
||||||
@ -209,15 +205,9 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
|
|||||||
metaInformation.setSize(meta->size);
|
metaInformation.setSize(meta->size);
|
||||||
metaInformation.setName(meta->name);
|
metaInformation.setName(meta->name);
|
||||||
|
|
||||||
PluginData pluginData;
|
|
||||||
|
|
||||||
plugin_data_t *data = &(plugin_data->data);
|
plugin_data_t *data = &(plugin_data->data);
|
||||||
|
|
||||||
pluginData.buffer = data->buffer;
|
PluginData pluginData = PluginDataPersistence::load(data);
|
||||||
pluginData.length = data->bufferLength;
|
|
||||||
pluginData.memoryType = (eMemoryTypes) data->memoryType;
|
|
||||||
pluginData.heapHandle = (MEMHeapHandle) data->heapHandle;
|
|
||||||
pluginData.loadReader();
|
|
||||||
|
|
||||||
PluginInformation pluginInformation;
|
PluginInformation pluginInformation;
|
||||||
|
|
||||||
|
@ -8,4 +8,6 @@ public:
|
|||||||
static bool savePlugin(plugin_information_t *pluginInformation, PluginContainer &plugin);
|
static bool savePlugin(plugin_information_t *pluginInformation, PluginContainer &plugin);
|
||||||
|
|
||||||
static std::vector<PluginContainer> loadPlugins(plugin_information_t *pluginInformation);
|
static std::vector<PluginContainer> loadPlugins(plugin_information_t *pluginInformation);
|
||||||
|
|
||||||
|
static bool savePluginData(plugin_data_t *pluginDataStruct, PluginData &plugin);
|
||||||
};
|
};
|
||||||
|
@ -73,5 +73,5 @@ private:
|
|||||||
|
|
||||||
friend class PluginContainer;
|
friend class PluginContainer;
|
||||||
|
|
||||||
friend class PluginContainerPersistence;
|
friend class PluginDataPersistence;
|
||||||
};
|
};
|
||||||
|
25
source/plugin/PluginDataPersistence.cpp
Normal file
25
source/plugin/PluginDataPersistence.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <common/plugin_defines.h>
|
||||||
|
#include "PluginDataPersistence.h"
|
||||||
|
#include "PluginData.h"
|
||||||
|
|
||||||
|
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData &plugin) {
|
||||||
|
if(pluginDataStruct == NULL){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pluginDataStruct->buffer = (char *) plugin.buffer;
|
||||||
|
pluginDataStruct->bufferLength = plugin.length;
|
||||||
|
pluginDataStruct->memoryType = plugin.memoryType;
|
||||||
|
pluginDataStruct->heapHandle = (int) plugin.heapHandle;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginData PluginDataPersistence::load(plugin_data_t *pluginDataStruct) {
|
||||||
|
PluginData pluginData;
|
||||||
|
|
||||||
|
pluginData.buffer = pluginDataStruct->buffer;
|
||||||
|
pluginData.length = pluginDataStruct->bufferLength;
|
||||||
|
pluginData.memoryType = (eMemoryTypes) pluginDataStruct->memoryType;
|
||||||
|
pluginData.heapHandle = (MEMHeapHandle) pluginDataStruct->heapHandle;
|
||||||
|
pluginData.loadReader();
|
||||||
|
return pluginData;
|
||||||
|
}
|
11
source/plugin/PluginDataPersistence.h
Normal file
11
source/plugin/PluginDataPersistence.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "PluginData.h"
|
||||||
|
|
||||||
|
class PluginDataPersistence {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static bool save(plugin_data_t *pluginDataStruct, PluginData &plugin);
|
||||||
|
|
||||||
|
static PluginData load(plugin_data_t *pluginDataStruct);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user