// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//

//! @file IGraphBuilderContext.h
//!
//! @brief Defines @ref omni::graph::exec::unstable::IGraphBuilderContext.
#pragma once

#include <omni/graph/exec/unstable/IBase.h>
#include <omni/graph/exec/unstable/Stamp.h>

namespace omni
{
namespace graph
{
namespace exec
{
namespace unstable
{

// forward declarations needed by interface declaration
class IGraph;
class IGraphBuilder;
class IGraphBuilderContext;
class IGraphBuilderContext_abi;
class INodeGraphDef;

//! Common state for graph builders.
//!
//! *TODO* We will use this class to introduce reporting from graph transformation pipeline back to the application.
class IGraphBuilderContext_abi
    : public omni::core::Inherits<omni::graph::exec::unstable::IBase,
                                  OMNI_TYPE_ID("omni.graph.exec.unstable.IGraphBuilderContext")>
{
protected:
    //! Current construction version.
    //!
    //! Incremented after each pass pipeline run to include definitions that were created before the run.
    virtual Stamp getConstructionStamp_abi() noexcept = 0;

    //! Return owner of all graphs this builder touches
    //!
    //! The returned @ref omni::graph::exec::unstable::IGraph will *not* have
    //! @ref omni::core::IObject::acquire() called before being returned.
    virtual OMNI_ATTR("no_acquire") IGraph* getGraph_abi() noexcept = 0;

    //! To be overriden by application specific class to enable reporting from transformation pipeline.
    virtual void report_abi(OMNI_ATTR("in, c_str, not_null") const char* diagnose) noexcept = 0;

    //! Run transformation pipeline
    virtual void runTransformations_abi(OMNI_ATTR("not_null") INodeGraphDef* nodeGraphDef) noexcept = 0;
};

//! Smart pointer managing an instance of @ref IGraphBuilderContext.
using GraphBuilderContextPtr = omni::core::ObjectPtr<IGraphBuilderContext>;

} // namespace unstable
} // namespace exec
} // namespace graph
} // namespace omni

// generated API declaration
#define OMNI_BIND_INCLUDE_INTERFACE_DECL
#include <omni/graph/exec/unstable/IGraphBuilderContext.gen.h>

//! @copydoc omni::graph::exec::unstable::IGraphBuilderContext_abi
//!
//! @ingroup groupOmniGraphExecInterfaces
class omni::graph::exec::unstable::IGraphBuilderContext
    : public omni::core::Generated<omni::graph::exec::unstable::IGraphBuilderContext_abi>
{
};

// additional headers needed for API implementation
#include <omni/graph/exec/unstable/IGraph.h>
#include <omni/graph/exec/unstable/IGraphBuilder.h>
#include <omni/graph/exec/unstable/INodeGraphDef.h>

// generated API implementation
#define OMNI_BIND_INCLUDE_INTERFACE_IMPL
#include <omni/graph/exec/unstable/IGraphBuilderContext.gen.h>
