// 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


//! State associated with a given execution task
//!
//! @note   We separated execution state from the execution graph to allow concurrent and/or nested execution
template <>
class omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>
    : public omni::graph::exec::unstable::IExecutionStateInfo_abi
{
public:
    OMNI_PLUGIN_INTERFACE("omni::graph::exec::unstable::IExecutionStateInfo")

    //! Store a "future" result for this state. The actual computation is running asynchronously outside of execution
    //! frame
    //!
    //! @return \c true if execution state accepts "future" results.
    bool storeBackgroundResult(omni::core::ObjectParam<omni::graph::exec::unstable::IBackgroundResult> result);

    //! Query used by some executors to determine if computation of a node is necessary
    bool needsCompute(const omni::graph::exec::unstable::Stamp& execVersion) noexcept;

    //! Set to request computation
    void requestCompute() noexcept;

    //! Reset request to compute after computation was performed
    void setComputed() noexcept;

    //! Get current/last exec version set for this node during execution
    omni::graph::exec::unstable::SyncStamp getExecutionStamp() noexcept;

    //! Set current exec version for this node. Returns true if version wasn't in sync.
    bool setExecutionStamp(const omni::graph::exec::unstable::Stamp& execVersion) noexcept;

    //! Returns a value from a node's key/value datastore.
    //!
    //! The key is used as a look-up in the node's key/value datastore.
    //!
    //! The type of each data item is returned in @p outTypeId.
    //!
    //! @p outPtr will be updated with a pointer to the actual data.
    //!
    //! @p outItemSize store the size of each item in the returned array.
    //!
    //! @p outItemCount contains the number of items returned (i.e. the number
    //! of items @p outPtr points to).  For an array, this will be greater than
    //! 1.
    //!
    //! If the key is not found, @p outPtr is set to @c nullptr and @p
    //! outItemCount is set to 0.
    //!
    //! Accessing the node's key/value datastore is not thread safe.
    //!
    //! An exception is thrown on all other errors.
    void getNodeData(omni::graph::exec::unstable::NodeDataKey key,
                     omni::core::TypeId* outTypeId,
                     void** outPtr,
                     uint64_t* outItemSize,
                     uint64_t* outItemCount);

    //! Sets a value in a node's key/value datastore.
    //!
    //! The key is used as a look-up in the node's key/value datastore.
    //!
    //! The type of each data item is set with @p typeId.
    //!
    //! @p data points to an array of data items.
    //!
    //! @p itemSize is the size of each item in the given array.
    //!
    //! @p itemCount contains the number of items pointed to by @p data. For an
    //! array, this will be greater than 1.
    //!
    //! @p deleter is a function used to delete @p data when either a new value
    //! is set at the key or the context is invalidated.  If @p deleter is @c
    //! nullptr, it is up to the calling code to manage the lifetime of the @p
    //! data.
    //!
    //! Accessing the node's key/value datastore is not thread safe.
    //!
    //! An exception is thrown on all other errors.
    void setNodeData(omni::graph::exec::unstable::NodeDataKey key,
                     omni::core::TypeId typeId,
                     void* data,
                     uint64_t itemSize,
                     uint64_t itemCount,
                     omni::graph::exec::unstable::NodeDataDeleterFn* deleter);
};

#endif

#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL

inline bool omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::storeBackgroundResult(
    omni::core::ObjectParam<omni::graph::exec::unstable::IBackgroundResult> result)
{
    OMNI_THROW_IF_ARG_NULL(result);
    auto return_ = storeBackgroundResult_abi(result.get());
    return return_;
}

inline bool omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::needsCompute(
    const omni::graph::exec::unstable::Stamp& execVersion) noexcept
{
    return needsCompute_abi(execVersion);
}

inline void omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::requestCompute() noexcept
{
    requestCompute_abi();
}

inline void omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::setComputed() noexcept
{
    setComputed_abi();
}

inline omni::graph::exec::unstable::SyncStamp omni::core::Generated<
    omni::graph::exec::unstable::IExecutionStateInfo_abi>::getExecutionStamp() noexcept
{
    return getExecutionStamp_abi();
}

inline bool omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::setExecutionStamp(
    const omni::graph::exec::unstable::Stamp& execVersion) noexcept
{
    return setExecutionStamp_abi(execVersion);
}

inline void omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::getNodeData(
    omni::graph::exec::unstable::NodeDataKey key,
    omni::core::TypeId* outTypeId,
    void** outPtr,
    uint64_t* outItemSize,
    uint64_t* outItemCount)
{
    OMNI_THROW_IF_ARG_NULL(outTypeId);
    OMNI_THROW_IF_ARG_NULL(outPtr);
    OMNI_THROW_IF_ARG_NULL(outItemSize);
    OMNI_THROW_IF_ARG_NULL(outItemCount);
    OMNI_THROW_IF_FAILED(getNodeData_abi(key, outTypeId, outPtr, outItemSize, outItemCount));
}

inline void omni::core::Generated<omni::graph::exec::unstable::IExecutionStateInfo_abi>::setNodeData(
    omni::graph::exec::unstable::NodeDataKey key,
    omni::core::TypeId typeId,
    void* data,
    uint64_t itemSize,
    uint64_t itemCount,
    omni::graph::exec::unstable::NodeDataDeleterFn* deleter)
{
    OMNI_THROW_IF_ARG_NULL(data);
    OMNI_THROW_IF_FAILED(setNodeData_abi(key, typeId, data, itemSize, itemCount, deleter));
}

#endif

#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
