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


//! The Topology of a graph is stored in this class.
//!
//! @ref omni::graph::exec::unstable::ITopology is a helper interface used to quickly invalidate the topology, quickly
//! determine if the topology has been invalidated, assign each node in the topology a unique index (suitable for access
//! in contiguous memory), and provide access to the root node.
//!
//! Topologies play a large role in graph invalidation.  See @rstref{Graph Invalidation <ef_graph_invalidation>} for
//! details.
//!
//! To better understand how this object relates to other objects in the Execution Framework, see
//! @rstref{Graph Concepts <ef_graph_concepts>}.
//!
//! See @ref omni::graph::exec::unstable::Topology for a concrete implementation of this interface.
template <>
class omni::core::Generated<omni::graph::exec::unstable::ITopology_abi> : public omni::graph::exec::unstable::ITopology_abi
{
public:
    OMNI_PLUGIN_INTERFACE("omni::graph::exec::unstable::ITopology")

    //! Returns how many nodes are alive in this topology.  Some of the counted nodes may not be connected and
    //! discoverable from the root node.
    //!
    //! @thread_safety This method is thread safe.
    uint64_t getNodeCount() noexcept;

    //! Returns the topology's root node that allows reaching all of the valid nodes in the topology.
    //!
    //! The returned @ref omni::graph::exec::unstable::INode will *not* have @ref omni::core::IObject::acquire() called
    //! before being returned.
    //!
    //! The returned pointer will remain valid for the lifetime of this object.
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::INode* getRoot() noexcept;

    //! Returns the topology stamp.  This stamp is updated each time the topology is invalidated.
    //!
    //! See omni::graph::exec::unstable::ITopology::invalidate() to invalidate the topology (and thereby update this
    //! Stamp).
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::Stamp getStamp() noexcept;

    //! Invalidate topology. All edges of the graph will be dropped (lazily), nodes remain valid and can be used to
    //! build new topology.
    //!
    //! See @rstref{Graph Invalidation <ef_graph_invalidation>} for details about how this method is used during
    //! invalidation.
    //!
    //! It is not recommended to call this method during graph execution.  Rather, defer invalidation until after
    //! execution.
    //!
    //! @thread_safety This method is thread safe.
    void invalidate() noexcept;

    //! Returns a unique index for a node in this topology.
    //!
    //! Users should not call this method.  Only the constructors of implementations of @ref
    //! omni::graph::exec::unstable::INode should call this method.
    //!
    //! Returns an error if an index could not be acquired.
    //!
    //! See @ref omni::graph::exec::unstable::ITopology::releaseNodeIndex().
    //!
    //! @thread_safety This method is not thread safe.
    omni::graph::exec::unstable::NodeIndexInTopology acquireNodeIndex();

    //! Release unique index of a node in this topology. Shouldn't be used by anything else than a node's destructor.
    //!
    //! See @ref omni::graph::exec::unstable::ITopology::acquireNodeIndex().
    //!
    //! @thread_safety This method is not thread safe.
    void releaseNodeIndex(omni::graph::exec::unstable::NodeIndexInTopology index) noexcept;

    //! Add a callback to forward invalidation to other entities.
    //!
    //! At a minimum, the top-level @ref omni::graph::exec::unstable::IGraph will register a invalidation callback with
    //! all topologies created within a pass pipeline. This allows tracking invalidation and triggering minimal graph
    //! rebuild.
    //!
    //! In the future, override passes can generate new graphs and still track authoring invalidation by registering to
    //! the original graph topologies invalidation.
    //!
    //! The given @ref omni::graph::exec::unstable::IInvalidationForwarder will be stored and have @ref
    //! omni::core::IObject::acquire() called.
    //!
    //! If @p owner has a current forwarder, it will be replaced with the given forwarder.
    //!
    //! See @rstref{Graph Invalidation <ef_graph_invalidation>} for details about how this method is used during
    //! invalidation.
    //!
    //! See @ref omni::graph::exec::unstable::ITopology::removeInvalidationForwarder().
    //!
    //! @thread_safety This method is not thread safe.
    omni::core::Result addInvalidationForwarder(
        omni::graph::exec::unstable::InvalidationForwarderId owner,
        omni::core::ObjectParam<omni::graph::exec::unstable::IInvalidationForwarder> callback);

    //! Remove invalidation forwarding for a given owner.
    //!
    //! If the given owner is not known, this method does nothing.
    //!
    //! See @ref omni::graph::exec::unstable::ITopology::addInvalidationForwarder().
    //!
    //! @thread_safety This method is not thread safe.
    void removeInvalidationForwarder(omni::graph::exec::unstable::InvalidationForwarderId owner) noexcept;

    //! Get construction version this topology is synchronized with.
    //!
    //! @thread_safety This method is thread safe.
    omni::graph::exec::unstable::SyncStamp getConstructionStamp() noexcept;

    //! Private method only for IGraphBuilder, used to tag construction version.
    //!
    //! @thread_safety Calling this method concurrently is not recommended.
    void _setConstructionInSync(const omni::graph::exec::unstable::Stamp& toSync) noexcept;
};

#endif

#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL

inline uint64_t omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::getNodeCount() noexcept
{
    return getNodeCount_abi();
}

inline omni::graph::exec::unstable::INode* omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::getRoot() noexcept
{
    return getRoot_abi();
}

inline omni::graph::exec::unstable::Stamp omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::getStamp() noexcept
{
    return getStamp_abi();
}

inline void omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::invalidate() noexcept
{
    invalidate_abi();
}

inline omni::graph::exec::unstable::NodeIndexInTopology omni::core::Generated<
    omni::graph::exec::unstable::ITopology_abi>::acquireNodeIndex()
{
    omni::graph::exec::unstable::NodeIndexInTopology out;
    OMNI_THROW_IF_FAILED(acquireNodeIndex_abi(&out));
    return out;
}

inline void omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::releaseNodeIndex(
    omni::graph::exec::unstable::NodeIndexInTopology index) noexcept
{
    releaseNodeIndex_abi(index);
}

inline omni::core::Result omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::addInvalidationForwarder(
    omni::graph::exec::unstable::InvalidationForwarderId owner,
    omni::core::ObjectParam<omni::graph::exec::unstable::IInvalidationForwarder> callback)
{
    OMNI_THROW_IF_ARG_NULL(callback);
    auto return_ = addInvalidationForwarder_abi(owner, callback.get());
    return return_;
}

inline void omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::removeInvalidationForwarder(
    omni::graph::exec::unstable::InvalidationForwarderId owner) noexcept
{
    removeInvalidationForwarder_abi(owner);
}

inline omni::graph::exec::unstable::SyncStamp omni::core::Generated<
    omni::graph::exec::unstable::ITopology_abi>::getConstructionStamp() noexcept
{
    return getConstructionStamp_abi();
}

inline void omni::core::Generated<omni::graph::exec::unstable::ITopology_abi>::_setConstructionInSync(
    const omni::graph::exec::unstable::Stamp& toSync) noexcept
{
    _setConstructionInSync_abi(toSync);
}

#endif

#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
