#pragma once

#include "../CommandHistory.h"
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/sdf/reference.h>
#include <string>

namespace UsdLayerManager {

class ReplaceReferenceCommand : public ICommand {
public:
    ReplaceReferenceCommand(pxr::UsdStageRefPtr      stage,
                            const pxr::SdfPath&      primPath,
                            const pxr::SdfReference& oldRef,
                            const pxr::SdfReference& newRef);

    void Execute() override;
    void Undo()    override;
    std::string GetDescription() const override { return m_description; }

private:
    void Apply(const pxr::SdfReference& toRemove, const pxr::SdfReference& toAdd);

    pxr::UsdStageRefPtr m_stage;
    pxr::SdfPath        m_primPath;
    pxr::SdfReference   m_oldRef;
    pxr::SdfReference   m_newRef;
    std::string         m_description;
};

} // namespace UsdLayerManager
