// 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.
//
// --------- Warning: This is a build system generated file. ----------
//

//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.

#include <omni/core/Interface.h>
#include <omni/core/OmniAttr.h>
#include <omni/core/ResultError.h>

#include <functional>
#include <type_traits>
#include <utility>

#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL


//! Encapsulates the execution state for the current thread allowing callers to determine quantities like the @ref
//! omni::graph::exec::unstable::ExecutionTask currently executing on the thread.
//!
//! Because methods in this interface return thread local data, all methods in this interface are thread safe.
//!
//! This interface is usually accessed as a singleton via one of the following helper methods:
//!
//! - @ref omni::graph::exec::unstable::getCurrentTask()
//!
//! - @ref omni::graph::exec::unstable::getCurrentExecutor()
//!
//! This interface contains methods for graph and task execution.  Users should not call these methods directly.  See
//! the methods' docs below for the correct way to perform execution.
//!
//! See @rstref{Execution Concepts <ef_execution_concepts>} for an in-depth guide on how this object is used during
//! execution.
template <>
class omni::core::Generated<omni::graph::exec::unstable::IExecutionCurrentThread_abi>
    : public omni::graph::exec::unstable::IExecutionCurrentThread_abi
{
public:
    OMNI_PLUGIN_INTERFACE("omni::graph::exec::unstable::IExecutionCurrentThread")

    //! Executes the given @ref omni::graph::exec::unstable::Graph.
    //!
    //! Do not call this function directly, rather, call @ref omni::graph::exec::unstable::IExecutionContext::execute().
    //!
    //! From an ABI point-of-view, the purpose of this method is to handle the special case of the top-level @ref
    //! omni::graph::exec::unstable::INodeGraphDef being contained by @ref omni::graph::exec::unstable::IGraph rather
    //! than pointed to by a node in another @ref omni::graph::exec::unstable::INodeGraphDef.  Meaningful values are set
    //! for the threads current task and executor (see @ref omni::graph::exec::unstable::getCurrentTask() and @ref
    //! omni::graph::exec::unstable::getCurrentExecutor()).
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::Status executeGraph(
        omni::core::ObjectParam<omni::graph::exec::unstable::IGraph> graph,
        omni::core::ObjectParam<omni::graph::exec::unstable::IExecutionContext> context);

    //! Executes and sets the thread's "current" task to the given task.
    //!
    //! Do not call this function directly, rather, call @ref omni::graph::exec::unstable::ExecutionTask::execute().
    //!
    //! This method executes the definition of the node pointed to by the given task.  Importantly, this method sets
    //! thread local data to track the currently running task and executor (see @ref
    //! omni::graph::exec::unstable::getCurrentTask() and @ref omni::graph::exec::unstable::getCurrentExecutor()).
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::Status execute(omni::graph::exec::unstable::ExecutionTask& task,
                                                omni::core::ObjectParam<omni::graph::exec::unstable::IExecutor> executor,
                                                omni::graph::exec::unstable::Status* taskStatus);

    //! Access the task currently executing on the current thread.
    //!
    //! Useful when needing to access execution context state without having to pass it to every function.
    //!
    //! Do not call this function directly, rather, call @ref omni::graph::exec::unstable::getCurrentTask().
    //!
    //! May return @c nullptr.
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::ExecutionTask* getCurrentTask() noexcept;

    //! Access the executor currently executing on the current thread.
    //!
    //! Useful when needing to spawn extra work within the scope of the graph.
    //!
    //! Do not call this function directly, rather, call @ref omni::graph::exec::unstable::getCurrentExecutor().
    //!
    //! May return @c nullptr.
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::IExecutor* getCurrentExecutor() noexcept;
};

#endif

#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL

inline omni::graph::exec::unstable::Status omni::core::Generated<omni::graph::exec::unstable::IExecutionCurrentThread_abi>::executeGraph(
    omni::core::ObjectParam<omni::graph::exec::unstable::IGraph> graph,
    omni::core::ObjectParam<omni::graph::exec::unstable::IExecutionContext> context)
{
    OMNI_THROW_IF_ARG_NULL(graph);
    OMNI_THROW_IF_ARG_NULL(context);
    auto return_ = executeGraph_abi(graph.get(), context.get());
    return return_;
}

inline omni::graph::exec::unstable::Status omni::core::Generated<omni::graph::exec::unstable::IExecutionCurrentThread_abi>::execute(
    omni::graph::exec::unstable::ExecutionTask& task,
    omni::core::ObjectParam<omni::graph::exec::unstable::IExecutor> executor,
    omni::graph::exec::unstable::Status* taskStatus)
{
    OMNI_THROW_IF_ARG_NULL(taskStatus);
    auto return_ = execute_abi(&task, executor.get(), taskStatus);
    return return_;
}

inline omni::graph::exec::unstable::ExecutionTask* omni::core::Generated<
    omni::graph::exec::unstable::IExecutionCurrentThread_abi>::getCurrentTask() noexcept
{
    return getCurrentTask_abi();
}

inline omni::graph::exec::unstable::IExecutor* omni::core::Generated<
    omni::graph::exec::unstable::IExecutionCurrentThread_abi>::getCurrentExecutor() noexcept
{
    return getCurrentExecutor_abi();
}

#endif

#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
