omni/connect/core/LiveSession.h

File members: omni/connect/core/LiveSession.h

// SPDX-FileCopyrightText: Copyright (c) 2022-2024 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 "Api.h"

#if OMNICONNECTCORE_WITH_NUCLEUS

#include "LiveSessionChannel.h"
#include "LiveSessionConfig.h"
#include "LiveSessionInfo.h"

#include <pxr/usd/sdf/layer.h>
#include <pxr/usd/usd/stage.h>

#include <memory>
#include <string>
#include <vector>

namespace omni::connect::core
{

class OMNICONNECTCORE_API LiveSession
{
public:

    static std::shared_ptr<LiveSession> create(pxr::UsdStagePtr rootStage);

    static std::shared_ptr<LiveSession> create(pxr::UsdStagePtr rootStage, std::shared_ptr<LiveSessionInfo> info);

    ~LiveSession();

    pxr::SdfLayerHandle join(const std::string& sessionName, const bool makeEditTarget = true);

    bool mergeToRoot(const char* checkpointComment = nullptr, const bool resetEditTarget = true);

    bool hasPrimSpecsInRootLayer();

    bool mergeToNewLayer(
        const char* targetLayerUri = nullptr,
        const char* checkpointComment = nullptr,
        const bool resetEditTarget = true,
        const pxr::SdfLayer::FileFormatArguments& fileFormatArgs = pxr::SdfLayer::FileFormatArguments()
    );

    void leave(const bool resetEditTarget = true);

    std::shared_ptr<LiveSessionChannel> getChannel() const;

    std::shared_ptr<LiveSessionInfo> getInfo() const;

private:

    LiveSession(pxr::UsdStagePtr rootStage, std::shared_ptr<LiveSessionInfo> info);
    LiveSession() = delete;

    class Impl;
    Impl* m_impl;
};
} // namespace omni::connect::core

#endif // OMNICONNECTCORE_WITH_NUCLEUS