Move everything into the WUPSBackend namespace

This commit is contained in:
Maschell 2023-02-17 12:03:27 +01:00
parent c8acaac6a7
commit 2da2336082
7 changed files with 116 additions and 103 deletions

View File

@ -24,21 +24,23 @@
#include "PluginData.h"
#include "PluginMetaInformation.h"
class PluginContainer {
namespace WUPSBackend {
class PluginContainer {
public:
PluginContainer(std::shared_ptr<PluginData> data, std::shared_ptr<PluginMetaInformation> metaInfo) : pluginData(std::move(data)),
metaInformation(std::move(metaInfo)) {
}
public:
PluginContainer(std::shared_ptr<PluginData> data, std::shared_ptr<PluginMetaInformation> metaInfo) : pluginData(std::move(data)),
metaInformation(std::move(metaInfo)) {
}
[[nodiscard]] const std::shared_ptr<PluginMetaInformation> &getMetaInformation() const {
return this->metaInformation;
}
[[nodiscard]] const std::shared_ptr<PluginMetaInformation> &getMetaInformation() const {
return this->metaInformation;
}
[[nodiscard]] const std::shared_ptr<PluginData> &getPluginData() const {
return pluginData;
}
[[nodiscard]] const std::shared_ptr<PluginData> &getPluginData() const {
return pluginData;
}
const std::shared_ptr<PluginData> pluginData;
const std::shared_ptr<PluginMetaInformation> metaInformation;
};
const std::shared_ptr<PluginData> pluginData;
const std::shared_ptr<PluginMetaInformation> metaInformation;
};
} // namespace WUPSBackend

View File

@ -19,15 +19,17 @@
#include <cstdint>
#include <wups_backend/import_defines.h>
class PluginData {
namespace WUPSBackend {
class PluginData {
public:
explicit PluginData(uint32_t handle);
~PluginData();
public:
explicit PluginData(uint32_t handle);
~PluginData();
[[nodiscard]] uint32_t getHandle() const {
return handle;
}
[[nodiscard]] uint32_t getHandle() const {
return handle;
}
uint32_t handle;
};
uint32_t handle;
};
} // namespace WUPSBackend

View File

@ -21,90 +21,92 @@
#include <string>
#include <vector>
class PluginMetaInformation {
public:
[[nodiscard]] const std::string &getName() const {
return name;
}
namespace WUPSBackend {
class PluginMetaInformation {
public:
[[nodiscard]] const std::string &getName() const {
return name;
}
[[nodiscard]] const std::string &getAuthor() const {
return this->author;
}
[[nodiscard]] const std::string &getAuthor() const {
return this->author;
}
[[nodiscard]] const std::string &getVersion() const {
return this->version;
}
[[nodiscard]] const std::string &getVersion() const {
return this->version;
}
[[nodiscard]] const std::string &getLicense() const {
return this->license;
}
[[nodiscard]] const std::string &getLicense() const {
return this->license;
}
[[nodiscard]] const std::string &getBuildTimestamp() const {
return this->buildtimestamp;
}
[[nodiscard]] const std::string &getBuildTimestamp() const {
return this->buildtimestamp;
}
[[nodiscard]] const std::string &getDescription() const {
return this->description;
}
[[nodiscard]] const std::string &getDescription() const {
return this->description;
}
[[nodiscard]] const std::string &getStorageId() const {
return this->storageId;
}
[[nodiscard]] const std::string &getStorageId() const {
return this->storageId;
}
[[nodiscard]] size_t getSize() const {
return this->size;
}
[[nodiscard]] size_t getSize() const {
return this->size;
}
PluginMetaInformation(std::string name,
std::string author,
std::string version,
std::string license,
std::string buildtimestamp,
std::string description,
std::string storageId,
size_t size);
PluginMetaInformation(std::string name,
std::string author,
std::string version,
std::string license,
std::string buildtimestamp,
std::string description,
std::string storageId,
size_t size);
private:
PluginMetaInformation() = default;
private:
PluginMetaInformation() = default;
void setName(std::string name_) {
this->name = std::move(name_);
}
void setName(std::string name_) {
this->name = std::move(name_);
}
void setAuthor(std::string author_) {
this->author = std::move(author_);
}
void setAuthor(std::string author_) {
this->author = std::move(author_);
}
void setVersion(std::string version_) {
this->version = std::move(version_);
}
void setVersion(std::string version_) {
this->version = std::move(version_);
}
void setLicense(std::string license_) {
this->license = std::move(license_);
}
void setLicense(std::string license_) {
this->license = std::move(license_);
}
void setBuildTimestamp(std::string buildtimestamp_) {
this->buildtimestamp = std::move(buildtimestamp_);
}
void setBuildTimestamp(std::string buildtimestamp_) {
this->buildtimestamp = std::move(buildtimestamp_);
}
void setDescription(std::string description_) {
this->description = std::move(description_);
}
void setDescription(std::string description_) {
this->description = std::move(description_);
}
void setStorageId(std::string storageId_) {
this->storageId = std::move(storageId_);
}
void setStorageId(std::string storageId_) {
this->storageId = std::move(storageId_);
}
void setSize(size_t size_) {
this->size = size_;
}
void setSize(size_t size_) {
this->size = size_;
}
std::string name;
std::string author;
std::string version;
std::string license;
std::string buildtimestamp;
std::string description;
std::string storageId;
size_t size{};
};
std::string name;
std::string author;
std::string version;
std::string license;
std::string buildtimestamp;
std::string description;
std::string storageId;
size_t size{};
};
} // namespace WUPSBackend

View File

@ -20,17 +20,19 @@
#include "PluginMetaInformation.h"
#include <optional>
class PluginUtils {
public:
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForBuffer(char *buffer, size_t size);
namespace WUPSBackend {
class PluginUtils {
public:
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForBuffer(char *buffer, size_t size);
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForPath(const std::string &path);
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForPath(const std::string &path);
static std::vector<std::unique_ptr<PluginContainer>> getLoadedPlugins(uint32_t maxSize);
static std::vector<std::unique_ptr<PluginContainer>> getLoadedPlugins(uint32_t maxSize);
static std::optional<std::unique_ptr<PluginContainer>> getPluginForPath(const std::string &path);
static std::optional<std::unique_ptr<PluginContainer>> getPluginForPath(const std::string &path);
static std::optional<std::unique_ptr<PluginContainer>> getPluginForBuffer(char *buffer, size_t size);
static std::optional<std::unique_ptr<PluginContainer>> getPluginForBuffer(char *buffer, size_t size);
static int32_t LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
};
static int32_t LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
};
} // namespace WUPSBackend

View File

@ -20,6 +20,8 @@
#include "logger.h"
#include <coreinit/debug.h>
using namespace WUPSBackend;
PluginData::PluginData(uint32_t handle) {
this->handle = handle;
}
@ -30,4 +32,4 @@ PluginData::~PluginData() {
DEBUG_FUNCTION_LINE_ERR("Failed to delete plugin data");
}
}
}
}

View File

@ -18,9 +18,10 @@
#include "wups_backend/PluginMetaInformation.h"
#include <cstring>
#include <optional>
#include <utility>
using namespace WUPSBackend;
PluginMetaInformation::PluginMetaInformation(std::string name,
std::string author,
std::string version,

View File

@ -22,6 +22,8 @@
#include <cstring>
#include <memory>
using namespace WUPSBackend;
std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformation(const plugin_information &info) {
if (info.plugin_information_version != PLUGIN_INFORMATION_VERSION) {
DEBUG_FUNCTION_LINE_ERR("Version mismatch");