/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <ox/fs/fs.hpp>
#include <ox/model/desctypes.hpp>

#include <keel/context.hpp>

namespace turbine {

class Context;

void safeDelete(Context *p);

keel::Context const &keelCtx(Context const &ctx) noexcept;

keel::Context &keelCtx(Context &ctx) noexcept;

inline ox::FileSystem const*rom(Context const &ctx) noexcept {
	return keelCtx(ctx).rom.get();
}

inline ox::FileSystem *rom(Context &ctx) noexcept {
	return keelCtx(ctx).rom.get();
}

void setApplicationDataRaw(Context &ctx, ox::AnyPtr const &applicationData) noexcept;

template<typename T>
void setApplicationData(Context &ctx, T *applicationData) noexcept {
	setApplicationDataRaw(ctx, applicationData);
}

[[nodiscard]]
ox::AnyPtr const &applicationDataRaw(Context &ctx) noexcept;

template<typename T>
[[nodiscard]]
T *applicationData(Context &ctx) noexcept {
	return applicationDataRaw(ctx).get<T>();
}

}

