SetInfoTable.h (1855B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include "winrt/Microsoft.Management.Configuration.h" 5 #include "Database/Schema/IConfigurationDatabase.h" 6 #include <winget/SQLiteWrapper.h> 7 #include <optional> 8 #include <vector> 9 10 namespace winrt::Microsoft::Management::Configuration::implementation::Database::Schema::V0_1 11 { 12 struct SetInfoTable 13 { 14 SetInfoTable(AppInstaller::SQLite::Connection& connection); 15 16 static std::string_view TableName(); 17 static std::string_view InstanceIdentifierColumn(); 18 19 // Creates the set info table. 20 void Create(); 21 22 // Adds the given configuration set to the table. 23 // Returns the row id of the added set. 24 AppInstaller::SQLite::rowid_t Add(const Configuration::ConfigurationSet& configurationSet); 25 26 // Updates the set with the target row id using the given set. 27 void Update(AppInstaller::SQLite::rowid_t target, const Configuration::ConfigurationSet& configurationSet); 28 29 // Removes the set with the target row id. 30 void Remove(AppInstaller::SQLite::rowid_t target); 31 32 // Gets all of the sets from the table. 33 std::vector<IConfigurationDatabase::ConfigurationSetPtr> GetAllSets(); 34 35 // Gets the row id of the set with the given instance identifier. 36 std::optional<AppInstaller::SQLite::rowid_t> GetSetRowId(const GUID& instanceIdentifier); 37 38 // Gets the set with the given instance identifier. 39 IConfigurationDatabase::ConfigurationSetPtr GetSet(const GUID& instanceIdentifier); 40 41 // Gets a set's first apply time. 42 std::chrono::system_clock::time_point GetSetFirstApply(const GUID& instanceIdentifier); 43 44 private: 45 AppInstaller::SQLite::Connection& m_connection; 46 }; 47 }