// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.2.1

#include "py.Windows.System.Power.Diagnostics.h"

namespace py::cpp::Windows::System::Power::Diagnostics
{
    // ----- BackgroundEnergyDiagnostics class --------------------

    static PyObject* _new_BackgroundEnergyDiagnostics(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Power::Diagnostics::BackgroundEnergyDiagnostics>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Power::Diagnostics::BackgroundEnergyDiagnostics>::type_name);
        return nullptr;
    }

    static PyObject* BackgroundEnergyDiagnostics_ComputeTotalEnergyUsage(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.System.Power.Diagnostics.BackgroundEnergyDiagnostics", L"ComputeTotalEnergyUsage", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::System::Power::Diagnostics::BackgroundEnergyDiagnostics::ComputeTotalEnergyUsage();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyDiagnostics_ResetTotalEnergyUsage(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.System.Power.Diagnostics.BackgroundEnergyDiagnostics", L"ResetTotalEnergyUsage", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    winrt::Windows::System::Power::Diagnostics::BackgroundEnergyDiagnostics::ResetTotalEnergyUsage();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyDiagnostics_get_DeviceSpecificConversionFactor(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.System.Power.Diagnostics.BackgroundEnergyDiagnostics", L"DeviceSpecificConversionFactor");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::System::Power::Diagnostics::BackgroundEnergyDiagnostics::DeviceSpecificConversionFactor();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_BackgroundEnergyDiagnostics[] = {
        { }};

    static PyGetSetDef _getset_BackgroundEnergyDiagnostics[] = {
        { }};

    static PyType_Slot _type_slots_BackgroundEnergyDiagnostics[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_BackgroundEnergyDiagnostics) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_BackgroundEnergyDiagnostics) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_BackgroundEnergyDiagnostics) },
        { }};

    static PyType_Spec type_spec_BackgroundEnergyDiagnostics = {
        "winrt._winrt_windows_system_power_diagnostics.BackgroundEnergyDiagnostics",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_BackgroundEnergyDiagnostics};

    static PyGetSetDef getset_BackgroundEnergyDiagnostics_Static[] = {
        { "device_specific_conversion_factor", reinterpret_cast<getter>(BackgroundEnergyDiagnostics_get_DeviceSpecificConversionFactor), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_BackgroundEnergyDiagnostics_Static[] = {
        { "compute_total_energy_usage", reinterpret_cast<PyCFunction>(BackgroundEnergyDiagnostics_ComputeTotalEnergyUsage), METH_VARARGS, nullptr },
        { "reset_total_energy_usage", reinterpret_cast<PyCFunction>(BackgroundEnergyDiagnostics_ResetTotalEnergyUsage), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_BackgroundEnergyDiagnostics_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_BackgroundEnergyDiagnostics_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_BackgroundEnergyDiagnostics_Static) },
        { }
    };

    static PyType_Spec type_spec_BackgroundEnergyDiagnostics_Static = {
        "winrt._winrt_windows_system_power_diagnostics.BackgroundEnergyDiagnostics_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_BackgroundEnergyDiagnostics_Static};

    // ----- ForegroundEnergyDiagnostics class --------------------

    static PyObject* _new_ForegroundEnergyDiagnostics(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Power::Diagnostics::ForegroundEnergyDiagnostics>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Power::Diagnostics::ForegroundEnergyDiagnostics>::type_name);
        return nullptr;
    }

    static PyObject* ForegroundEnergyDiagnostics_ComputeTotalEnergyUsage(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.System.Power.Diagnostics.ForegroundEnergyDiagnostics", L"ComputeTotalEnergyUsage", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::System::Power::Diagnostics::ForegroundEnergyDiagnostics::ComputeTotalEnergyUsage();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyDiagnostics_ResetTotalEnergyUsage(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.System.Power.Diagnostics.ForegroundEnergyDiagnostics", L"ResetTotalEnergyUsage", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    winrt::Windows::System::Power::Diagnostics::ForegroundEnergyDiagnostics::ResetTotalEnergyUsage();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyDiagnostics_get_DeviceSpecificConversionFactor(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.System.Power.Diagnostics.ForegroundEnergyDiagnostics", L"DeviceSpecificConversionFactor");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::System::Power::Diagnostics::ForegroundEnergyDiagnostics::DeviceSpecificConversionFactor();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_ForegroundEnergyDiagnostics[] = {
        { }};

    static PyGetSetDef _getset_ForegroundEnergyDiagnostics[] = {
        { }};

    static PyType_Slot _type_slots_ForegroundEnergyDiagnostics[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_ForegroundEnergyDiagnostics) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ForegroundEnergyDiagnostics) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ForegroundEnergyDiagnostics) },
        { }};

    static PyType_Spec type_spec_ForegroundEnergyDiagnostics = {
        "winrt._winrt_windows_system_power_diagnostics.ForegroundEnergyDiagnostics",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ForegroundEnergyDiagnostics};

    static PyGetSetDef getset_ForegroundEnergyDiagnostics_Static[] = {
        { "device_specific_conversion_factor", reinterpret_cast<getter>(ForegroundEnergyDiagnostics_get_DeviceSpecificConversionFactor), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_ForegroundEnergyDiagnostics_Static[] = {
        { "compute_total_energy_usage", reinterpret_cast<PyCFunction>(ForegroundEnergyDiagnostics_ComputeTotalEnergyUsage), METH_VARARGS, nullptr },
        { "reset_total_energy_usage", reinterpret_cast<PyCFunction>(ForegroundEnergyDiagnostics_ResetTotalEnergyUsage), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_ForegroundEnergyDiagnostics_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_ForegroundEnergyDiagnostics_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_ForegroundEnergyDiagnostics_Static) },
        { }
    };

    static PyType_Spec type_spec_ForegroundEnergyDiagnostics_Static = {
        "winrt._winrt_windows_system_power_diagnostics.ForegroundEnergyDiagnostics_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_ForegroundEnergyDiagnostics_Static};

    // ----- Windows.System.Power.Diagnostics Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.System.Power.Diagnostics");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_system_power_diagnostics",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::System::Power::Diagnostics

PyMODINIT_FUNC PyInit__winrt_windows_system_power_diagnostics(void) noexcept
{
    using namespace py::cpp::Windows::System::Power::Diagnostics;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle BackgroundEnergyDiagnostics_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!BackgroundEnergyDiagnostics_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_BackgroundEnergyDiagnostics_Static{PyType_FromSpecWithBases(&type_spec_BackgroundEnergyDiagnostics_Static, BackgroundEnergyDiagnostics_Static_bases.get())};
    if (!type_BackgroundEnergyDiagnostics_Static)
    {
        return nullptr;
    }

    py::pytype_handle BackgroundEnergyDiagnostics_type{py::register_python_type(module.get(), &type_spec_BackgroundEnergyDiagnostics, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_BackgroundEnergyDiagnostics_Static.get()))};
    if (!BackgroundEnergyDiagnostics_type)
    {
        return nullptr;
    }

    py::pyobj_handle ForegroundEnergyDiagnostics_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!ForegroundEnergyDiagnostics_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_ForegroundEnergyDiagnostics_Static{PyType_FromSpecWithBases(&type_spec_ForegroundEnergyDiagnostics_Static, ForegroundEnergyDiagnostics_Static_bases.get())};
    if (!type_ForegroundEnergyDiagnostics_Static)
    {
        return nullptr;
    }

    py::pytype_handle ForegroundEnergyDiagnostics_type{py::register_python_type(module.get(), &type_spec_ForegroundEnergyDiagnostics, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_ForegroundEnergyDiagnostics_Static.get()))};
    if (!ForegroundEnergyDiagnostics_type)
    {
        return nullptr;
    }


    return module.detach();
}
