Repository: microsoft/terminal
File: src/cascadia/TerminalApp/WindowsPackageManagerFactory.h (C/C++)

Code before:
// - This factory is designed to create production-level instances of WinGet objects.
//   Elevated sessions require manual activation of WinGet objects and are not currently supported,
//   while non-elevated sessions can use the standard WinRT activation system.
// Author:
// - Carlos Zamora (carlos-zamora) 23-Jul-2024

#pragma once

#include "../../types/inc/utils.hpp"
#include <combaseapi.h>
#include <wil/result_macros.h>
#include <wil/win32_helpers.h>
#include <type_traits>

#include <winrt/Microsoft.Management.Deployment.h>

namespace winrt::TerminalApp::implementation
{
    class WindowsPackageManagerFactory
    {
    public:
        static WindowsPackageManagerFactory& Instance()
        {
            static WindowsPackageManagerFactory instance;
            return instance;
        }

        // Delete copy constructor and assignment operator
        WindowsPackageManagerFactory(const WindowsPackageManagerFactory&) = delete;
        WindowsPackageManagerFactory& operator=(const WindowsPackageManagerFactory&) = delete;

        winrt::Microsoft::Management::Deployment::PackageManager CreatePackageManager()
        {
            static winrt::guid clsid{ "C53A4F16-787E-42A4-B304-29EFFB4BF597" };
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::PackageManager>(clsid, CLSCTX_ALL);
        }

        winrt::Microsoft::Management::Deployment::FindPackagesOptions CreateFindPackagesOptions()
        {
            static winrt::guid clsid{ "572DED96-9C60-4526-8F92-EE7D91D38C1A" };
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::FindPackagesOptions>(clsid, CLSCTX_ALL);
        }

        winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions()
        {
            static winrt::guid clsid{ "526534B8-7E46-47C8-8416-B1685C327D37" };
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions>(clsid, CLSCTX_ALL);
        }

        winrt::Microsoft::Management::Deployment::InstallOptions CreateInstallOptions()
        {

Review comment (suggestion):
Since this singleton has no members, you can instead also simply declare all those member functions as `static`. That way you don't need to call `Instance()` anywhere.

Code after:
// - This factory is designed to create production-level instances of WinGet objects.
//   Elevated sessions require manual activation of WinGet objects and are not currently supported,
//   while non-elevated sessions can use the standard WinRT activation system.
// Author:
// - Carlos Zamora (carlos-zamora) 23-Jul-2024

#pragma once

#include <winrt/Microsoft.Management.Deployment.h>

namespace winrt::TerminalApp::implementation
{
    struct WindowsPackageManagerFactory
    {
    public:
        static winrt::Microsoft::Management::Deployment::PackageManager CreatePackageManager()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::PackageManager>(PackageManagerGuid, CLSCTX_ALL);
        }

        static winrt::Microsoft::Management::Deployment::FindPackagesOptions CreateFindPackagesOptions()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::FindPackagesOptions>(FindPackageOptionsGuid, CLSCTX_ALL);
        }

        static winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions>(CreateCompositePackageCatalogOptionsGuid, CLSCTX_ALL);
        }

        static winrt::Microsoft::Management::Deployment::InstallOptions CreateInstallOptions()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::InstallOptions>(InstallOptionsGuid, CLSCTX_ALL);
        }

        static winrt::Microsoft::Management::Deployment::UninstallOptions CreateUninstallOptions()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::UninstallOptions>(UninstallOptionsGuid, CLSCTX_ALL);
        }

        static winrt::Microsoft::Management::Deployment::PackageMatchFilter CreatePackageMatchFilter()
        {
            return winrt::create_instance<winrt::Microsoft::Management::Deployment::PackageMatchFilter>(PackageMatchFilterGuid, CLSCTX_ALL);
        }

    private:
        static constexpr winrt::guid PackageManagerGuid{ 0xC53A4F16, 0x787E, 0x42A4, { 0xB3, 0x04, 0x29, 0xEF, 0xFB, 0x4B, 0xF5, 0x97 } };
        static constexpr winrt::guid FindPackageOptionsGuid{ 0x572DED96, 0x9C60, 0x4526, { 0x8F, 0x92, 0xEE, 0x7D, 0x91, 0xD3, 0x8C, 0x1A } };
        static constexpr winrt::guid CreateCompositePackageCatalogOptionsGuid{ 0x526534B8, 0x7E46, 0x47C8, { 0x84, 0x16, 0xB1, 0x68, 0x5C, 0x32, 0x7D, 0x37 } };
        static constexpr winrt::guid InstallOptionsGuid{ 0x1095F097, 0xEB96, 0x453B, { 0xB4, 0xE6, 0x16, 0x13, 0x63, 0x7F, 0x3B, 0x14 } };
        static constexpr winrt::guid UninstallOptionsGuid{ 0xE1D9A11E, 0x9F85, 0x4D87, { 0x9C, 0x17, 0x2B, 0x93, 0x14, 0x3A, 0xDB, 0x8D } };