libcamera: bound_method: Store connection type in BoundMethodBase
Store the connection type in the base BoundMethodBase class to make it accessible to all bound methods. The default type is ConnectionTypeAuto. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
1e2db0eee7
commit
df2518b2a3
1 changed files with 17 additions and 7 deletions
|
@ -24,8 +24,10 @@ enum ConnectionType {
|
||||||
class BoundMethodBase
|
class BoundMethodBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoundMethodBase(void *obj, Object *object)
|
BoundMethodBase(void *obj, Object *object, ConnectionType type)
|
||||||
: obj_(obj), object_(object) {}
|
: obj_(obj), object_(object), connectionType_(type)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~BoundMethodBase() {}
|
virtual ~BoundMethodBase() {}
|
||||||
|
|
||||||
template<typename T, typename std::enable_if<!std::is_same<Object, T>::value>::type * = nullptr>
|
template<typename T, typename std::enable_if<!std::is_same<Object, T>::value>::type * = nullptr>
|
||||||
|
@ -33,6 +35,7 @@ public:
|
||||||
bool match(Object *object) { return object == object_; }
|
bool match(Object *object) { return object == object_; }
|
||||||
|
|
||||||
Object *object() const { return object_; }
|
Object *object() const { return object_; }
|
||||||
|
ConnectionType connectionType() const { return connectionType_; }
|
||||||
|
|
||||||
void activatePack(void *pack);
|
void activatePack(void *pack);
|
||||||
virtual void invokePack(void *pack) = 0;
|
virtual void invokePack(void *pack) = 0;
|
||||||
|
@ -40,6 +43,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void *obj_;
|
void *obj_;
|
||||||
Object *object_;
|
Object *object_;
|
||||||
|
ConnectionType connectionType_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
@ -76,8 +80,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoundMethodArgs(void *obj, Object *object)
|
BoundMethodArgs(void *obj, Object *object, ConnectionType type)
|
||||||
: BoundMethodBase(obj, object) {}
|
: BoundMethodBase(obj, object, type) {}
|
||||||
|
|
||||||
void invokePack(void *pack) override
|
void invokePack(void *pack) override
|
||||||
{
|
{
|
||||||
|
@ -94,8 +98,11 @@ class BoundMemberMethod : public BoundMethodArgs<Args...>
|
||||||
public:
|
public:
|
||||||
using PackType = std::tuple<typename std::remove_reference<Args>::type...>;
|
using PackType = std::tuple<typename std::remove_reference<Args>::type...>;
|
||||||
|
|
||||||
BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...))
|
BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...),
|
||||||
: BoundMethodArgs<Args...>(obj, object), func_(func) {}
|
ConnectionType type = ConnectionTypeAuto)
|
||||||
|
: BoundMethodArgs<Args...>(obj, object, type), func_(func)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool match(void (T::*func)(Args...)) const { return func == func_; }
|
bool match(void (T::*func)(Args...)) const { return func == func_; }
|
||||||
|
|
||||||
|
@ -121,7 +128,10 @@ class BoundStaticMethod : public BoundMethodArgs<Args...>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoundStaticMethod(void (*func)(Args...))
|
BoundStaticMethod(void (*func)(Args...))
|
||||||
: BoundMethodArgs<Args...>(nullptr, nullptr), func_(func) {}
|
: BoundMethodArgs<Args...>(nullptr, nullptr, ConnectionTypeAuto),
|
||||||
|
func_(func)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool match(void (*func)(Args...)) const { return func == func_; }
|
bool match(void (*func)(Args...)) const { return func == func_; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue