winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

IPinningIndex.h (1813B)


      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/Pin.h"
      7 
      8 namespace AppInstaller::Repository::Microsoft::Schema
      9 {
     10     struct IPinningIndex
     11     {
     12         virtual ~IPinningIndex() = default;
     13 
     14         // Gets the schema version that this index interface is built for.
     15         virtual SQLite::Version GetVersion() const = 0;
     16 
     17         // Creates all of the version dependent tables within the database.
     18         virtual void CreateTables(SQLite::Connection& connection) = 0;
     19 
     20         // Version 1.0
     21         // Adds a pin to the index.
     22         virtual SQLite::rowid_t AddPin(SQLite::Connection& connection, const Pinning::Pin& pin) = 0;
     23 
     24         // Updates an existing pin in the index.
     25         // The return value indicates whether the index was modified by the function.
     26         virtual std::pair<bool, SQLite::rowid_t> UpdatePin(SQLite::Connection& connection, const Pinning::Pin& pin) = 0;
     27 
     28         // Removes a pin from the index.
     29         virtual SQLite::rowid_t RemovePin(SQLite::Connection& connection, const Pinning::PinKey& pinKey) = 0;
     30 
     31         // Returns the current pin for a given package if it exists.
     32         virtual std::optional<Pinning::Pin> GetPin(SQLite::Connection& connection, const Pinning::PinKey& pinKey) = 0;
     33 
     34         // Returns a vector containing all the existing pins.
     35         virtual std::vector<Pinning::Pin> GetAllPins(SQLite::Connection& connection) = 0;
     36 
     37         // Removes all the pins from a given source, or from all sources if none is specified.
     38         // Returns a value indicating whether any pin was deleted.
     39         virtual bool ResetAllPins(SQLite::Connection& connection, std::string_view sourceId) = 0;
     40     };
     41 }