// 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.
//

#include <OgnGetParentPrimsDatabase.h>

namespace omni
{
namespace graph
{
namespace nodes
{

class OgnGetParentPrims
{
public:
    static size_t computeVectorized(OgnGetParentPrimsDatabase& db, size_t count)
    {
        auto pathInterface = carb::getCachedInterface<omni::fabric::IPath>();
        if (!pathInterface)
        {
            CARB_LOG_ERROR("Failed to initialize path or token interface");
            return 0;
        }

        for (size_t i = 0; i < count; i++)
        {
            const auto& prims = db.inputs.prims(i);
            auto& parentPaths = db.outputs.parentPrims(i);
            parentPaths.resize(prims.size());
            std::transform(prims.begin(), prims.end(), parentPaths.begin(),
                           [&](const auto& p) { return pathInterface->getParent(p); });
        }
        return count;
    }
};

REGISTER_OGN_NODE();

} // nodes
} // graph
} // omni
