libcamera: object: Create parent-child relationships
Add a parent Object to Object instances, and track the parent-children relationships. Children are bound to the same thread as their parent, and moving an Object to a thread automatically moves all its children. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <libcamera/bound_method.h>
|
||||
|
||||
@@ -23,7 +24,7 @@ class Thread;
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
Object(Object *parent = nullptr);
|
||||
virtual ~Object();
|
||||
|
||||
void postMessage(std::unique_ptr<Message> msg);
|
||||
@@ -41,6 +42,8 @@ public:
|
||||
Thread *thread() const { return thread_; }
|
||||
void moveToThread(Thread *thread);
|
||||
|
||||
Object *parent() const { return parent_; }
|
||||
|
||||
protected:
|
||||
virtual void message(Message *msg);
|
||||
|
||||
@@ -57,6 +60,9 @@ private:
|
||||
void connect(SignalBase *signal);
|
||||
void disconnect(SignalBase *signal);
|
||||
|
||||
Object *parent_;
|
||||
std::vector<Object *> children_;
|
||||
|
||||
Thread *thread_;
|
||||
std::list<SignalBase *> signals_;
|
||||
unsigned int pendingMessages_;
|
||||
|
||||
Reference in New Issue
Block a user