omni/core/OmniAttr.h
File members: omni/core/OmniAttr.h
// Copyright (c) 2020-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 <type_traits>
#ifdef OMNI_BIND
// OMNI_ATTR("enum,prefix=eState") --> __attribute__((annotate("omni_attr:enum,prefix=eState")))
# define OMNI_ATTR(attrs_) __attribute__((annotate("omni_attr:" attrs_)))
#else
# define OMNI_ATTR(p0_)
#endif
#define OMNI_GENERATED_API(iface_) omni::core::Generated<iface_##_abi>
#define OMNI_USE_FROM_GENERATED_API(iface_, func_) using OMNI_GENERATED_API(iface_)::func_;
#define OMNI_DECLARE_INTERFACE(iface_) \
class iface_##_abi; \
\
using iface_ = omni::core::Api<iface_##_abi>;
#define OMNI_DEFINE_INTERFACE_API(iface_) \
\
template <> \
class omni::core::Api<iface_##_abi> : public OMNI_GENERATED_API(iface_)
namespace carb
{
template <typename T>
class ObjectPtr; // forward declaration needed by ObjectParam
}
namespace omni
{
namespace core
{
template <typename T>
class Generated : public T
{
};
template <typename T>
class Api : public Generated<T>
{
};
template <typename T>
class ObjectPtr; // forward declaration needed by ObjectParam
template <typename T>
class ObjectParam
{
public:
template <typename Y>
ObjectParam(const ObjectPtr<Y>& o, typename std::enable_if_t<std::is_base_of<T, Y>::value>* = nullptr) noexcept
: m_ptr{ o.get() }
{
}
template <typename Y>
ObjectParam(const carb::ObjectPtr<Y>& o) noexcept : m_ptr{ o.get() }
{
}
ObjectParam(T* o) noexcept : m_ptr{ o }
{
}
T* operator->() const noexcept
{
return m_ptr;
}
T* get() const noexcept
{
return m_ptr;
}
explicit operator bool() const noexcept
{
return m_ptr != nullptr;
}
private:
T* m_ptr;
};
} // namespace core
} // namespace omni