EventsAdapterUtils.h#
Fully qualified name: carb/events/EventsAdapterUtils.h
File members: carb/events/EventsAdapterUtils.h
// Copyright (c) 2024-2025, 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 "IEvents.h"
#include "../eventdispatcher/IEventDispatcher.h"
#include "../../omni/String.h"
namespace carb
{
namespace events
{
#if CARB_VERSION_ATLEAST(carb_eventdispatcher_IEventDispatcher, 1, 3)
inline bool registerEventAlias(EventType eventType, RString pushEvent, RString popEvent)
{
auto ed = carb::getCachedInterface<eventdispatcher::IEventDispatcher>();
if (eventType == 0 || (pushEvent.isEmpty() && popEvent.isEmpty()))
return false;
omni::string scratch(omni::formatted, "AdapterAlias:%" PRIu64 ":immediate", eventType);
bool r1 = pushEvent.isEmpty() ? true : ed->addEventAlias(pushEvent, RString(scratch.c_str(), scratch.length()));
scratch.resize(scratch.size() - cpp::string_view(":immediate").length());
bool r2 = popEvent.isEmpty() ? true : ed->addEventAlias(popEvent, RString(scratch.c_str(), scratch.length()));
return r1 && r2;
}
inline bool unregisterEventAlias(EventType eventType, RString pushEvent, RString popEvent)
{
auto ed = carb::getCachedInterface<eventdispatcher::IEventDispatcher>();
if (eventType == 0 || (pushEvent.isEmpty() && popEvent.isEmpty()))
return false;
omni::string scratch(omni::formatted, "AdapterAlias:%" PRIu64 ":immediate", eventType);
bool r1 = pushEvent.isEmpty() ? true : ed->removeEventAlias(pushEvent, RString(scratch.c_str(), scratch.length()));
scratch.resize(scratch.size() - cpp::string_view(":immediate").length());
bool r2 = popEvent.isEmpty() ? true : ed->removeEventAlias(popEvent, RString(scratch.c_str(), scratch.length()));
return r1 && r2;
}
#endif
} // namespace events
} // namespace carb