Files
external_libcamera/src/libcamera/object.cpp
Laurent Pinchart 1ba441cae6 libcamera: Include header related to source file first
Include the header file corresponding to the source file in the very
first position. This complies with the Google C++ coding style
guideliens, and helps ensuring that the headers are self-contained.

Three bugs are already caught by this change (missing includes or
forward declarations) in device_enumerator.h, event_dispatcher_poll.h
and pipeline_handler.h. Fix them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-19 13:38:14 +03:00

52 lines
998 B
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* object.cpp - Base object
*/
#include <libcamera/object.h>
#include <libcamera/signal.h>
/**
* \file object.h
* \brief Base object to support automatic signal disconnection
*/
namespace libcamera {
/**
* \class Object
* \brief Base object to support automatic signal disconnection
*
* The Object class simplifies signal/slot handling for classes implementing
* slots. By inheriting from Object, an object is automatically disconnected
* from all connected signals when it gets destroyed.
*
* \sa Signal
*/
Object::~Object()
{
for (SignalBase *signal : signals_)
signal->disconnect(this);
}
void Object::connect(SignalBase *signal)
{
signals_.push_back(signal);
}
void Object::disconnect(SignalBase *signal)
{
for (auto iter = signals_.begin(); iter != signals_.end(); ) {
if (*iter == signal)
iter = signals_.erase(iter);
else
iter++;
}
}
}; /* namespace libcamera */