summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-11 00:39:54 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-13 20:37:21 +0300
commit4ebc7297e1994b05f0ac00a0ac0d91ef94bf00a8 (patch)
tree60a337b2e8089ae0e17a288cfd346d05811b00f1 /include/linux
parentf3c53dbf53b60defc61948cdfb64f79e6983e071 (diff)
libcamera: pipeline: rkisp1: Avoid copy assignment of V4L2 control map
Use the std::map::emplace() method to avoid unnecessary creation of an empty V4L2ControlInfoMap folled by a copy assignment. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions
/a> 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * object.h - Base object
 */
#ifndef __LIBCAMERA_BASE_OBJECT_H__
#define __LIBCAMERA_BASE_OBJECT_H__

#include <list>
#include <memory>
#include <vector>

#include <libcamera/base/bound_method.h>

namespace libcamera {

class Message;
template<typename... Args>
class Signal;
class SignalBase;
class Thread;

class Object
{
public:
	Object(Object *parent = nullptr);
	virtual ~Object();

	void deleteLater();

	void postMessage(std::unique_ptr<Message> msg);

	template<typename T, typename R, typename... FuncArgs, typename... Args,
		 typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
	R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type,
		       Args... args)
	{
		T *obj = static_cast<T *>(this);
		auto *method = new BoundMethodMember<T, R, FuncArgs...>(obj, this, func, type);
		return method->activate(args..., true);
	}

	Thread *thread() const { return thread_; }
	void moveToThread(Thread *thread);

	Object *parent() const { return parent_; }

protected:
	virtual void message(Message *msg);

private:
	friend class SignalBase;
	friend class Thread;

	void notifyThreadMove();

	void connect(SignalBase *signal);
	void disconnect(SignalBase *signal);

	Object *parent_;
	std::vector<Object *> children_;

	Thread *thread_;
	std::list<SignalBase *> signals_;
	unsigned int pendingMessages_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_BASE_OBJECT_H__ */