omni/core/ModuleInfo.h
File members: omni/core/ModuleInfo.h
// Copyright (c) 2020-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.
//
#pragma once
#include "../../carb/extras/Library.h"
#include "../../carb/Interface.h"
#include "IObject.h"
namespace omni
{
namespace core
{
inline std::string getModuleFilename(omni::core::IObject* obj)
{
// getLibraryFilename maps an address to a library.
//
// the first entry in IObject is the vtable pointer on both Windows and Linux. here we use the first virtual
// function address as a function pointer to pass to getLibraryFilename.
//
// Fun fact: everyone loves pointer dereferencing gymnastics: ** **** ******* ****
void** vtbl = *reinterpret_cast<void***>(obj);
return carb::extras::getLibraryFilename(vtbl[0]);
}
} // namespace core
} // namespace omni
#define OMNI_PLUGIN_IMPL_DEPS(...) \
template <typename... Types> \
static void getPluginDepsTyped(struct carb::InterfaceDesc** deps, size_t* depsCount) \
{ \
static carb::InterfaceDesc depends[] = { Types::getInterfaceDesc()... }; \
*deps = depends; \
*depsCount = sizeof...(Types); \
} \
\
omni::core::Result omniGetDependencies(carb::InterfaceDesc** deps, size_t* depsCount) \
{ \
getPluginDepsTyped<__VA_ARGS__>(deps, depsCount); \
return omni::core::kResultSuccess; \
}
#define OMNI_PLUGIN_IMPL_NODEPS() \
omni::core::Result omniGetDependencies(carb::InterfaceDesc** deps, size_t* depsCount) \
{ \
*deps = nullptr; \
*depsCount = 0; \
return omni::core::kResultSuccess; \
}