EventsAdapterUtils.h#
Fully qualified name: carb/events/EventsAdapterUtils.h
File members: carb/events/EventsAdapterUtils.h
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates 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 (!ed || 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