ISettingsCommon.h#

Fully qualified name: carb/settings/detail/ISettingsCommon.h

File members: carb/settings/detail/ISettingsCommon.h

// SPDX-FileCopyrightText: Copyright (c) 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.

// purposely missing #pragma once

#ifdef DOXYGEN_BUILD
#    include "../../Defines.h"

namespace carb::settings
{
#endif

class ScopedWrite : public carb::dictionary::ScopedWrite
{
public:
    ScopedWrite()
        : carb::dictionary::ScopedWrite(
              *carb::getCachedInterface<dictionary::IDictionary>(),
              const_cast<dictionary::Item*>(carb::getCachedInterface<ISettings>()->getSettingsDictionary("/")))
    {
    }

    ScopedWrite(ISettings* settings, dictionary::IDictionary* dict)
        : carb::dictionary::ScopedWrite(*dict, const_cast<dictionary::Item*>(settings->getSettingsDictionary("/")))
    {
    }

    ~ScopedWrite() = default;
    CARB_PREVENT_COPY_AND_MOVE(ScopedWrite);
};

class ScopedRead : public carb::dictionary::ScopedRead
{
public:
    ScopedRead()
        : carb::dictionary::ScopedRead(*carb::getCachedInterface<dictionary::IDictionary>(),
                                       carb::getCachedInterface<ISettings>()->getSettingsDictionary("/"))
    {
    }

    ScopedRead(const ISettings* settings,
               dictionary::IDictionary* dict = carb::getCachedInterface<dictionary::IDictionary>())
        : carb::dictionary::ScopedRead(*dict, const_cast<dictionary::Item*>(settings->getSettingsDictionary("/")))
    {
    }

    ~ScopedRead() = default;
    CARB_PREVENT_COPY_AND_MOVE(ScopedRead);
};

#ifdef DOXYGEN_BUILD
} // namespace carb::settings
#endif