//
//  AudioNode.hpp
//  SwitchboardSDK
//
//  Created by Balázs Kiss on 2022. 03. 03..
//  Copyright © 2022. Synervoz Inc. All rights reserved.
//

#pragma once

#include <any>
#include <map>
#include <string>
#include <switchboard/export.h>
#include <switchboard_core/Node.hpp>
#include <switchboard_core/SwitchboardCore.hpp>
#include <vector>

namespace switchboard {

/**
 * AudioNode class.
 * @brief Represents a node in the audio graph.
 */
class SWITCHBOARDSDK_EXPORT AudioNode : public Node {
public:
    /**
     * @brief AudioNode constructor.
     *
     * @param numberOfInputs The number of inputs for the audio node.
     * @param numberOfOutputs The number of outputs for the audio node.
     */
    AudioNode(uint numberOfInputs, uint numberOfOutputs);

    /**
     * @brief AudioNode virtual destructor.
     */
    ~AudioNode() override = default;

    /**
     * @brief Gets the display name of the audio node.
     * @details By default the display name follows this format: name (type)
     *
     * @returns The display name of the node.
     */
    virtual std::string getDisplayName() const;

    /**
     * @brief Called when the audio graph is started.
     * @details Runs on the caller's thread, before any process() call for this run. Format-dependent
     * state belongs in setBusFormats(), which runs again on the first process() after every start.
     */
    virtual void onGraphStart() {}

    /**
     * @brief Called when the audio graph is stopped.
     * @details Runs on the caller's thread with no guarantee that process() has returned, and no flag
     * or lock set here can change that: the graph frees its per-node state as stop() returns. Do not
     * free or resize what process() touches, leave that to the destructor. Use it for work that is
     * safe alongside a final process(): closing a file, signalling a worker, emitting an event.
     * @see AudioGraph::stop() for the ordering the caller must guarantee.
     */
    virtual void onGraphStop() {}
};

}
