/*
* This file was automatically generated using Avlos.
* https://github.com/tinymovr/avlos
*
* Any changes to this file will be overwritten when
* content is regenerated.
*/

#pragma once

#include <cstdint>
#include <{{ helper_file | file_from_path }}>
{%- for include in includes %}
#include <{{ include }}>
{%- endfor %}

{%- if instance.remote_attributes %}
    {%- for attr in instance.remote_attributes.values() %}
        {%- if attr.remote_attributes %}
#include <{{attr.name}}.hpp>
        {%- endif %}
    {%- endfor %}
{%- endif %}

{%- for ep in instance | bitmask_eps %}

enum {{ ep.full_name | replace(".", "_") }}_flags
{
    {%- set comma = joiner(", ") %}
    {{ ep.full_name | replace(".", "_") | upper }}_NONE = 0,
    {%- for flag in ep.bitmask %}{{ comma() }}
    {{ ep.full_name | replace(".", "_") | upper }}_{{ flag.name }} = (1 << {{ loop.index0 }})
    {%- endfor %}
};
{%- endfor %}

class Device : Node
{
    public:

        Device(uint8_t _can_node_id, send_callback _send_cb, recv_callback _recv_cb):
            Node(_can_node_id, _send_cb, _recv_cb) 
{%- if instance.remote_attributes %}
    {%- for attr in instance.remote_attributes.values() %}
        {%- if attr.remote_attributes %}
            , {{attr.name}}(_can_node_id, _send_cb, _recv_cb)
        {%- endif %}
    {%- endfor %}
{%- endif %} {};

    {%- if instance.remote_attributes %}
        {%- for attr in instance.remote_attributes.values() %}
            {%- if attr.remote_attributes %}
        {{attr.name}} {{attr.name}};

            {%- else %}
                {%- if attr.getter_name %}
        {{attr.dtype.c_name}} get_{{attr.name}}(void);
                {%- endif %}
                {%- if attr.setter_name %}
        void set_{{attr.name}}({{attr.dtype.c_name}} value);
                {%- endif %}
                {%- if attr.caller_name %}
                    {%- set comma = joiner(", ") %}
        {{attr.dtype.c_name}} {{attr.name}}({%- for arg in attr.arguments %}{{ comma() }}{{arg.dtype.c_name}} {{ arg.name }} {%- endfor %});
                {%- endif %}

            {%- endif %}
        {%- endfor %}
    {%- endif %}

};
