2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-06-06 12:33:27 +00:00
metaforce/Runtime/IVParamObj.hpp
Lioncash 2059535b55 RuntimeCommonB: Use the override specifier where applicable
Applies the override keyword where applicable to indicate visually where
member function overriding is occurring. This only targets
the RuntimeCommonB target as a starting point, which resolves around
900+ cases where the keyword could be used.
2019-08-09 09:13:26 -04:00

41 lines
886 B
C++

#pragma once
#include <memory>
#include "IObj.hpp"
namespace urde {
class IVParamObj : public IObj {
public:
~IVParamObj() override = default;
};
template <class T>
class TObjOwnerParam : public IVParamObj {
T m_param;
public:
TObjOwnerParam(T&& obj) : m_param(std::move(obj)) {}
T& GetParam() { return m_param; }
};
class CVParamTransfer {
std::shared_ptr<IVParamObj> m_ref;
public:
CVParamTransfer() = default;
CVParamTransfer(IVParamObj* obj) : m_ref(obj) {}
CVParamTransfer(const CVParamTransfer& other) : m_ref(other.m_ref) {}
IVParamObj* GetObj() const { return m_ref.get(); }
CVParamTransfer ShareTransferRef() { return CVParamTransfer(*this); }
template <class T>
T& GetOwnedObj() const {
return static_cast<TObjOwnerParam<T>*>(GetObj())->GetParam();
}
static CVParamTransfer Null() { return CVParamTransfer(); }
};
} // namespace urde