2018-10-06 20:42:33 -07:00
|
|
|
#pragma once
|
2015-08-21 18:58:41 -07:00
|
|
|
|
2015-08-21 19:59:57 -07:00
|
|
|
#include <memory>
|
2015-08-21 18:58:41 -07:00
|
|
|
#include "IObj.hpp"
|
|
|
|
|
2016-03-04 15:04:53 -08:00
|
|
|
namespace urde
|
2015-08-21 18:58:41 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
class IVParamObj : public IObj
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IVParamObj() {}
|
|
|
|
};
|
|
|
|
|
2016-12-22 22:41:39 -08:00
|
|
|
template<class T>
|
|
|
|
class TObjOwnerParam : public IVParamObj
|
|
|
|
{
|
|
|
|
T m_param;
|
|
|
|
public:
|
|
|
|
TObjOwnerParam(T&& obj) : m_param(std::move(obj)) {}
|
|
|
|
T& GetParam() {return m_param;}
|
|
|
|
};
|
|
|
|
|
2015-08-21 18:58:41 -07:00
|
|
|
class CVParamTransfer
|
|
|
|
{
|
2016-02-04 17:27:03 -08:00
|
|
|
std::shared_ptr<IVParamObj> m_ref;
|
2015-08-21 18:58:41 -07:00
|
|
|
public:
|
2016-02-15 21:50:41 -08:00
|
|
|
CVParamTransfer() = default;
|
2015-08-25 18:34:56 -07:00
|
|
|
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);}
|
|
|
|
|
2016-12-22 22:41:39 -08:00
|
|
|
template <class T>
|
|
|
|
T& GetOwnedObj() const {return static_cast<TObjOwnerParam<T>*>(GetObj())->GetParam();}
|
2015-08-21 18:58:41 -07:00
|
|
|
|
2016-12-22 22:41:39 -08:00
|
|
|
static CVParamTransfer Null() {return CVParamTransfer();}
|
2015-08-21 18:58:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|