#pragma once

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

namespace UsdLayerManager {

class UsdStageManager {
public:
    UsdStageManager();
    ~UsdStageManager();
    
    // Stage lifecycle management
    bool OpenStage(const std::string& filePath);
    bool CreateNewStage(const std::string& filePath);
    bool CreateInMemoryStage();
    void CloseStage();
    
    // Stage operations
    bool SaveStage();
    bool SaveStageAs(const std::string& filePath);
    
    // Stage access
    pxr::UsdStageRefPtr GetStage() const { return m_stage; }
    bool HasStage() const { return m_stage != nullptr; }
    
    // Stage information
    std::string GetRootLayerPath() const;
    std::string GetRootLayerIdentifier() const;
    pxr::SdfLayerHandle GetRootLayer() const;
    pxr::SdfLayerHandle GetSessionLayer() const;
    
    // Error handling
    std::string GetLastError() const { return m_lastError; }
    
private:
    void SetError(const std::string& error);
    
    pxr::UsdStageRefPtr m_stage;
    std::string m_lastError;
};

} // namespace UsdLayerManager
