mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Implement an object backed IStorage backing
This is more convinient and efficient to use when passing structured data out of applets
This commit is contained in:
parent
d115ce3c05
commit
df5d1256c2
27
app/src/main/cpp/skyline/services/am/storage/ObjIStorage.h
Normal file
27
app/src/main/cpp/skyline/services/am/storage/ObjIStorage.h
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <services/serviceman.h>
|
||||
#include "IStorage.h"
|
||||
|
||||
namespace skyline::service::am {
|
||||
/**
|
||||
* @brief ObjIStorage is an IStorage backed by a trivially copyable object
|
||||
*/
|
||||
template<typename T> requires std::is_trivially_copyable_v<T>
|
||||
class ObjIStorage : public IStorage {
|
||||
private:
|
||||
T obj;
|
||||
|
||||
public:
|
||||
ObjIStorage(const DeviceState &state, ServiceManager &manager, T &&obj) : IStorage(state, manager, true), obj(obj) {}
|
||||
|
||||
~ObjIStorage() override = default;
|
||||
|
||||
span<u8> GetSpan() override {
|
||||
return {reinterpret_cast<u8 *>(&obj), sizeof(T)};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user