mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-23 16:45:07 +03:00
libcamera: base: bound_method: Remove BoundMethodMember specialization
The BoundMethodMember specialization for the void return type is only needed to avoid accessing the ret_ member variable that is lacking from the corresponding BoundMethodPack specialization. By adding a BoundMethodPack::returnValue() function to read the member variable, we can remove the complete BoundMethodMember specialization. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
parent
eb5c4ead88
commit
d1315600b8
1 changed files with 10 additions and 36 deletions
|
@ -38,6 +38,11 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
R returnValue()
|
||||||
|
{
|
||||||
|
return ret_;
|
||||||
|
}
|
||||||
|
|
||||||
std::tuple<typename std::remove_reference_t<Args>...> args_;
|
std::tuple<typename std::remove_reference_t<Args>...> args_;
|
||||||
R ret_;
|
R ret_;
|
||||||
};
|
};
|
||||||
|
@ -51,6 +56,10 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void returnValue()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::tuple<typename std::remove_reference_t<Args>...> args_;
|
std::tuple<typename std::remove_reference_t<Args>...> args_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -160,7 +169,7 @@ public:
|
||||||
|
|
||||||
auto pack = std::make_shared<PackType>(args...);
|
auto pack = std::make_shared<PackType>(args...);
|
||||||
bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
|
bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
|
||||||
return sync ? pack->ret_ : R();
|
return sync ? pack->returnValue() : R();
|
||||||
}
|
}
|
||||||
|
|
||||||
R invoke(Args... args) override
|
R invoke(Args... args) override
|
||||||
|
@ -173,41 +182,6 @@ private:
|
||||||
R (T::*func_)(Args...);
|
R (T::*func_)(Args...);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
class BoundMethodMember<T, void, Args...> : public BoundMethodArgs<void, Args...>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using PackType = typename BoundMethodArgs<void, Args...>::PackType;
|
|
||||||
|
|
||||||
BoundMethodMember(T *obj, Object *object, void (T::*func)(Args...),
|
|
||||||
ConnectionType type = ConnectionTypeAuto)
|
|
||||||
: BoundMethodArgs<void, Args...>(obj, object, type), func_(func)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool match(void (T::*func)(Args...)) const { return func == func_; }
|
|
||||||
|
|
||||||
void activate(Args... args, bool deleteMethod = false) override
|
|
||||||
{
|
|
||||||
if (!this->object_) {
|
|
||||||
T *obj = static_cast<T *>(this->obj_);
|
|
||||||
return (obj->*func_)(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pack = std::make_shared<PackType>(args...);
|
|
||||||
BoundMethodBase::activatePack(pack, deleteMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
void invoke(Args... args) override
|
|
||||||
{
|
|
||||||
T *obj = static_cast<T *>(this->obj_);
|
|
||||||
return (obj->*func_)(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void (T::*func_)(Args...);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename... Args>
|
template<typename R, typename... Args>
|
||||||
class BoundMethodStatic : public BoundMethodArgs<R, Args...>
|
class BoundMethodStatic : public BoundMethodArgs<R, Args...>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue