2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-08-22 01:58:41 +00:00
|
|
|
|
2015-08-22 02:59:57 +00:00
|
|
|
#include <memory>
|
2019-09-23 19:00:23 +00:00
|
|
|
#include "Runtime/IObj.hpp"
|
2015-08-22 01:58:41 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2015-08-22 01:58:41 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class IVParamObj : public IObj {
|
2015-08-22 01:58:41 +00:00
|
|
|
public:
|
2019-08-09 12:45:18 +00:00
|
|
|
~IVParamObj() override = default;
|
2015-08-22 01:58:41 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
template <class T>
|
|
|
|
class TObjOwnerParam : public IVParamObj {
|
|
|
|
T m_param;
|
2016-12-23 06:41:39 +00:00
|
|
|
|
2015-08-22 01:58:41 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
TObjOwnerParam(T&& obj) : m_param(std::move(obj)) {}
|
2019-09-30 06:52:52 +00:00
|
|
|
T& GetParam() noexcept { return m_param; }
|
|
|
|
const T& GetParam() const noexcept { return m_param; }
|
2018-12-08 05:30:43 +00:00
|
|
|
};
|
2015-08-26 01:34:56 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CVParamTransfer {
|
|
|
|
std::shared_ptr<IVParamObj> m_ref;
|
2015-08-22 01:58:41 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
2019-09-30 06:54:23 +00:00
|
|
|
constexpr CVParamTransfer() noexcept = default;
|
2018-12-08 05:30:43 +00:00
|
|
|
CVParamTransfer(IVParamObj* obj) : m_ref(obj) {}
|
2019-09-30 06:46:31 +00:00
|
|
|
|
|
|
|
CVParamTransfer(const CVParamTransfer& other) noexcept = default;
|
|
|
|
CVParamTransfer& operator=(const CVParamTransfer&) noexcept = default;
|
|
|
|
|
|
|
|
CVParamTransfer(CVParamTransfer&&) noexcept = default;
|
|
|
|
CVParamTransfer& operator=(CVParamTransfer&&) noexcept = default;
|
|
|
|
|
2019-09-30 06:52:52 +00:00
|
|
|
IVParamObj* GetObj() const noexcept { return m_ref.get(); }
|
|
|
|
CVParamTransfer ShareTransferRef() const noexcept { return CVParamTransfer(*this); }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
template <class T>
|
2019-09-30 06:52:52 +00:00
|
|
|
T& GetOwnedObj() const noexcept {
|
2018-12-08 05:30:43 +00:00
|
|
|
return static_cast<TObjOwnerParam<T>*>(GetObj())->GetParam();
|
|
|
|
}
|
|
|
|
|
2019-09-30 06:52:52 +00:00
|
|
|
static CVParamTransfer Null() noexcept { return CVParamTransfer(); }
|
2015-08-22 01:58:41 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|