libcamera/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
Laurent Pinchart 829acb3ab0 libcamera: Drop file name from header comment blocks in templates
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment blocks in
template files and templates embedded in generator scripts.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-09 23:31:14 +03:00

132 lines
3.3 KiB
Cheetah

{#-
# SPDX-License-Identifier: LGPL-2.1-or-later
# Copyright (C) 2020, Google Inc.
-#}
{%- import "proxy_functions.tmpl" as proxy_funcs -%}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Google Inc.
*
* Image Processing Algorithm proxy for {{module_name}}
*
* This file is auto-generated. Do not edit.
*/
#pragma once
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/{{module_name}}_ipa_interface.h>
#include <libcamera/base/object.h>
#include <libcamera/base/thread.h>
#include "libcamera/internal/control_serializer.h"
#include "libcamera/internal/ipa_proxy.h"
#include "libcamera/internal/ipc_pipe.h"
#include "libcamera/internal/ipc_pipe_unixsocket.h"
#include "libcamera/internal/ipc_unixsocket.h"
namespace libcamera {
{%- if has_namespace %}
{% for ns in namespace %}
namespace {{ns}} {
{% endfor %}
{%- endif %}
class {{proxy_name}} : public IPAProxy, public {{interface_name}}, public Object
{
public:
{{proxy_name}}(IPAModule *ipam, bool isolate);
~{{proxy_name}}();
{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "", false, true)|indent(8, true)}};
{% endfor %}
{%- for method in interface_event.methods %}
Signal<
{%- for param in method.parameters -%}
{{"const " if not param|is_pod}}{{param|name}}{{" &" if not param|is_pod and not param|is_enum}}
{{- ", " if not loop.last}}
{%- endfor -%}
> {{method.mojom_name}};
{% endfor %}
private:
void recvMessage(const IPCMessage &data);
{% for method in interface_main.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "Thread", false)|indent(8, true)}};
{{proxy_funcs.func_sig(proxy_name, method, "IPC", false)|indent(8, true)}};
{% endfor %}
{% for method in interface_event.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "Thread", false)|indent(8, true)}};
void {{method.mojom_name}}IPC(
std::vector<uint8_t>::const_iterator data,
size_t dataSize,
const std::vector<SharedFD> &fds);
{% endfor %}
/* Helper class to invoke async functions in another thread. */
class ThreadProxy : public Object
{
public:
ThreadProxy()
: ipa_(nullptr)
{
}
void setIPA({{interface_name}} *ipa)
{
ipa_ = ipa;
}
void stop()
{
ipa_->stop();
}
{% for method in interface_main.methods %}
{%- if method|is_async %}
{{proxy_funcs.func_sig(proxy_name, method, "", false)|indent(16)}}
{
ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}});
}
{%- elif method.mojom_name == "start" %}
{{proxy_funcs.func_sig(proxy_name, method, "", false)|indent(16)}}
{
{%- if method|method_return_value != "void" %}
return ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}});
{%- else %}
ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}}
{{- ", " if method|method_param_outputs|params_comma_sep -}}
{{- method|method_param_outputs|params_comma_sep}});
{%- endif %}
}
{%- endif %}
{%- endfor %}
private:
{{interface_name}} *ipa_;
};
Thread thread_;
ThreadProxy proxy_;
std::unique_ptr<{{interface_name}}> ipa_;
const bool isolate_;
std::unique_ptr<IPCPipeUnixSocket> ipc_;
ControlSerializer controlSerializer_;
{# \todo Move this to IPCPipe #}
uint32_t seq_;
};
{%- if has_namespace %}
{% for ns in namespace|reverse %}
} /* namespace {{ns}} */
{% endfor %}
{%- endif %}
} /* namespace libcamera */