// 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 IDef.h
//!
//! @brief Defines @ref omni::graph::exec::unstable::IDef.
#pragma once

#include <omni/graph/exec/unstable/ConstName.h>
#include <omni/graph/exec/unstable/IBase.h>
#include <omni/graph/exec/unstable/SchedulingInfo.h>
#include <omni/graph/exec/unstable/Status.h>
#include <omni/graph/exec/unstable/Types.h>

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

class IDef;
class IDef_abi;
class ExecutionTask;

//! Base class for all node definitions
//!
//! See @rstref{Execution Concepts <ef_execution_concepts>} for an in-depth guide on how this object is used during
//! execution.
//!
//! Since definitions can be shared by multiple nodes, and nodes can be executed in parallel, implementations of
//! this interface should expect its methods to be called in parallel.
class IDef_abi
    : public omni::core::Inherits<omni::graph::exec::unstable::IBase, OMNI_TYPE_ID("omni.graph.exec.unstable.IDef")>
{
protected:
    //! Execute the node definition.
    //!
    //! See thread safety information in interface description.
    virtual Status execute_abi(OMNI_ATTR("in, out, not_null, throw_if_null, ref") ExecutionTask* info) noexcept = 0;

    //! Provide runtime information about scheduling constraints particular task have
    //!
    //! The provided @ref omni::graph::exec::unstable::ExecutionTask can be used to determine the path of the current
    //! definition.
    //!
    //! The given task must not be @c nullptr.
    //!
    //! See thread safety information in interface description.
    virtual SchedulingInfo getSchedulingInfo_abi(OMNI_ATTR("in, not_null, throw_if_null, ref")
                                                     const ExecutionTask* info) noexcept = 0;

    //! Return unique definition identifier.
    //!
    //! See thread safety information in interface description.
    virtual OMNI_ATTR("ref") const ConstName* getName_abi() noexcept = 0;
};

//! Smart pointer managing an instance of @ref omni::graph::exec::unstable::IDef.
using DefPtr = omni::core::ObjectPtr<IDef>;

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

#define OMNI_BIND_INCLUDE_INTERFACE_DECL
#include <omni/graph/exec/unstable/IDef.gen.h>

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

#define OMNI_BIND_INCLUDE_INTERFACE_IMPL
#include <omni/graph/exec/unstable/IDef.gen.h>
