ConfigurationSet.h (5003B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include "ConfigurationSet.g.h" 5 #include "ConfigurationEnvironment.h" 6 #include "ConfigurationSetChangeData.h" 7 #include "ConfigurationStatus.h" 8 #include <winget/ILifetimeWatcher.h> 9 #include <winget/ModuleCountBase.h> 10 #include <winrt/Windows.Foundation.h> 11 #include <winrt/Windows.Foundation.Collections.h> 12 #include <vector> 13 14 namespace winrt::Microsoft::Management::Configuration::implementation 15 { 16 struct ConfigurationSet : ConfigurationSetT<ConfigurationSet, winrt::cloaked<AppInstaller::WinRT::ILifetimeWatcher>>, AppInstaller::WinRT::LifetimeWatcherBase, AppInstaller::WinRT::ModuleCountBase 17 { 18 using WinRT_Self = ::winrt::Microsoft::Management::Configuration::ConfigurationSet; 19 using ConfigurationUnit = ::winrt::Microsoft::Management::Configuration::ConfigurationUnit; 20 using ConfigurationParameter = ::winrt::Microsoft::Management::Configuration::ConfigurationParameter; 21 22 ConfigurationSet(); 23 24 #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) 25 ConfigurationSet(const guid& instanceIdentifier); 26 void Units(std::vector<Configuration::ConfigurationUnit>&& units); 27 void Parameters(std::vector<Configuration::ConfigurationParameter>&& value); 28 void ConfigurationSetChange(com_ptr<ConfigurationSetChangeData>& data, const std::optional<guid>& unitInstanceIdentifier); 29 implementation::ConfigurationEnvironment& EnvironmentInternal(); 30 std::vector<Configuration::ConfigurationEnvironment> GetUnitEnvironmentsInternal(); 31 #endif 32 33 hstring Name(); 34 void Name(const hstring& value); 35 36 hstring Origin(); 37 void Origin(const hstring& value); 38 39 hstring Path(); 40 void Path(const hstring& value); 41 42 guid InstanceIdentifier() const; 43 ConfigurationSetState State(); 44 clock::time_point FirstApply(); 45 clock::time_point ApplyBegun(); 46 clock::time_point ApplyEnded(); 47 48 Windows::Foundation::Collections::IVector<ConfigurationUnit> Units(); 49 void Units(const Windows::Foundation::Collections::IVector<ConfigurationUnit>& value); 50 51 hstring SchemaVersion(); 52 void SchemaVersion(const hstring& value); 53 54 event_token ConfigurationSetChange(const Windows::Foundation::TypedEventHandler<WinRT_Self, Configuration::ConfigurationSetChangeData>& handler); 55 void ConfigurationSetChange(const event_token& token) noexcept; 56 57 void Serialize(const Windows::Storage::Streams::IOutputStream& stream); 58 59 void Remove(); 60 61 Windows::Foundation::Collections::ValueSet Metadata(); 62 void Metadata(const Windows::Foundation::Collections::ValueSet& value); 63 64 Windows::Foundation::Collections::IVector<ConfigurationParameter> Parameters(); 65 void Parameters(const Windows::Foundation::Collections::IVector<ConfigurationParameter>& value); 66 67 Windows::Foundation::Collections::ValueSet Variables(); 68 void Variables(const Windows::Foundation::Collections::ValueSet& value); 69 70 Windows::Foundation::Uri SchemaUri(); 71 void SchemaUri(const Windows::Foundation::Uri& value); 72 73 Configuration::ConfigurationEnvironment Environment(); 74 75 Windows::Foundation::Collections::IVector<Configuration::ConfigurationEnvironment> GetUnitEnvironments(); 76 77 HRESULT STDMETHODCALLTYPE SetLifetimeWatcher(IUnknown* watcher); 78 79 #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) 80 void SetInputHash(std::string inputHash); 81 const std::string& GetInputHash() const; 82 83 private: 84 hstring m_name; 85 hstring m_origin; 86 hstring m_path; 87 guid m_instanceIdentifier; 88 clock::time_point m_firstApply{}; 89 Windows::Foundation::Collections::IVector<ConfigurationUnit> m_units{ winrt::multi_threaded_vector<ConfigurationUnit>() }; 90 hstring m_schemaVersion; 91 winrt::event<Windows::Foundation::TypedEventHandler<WinRT_Self, Configuration::ConfigurationSetChangeData>> m_configurationSetChange; 92 Windows::Foundation::Collections::ValueSet m_metadata; 93 Windows::Foundation::Collections::IVector<ConfigurationParameter> m_parameters{ winrt::multi_threaded_vector<ConfigurationParameter>() }; 94 Windows::Foundation::Collections::ValueSet m_variables; 95 Windows::Foundation::Uri m_schemaUri = nullptr; 96 std::string m_inputHash; 97 std::shared_ptr<ConfigurationStatus::SetChangeRegistration> m_setChangeRegistration; 98 com_ptr<implementation::ConfigurationEnvironment> m_environment{ make_self<implementation::ConfigurationEnvironment>() }; 99 #endif 100 }; 101 } 102 103 #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) 104 namespace winrt::Microsoft::Management::Configuration::factory_implementation 105 { 106 struct ConfigurationSet : ConfigurationSetT<ConfigurationSet, implementation::ConfigurationSet> 107 { 108 }; 109 } 110 #endif