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>
|
2015-08-22 01:58:41 +00:00
|
|
|
#include "IObj.hpp"
|
|
|
|
|
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)) {}
|
|
|
|
T& GetParam() { return m_param; }
|
2019-08-14 10:04:11 +00:00
|
|
|
const T& GetParam() const { 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:
|
|
|
|
CVParamTransfer() = default;
|
|
|
|
CVParamTransfer(IVParamObj* obj) : m_ref(obj) {}
|
|
|
|
CVParamTransfer(const CVParamTransfer& other) : m_ref(other.m_ref) {}
|
|
|
|
IVParamObj* GetObj() const { return m_ref.get(); }
|
2019-08-14 10:04:11 +00:00
|
|
|
CVParamTransfer ShareTransferRef() const { return CVParamTransfer(*this); }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
T& GetOwnedObj() const {
|
|
|
|
return static_cast<TObjOwnerParam<T>*>(GetObj())->GetParam();
|
|
|
|
}
|
|
|
|
|
|
|
|
static CVParamTransfer Null() { return CVParamTransfer(); }
|
2015-08-22 01:58:41 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|