summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-28 05:12:31 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-29 16:41:37 +0200
commitdf2518b2a3451ad73ebddce056b68edb98ab0f7c (patch)
treeb39c42f7253e7bdc1d8e91ee384d6a6d94709b0d
parent1e2db0eee7b3752507de50788c974e40dcafaf1b (diff)
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>
-rw-r--r--include/libcamera/bound_method.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h
index e1524c91..06c5a3b1 100644
--- a/include/libcamera/bound_method.h
+++ b/include/libcamera/bound_method.h
@@ -24,8 +24,10 @@ enum ConnectionType {
class BoundMethodBase
{
public:
- BoundMethodBase(void *obj, Object *object)
- : obj_(obj), object_(object) {}
+ BoundMethodBase(void *obj, Object *object, ConnectionType type)
+ : obj_(obj), object_(object), connectionType_(type)
+ {
+ }
virtual ~BoundMethodBase() {}
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_; }
Object *object() const { return object_; }
+ ConnectionType connectionType() const { return connectionType_; }
void activatePack(void *pack);
virtual void invokePack(void *pack) = 0;
@@ -40,6 +43,7 @@ public:
protected:
void *obj_;
Object *object_;
+ ConnectionType connectionType_;
};
template<typename... Args>
@@ -76,8 +80,8 @@ private:
}
public:
- BoundMethodArgs(void *obj, Object *object)
- : BoundMethodBase(obj, object) {}
+ BoundMethodArgs(void *obj, Object *object, ConnectionType type)
+ : BoundMethodBase(obj, object, type) {}
void invokePack(void *pack) override
{
@@ -94,8 +98,11 @@ class BoundMemberMethod : public BoundMethodArgs<Args...>
public:
using PackType = std::tuple<typename std::remove_reference<Args>::type...>;
- BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...))
- : BoundMethodArgs<Args...>(obj, object), func_(func) {}
+ BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...),
+ ConnectionType type = ConnectionTypeAuto)
+ : BoundMethodArgs<Args...>(obj, object, type), func_(func)
+ {
+ }
bool match(void (T::*func)(Args...)) const { return func == func_; }
@@ -121,7 +128,10 @@ class BoundStaticMethod : public BoundMethodArgs<Args...>
{
public:
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_; }