winget-cli

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

RestSource.h (1907B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include "ISource.h"
      5 #include "RestClient.h"
      6 
      7 namespace AppInstaller::Repository::Rest
      8 {
      9     // A source that holds a RestSource.
     10     struct RestSource : public std::enable_shared_from_this<RestSource>, public ISource
     11     {
     12         static constexpr ISourceType SourceType = ISourceType::RestSource;
     13 
     14         RestSource(const SourceDetails& details, SourceInformation information, RestClient&& restClient);
     15 
     16         RestSource(const RestSource&) = delete;
     17         RestSource& operator=(const RestSource&) = delete;
     18 
     19         RestSource(RestSource&&) = default;
     20         RestSource& operator=(RestSource&&) = default;
     21 
     22         ~RestSource() = default;
     23 
     24         // Gets the source's identifier; a unique identifier independent of the name
     25         // that will not change between a remove/add or between additional adds.
     26         // Must be suitable for filesystem names.
     27         const std::string& GetIdentifier() const override;
     28 
     29         // Get the source's details.
     30         const SourceDetails& GetDetails() const override;
     31 
     32         SourceInformation GetInformation() const override;
     33 
     34         bool QueryFeatureFlag(SourceFeatureFlag flag) const override;
     35 
     36         // Execute a search on the source.
     37         SearchResult Search(const SearchRequest& request) const override;
     38 
     39         // Casts to the requested type.
     40         void* CastTo(ISourceType type) override;
     41 
     42         // Gets the rest client.
     43         const RestClient& GetRestClient() const;
     44 
     45         // Determines if the other source refers to the same as this.
     46         bool IsSame(const RestSource* other) const;
     47 
     48     private:
     49         std::shared_ptr<RestSource> NonConstSharedFromThis() const;
     50 
     51         SourceDetails m_details;
     52         SourceInformation m_information;
     53         RestClient m_restClient;
     54     };
     55 }