ConfigurationContext.cpp (2399B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "ConfigurationContext.h" 5 #include <winrt/Microsoft.Management.Configuration.h> 6 7 using namespace winrt::Microsoft::Management::Configuration; 8 9 namespace AppInstaller::CLI::Execution 10 { 11 namespace details 12 { 13 struct ConfigurationContextData 14 { 15 ConfigurationProcessor Processor = nullptr; 16 ConfigurationSet Set = nullptr; 17 std::vector<ConfigurationSet> History; 18 }; 19 } 20 21 ConfigurationContext::ConfigurationContext() : m_data(std::make_unique<details::ConfigurationContextData>()) 22 { 23 } 24 25 ConfigurationContext::~ConfigurationContext() = default; 26 27 ConfigurationContext::ConfigurationContext(ConfigurationContext&&) = default; 28 ConfigurationContext& ConfigurationContext::operator=(ConfigurationContext&&) = default; 29 30 ConfigurationProcessor& ConfigurationContext::Processor() 31 { 32 return m_data->Processor; 33 } 34 35 const ConfigurationProcessor& ConfigurationContext::Processor() const 36 { 37 return m_data->Processor; 38 } 39 40 void ConfigurationContext::Processor(const ConfigurationProcessor& value) 41 { 42 m_data->Processor = value; 43 } 44 45 void ConfigurationContext::Processor(ConfigurationProcessor&& value) 46 { 47 m_data->Processor = std::move(value); 48 } 49 50 ConfigurationSet& ConfigurationContext::Set() 51 { 52 return m_data->Set; 53 } 54 55 const ConfigurationSet& ConfigurationContext::Set() const 56 { 57 return m_data->Set; 58 } 59 60 void ConfigurationContext::Set(const ConfigurationSet& value) 61 { 62 m_data->Set = value; 63 } 64 65 void ConfigurationContext::Set(ConfigurationSet&& value) 66 { 67 m_data->Set = std::move(value); 68 } 69 70 std::vector<ConfigurationSet>& ConfigurationContext::History() 71 { 72 return m_data->History; 73 } 74 75 const std::vector<ConfigurationSet>& ConfigurationContext::History() const 76 { 77 return m_data->History; 78 } 79 80 void ConfigurationContext::History(const winrt::Windows::Foundation::Collections::IVector<ConfigurationSet>& value) 81 { 82 std::vector<ConfigurationSet> history{ value.Size() }; 83 value.GetMany(0, history); 84 m_data->History = std::move(history); 85 } 86 }