IPortableIndex.h (1893B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <winget/SQLiteWrapper.h> 5 #include <winget/SQLiteVersion.h> 6 #include "winget/PortableFileEntry.h" 7 #include <filesystem> 8 9 namespace AppInstaller::Repository::Microsoft::Schema 10 { 11 struct IPortableIndex 12 { 13 virtual ~IPortableIndex() = default; 14 15 // Gets the schema version that this index interface is built for. 16 virtual SQLite::Version GetVersion() const = 0; 17 18 // Creates all of the version dependent tables within the database. 19 virtual void CreateTable(SQLite::Connection& connection) = 0; 20 21 // Version 1.0 22 // Adds a portable file to the index. 23 virtual SQLite::rowid_t AddPortableFile(SQLite::Connection& connection, const Portable::PortableFileEntry& file) = 0; 24 25 // Removes a portable file from the index. 26 virtual SQLite::rowid_t RemovePortableFile(SQLite::Connection& connection, const Portable::PortableFileEntry& file) = 0; 27 28 // Updates the file with matching FilePath in the index. 29 // The return value indicates whether the index was modified by the function. 30 virtual std::pair<bool, SQLite::rowid_t> UpdatePortableFile(SQLite::Connection& connection, const Portable::PortableFileEntry& file) = 0; 31 32 // Returns a bool value indicating whether the PortableFile already exists in the index. 33 virtual bool Exists(SQLite::Connection& connection, const Portable::PortableFileEntry& file) = 0; 34 35 // Returns a bool value indicating whether the index is empty. 36 virtual bool IsEmpty(SQLite::Connection& connection) = 0; 37 38 // Returns a vector including all the portable files recorded in the index. 39 virtual std::vector<Portable::PortableFileEntry> GetAllPortableFiles(SQLite::Connection& connection) = 0; 40 }; 41 }