"""C++ code generator.

SPDX-License-Identifier: GPL-3.0-or-later
"""

import os

from ..common import CppGeneratorBase
from ...core.Constants import TOP_BLOCK_FILE_MODE


class CppNoGuiTopBlockGenerator(CppGeneratorBase):
    """Generator for no-GUI C++ top block code."""

    def __init__(self, flow_graph, output_dir, header_template=None, source_template=None):
        """
        Initialize the top block generator object.

        Args:
            flow_graph: the flow graph object
            output_dir: the path for written files
        """
        this_dir = os.path.dirname(__file__)
        super().__init__(flow_graph, output_dir, add_xterm=True,
                         header_template=header_template or os.path.join(this_dir, 'flow_graph_nogui.hpp.mako'),
                         source_template=source_template or os.path.join(this_dir, 'flow_graph_nogui.cpp.mako'),
                         cmake_template=os.path.join(this_dir, 'CMakeLists.txt.mako'),
                         )
        self._mode = TOP_BLOCK_FILE_MODE
