omni/kit/exec/core/unstable/IExecutionController.h
File members: omni/kit/exec/core/unstable/IExecutionController.h
// Copyright (c) 2022-2024, 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.
//
#pragma once
#include <omni/graph/exec/unstable/IBase.h>
#include <omni/graph/exec/unstable/Status.h>
#include <omni/kit/IStageUpdate.h> // StageUpdateSettings
namespace omni
{
namespace graph
{
namespace exec
{
namespace unstable
{
class IDef;
class IGraph;
class IScheduleFunction;
} // namespace unstable
} // namespace exec
} // namespace graph
namespace kit
{
namespace exec
{
namespace core
{
namespace unstable
{
// Forward declarations needed by interface declaration.
class IExecutionContext;
class IExecutionController;
class IExecutionController_abi;
class IExecutionController_abi
: public omni::core::Inherits<graph::exec::unstable::IBase, OMNI_TYPE_ID("omni.kit.exec.core.unstable.IExecutionController")>
{
protected:
virtual void compile_abi() noexcept = 0;
virtual OMNI_ATTR("nodiscard") omni::graph::exec::unstable::Status
executeDefinition_abi(OMNI_ATTR("not_null") omni::graph::exec::unstable::IDef* execDef) noexcept = 0;
virtual OMNI_ATTR("nodiscard") omni::graph::exec::unstable::Status
execute_abi(double currentTime,
float elapsedSecs,
double absoluteSimTime,
OMNI_ATTR("in") const omni::kit::StageUpdateSettings* updateSettings) noexcept = 0;
virtual OMNI_ATTR("not_null, no_acquire") IExecutionContext* getContext_abi() noexcept = 0;
virtual OMNI_ATTR("not_null, no_acquire") omni::graph::exec::unstable::IGraph* getGraph_abi() noexcept = 0;
virtual OMNI_ATTR("no_api") void schedulePreProcessTask_abi(OMNI_ATTR("not_null")
graph::exec::unstable::IScheduleFunction* fn,
const bool persist,
const uint64_t moduleHash) noexcept = 0;
virtual OMNI_ATTR("no_api") void schedulePostProcessTask_abi(
OMNI_ATTR("not_null") graph::exec::unstable::IScheduleFunction* fn) noexcept = 0;
};
using ExecutionControllerPtr = omni::core::ObjectPtr<IExecutionController>;
} // namespace unstable
} // namespace core
} // namespace exec
} // namespace kit
} // namespace omni
// Generated API declaration.
#define OMNI_BIND_INCLUDE_INTERFACE_DECL
#include <omni/kit/exec/core/unstable/IExecutionController.gen.h>
class omni::kit::exec::core::unstable::IExecutionController
: public omni::core::Generated<omni::kit::exec::core::unstable::IExecutionController_abi>
{
public:
template <typename Fn>
inline void schedulePreProcessTask(Fn&& callback, const bool persist) noexcept;
template <typename Fn>
inline void schedulePostProcessTask(Fn&& callback) noexcept;
};
// Additional headers needed for API implementation.
#include <omni/graph/exec/unstable/IDef.h>
#include <omni/graph/exec/unstable/IGraph.h>
#include <omni/graph/exec/unstable/IScheduleFunction.h>
#include <omni/kit/exec/core/unstable/IExecutionContext.h>
#include <omni/kit/exec/core/unstable/IExecutionControllerFactory.h>
template <typename Fn>
inline void omni::kit::exec::core::unstable::IExecutionController::schedulePreProcessTask(Fn&& callback,
const bool persist) noexcept
{
class Forwarder : public graph::exec::unstable::Implements<graph::exec::unstable::IScheduleFunction>
{
public:
Forwarder(Fn&& fn) noexcept : m_fn(std::move(fn))
{
}
protected:
graph::exec::unstable::Status invoke_abi() noexcept override
{
m_fn();
return graph::exec::unstable::Status::eSuccess;
}
Fn m_fn;
};
schedulePreProcessTask_abi(
omni::core::steal(new Forwarder(std::forward<Fn>(callback))).get(), persist, detail::getModuleHash());
}
template <typename Fn>
inline void omni::kit::exec::core::unstable::IExecutionController::schedulePostProcessTask(Fn&& callback) noexcept
{
class Forwarder : public graph::exec::unstable::Implements<graph::exec::unstable::IScheduleFunction>
{
public:
Forwarder(Fn&& fn) noexcept : m_fn(std::move(fn))
{
}
protected:
graph::exec::unstable::Status invoke_abi() noexcept override
{
m_fn();
return graph::exec::unstable::Status::eSuccess;
}
Fn m_fn;
};
if (getContext()->inExecute())
{
schedulePostProcessTask_abi(omni::core::steal(new Forwarder(std::forward<Fn>(callback))).get());
}
}
// Generated API implementation.
#define OMNI_BIND_INCLUDE_INTERFACE_IMPL
#include <omni/kit/exec/core/unstable/IExecutionController.gen.h>