LCOV - code coverage report
Current view: top level - include/esys/repo/sharing - providerregistry.h (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 2 2 100.0 %
Date: 2026-11-07 22:18:26 Functions: 0 0 -

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/sharing/providerregistry.h
       3             :  * \brief Explicit shareable providers from root manifest (ADR-0039/0040)
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2026 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #pragma once
      19             : 
      20             : #include "esys/repo/esysrepo_defs.h"
      21             : #include "esys/repo/result.h"
      22             : #include "esys/repo/result_t.h"
      23             : #include "esys/repo/sharing/policy.h"
      24             : 
      25             : #include <map>
      26             : #include <memory>
      27             : #include <set>
      28             : #include <string>
      29             : #include <vector>
      30             : 
      31             : namespace esys::repo
      32             : {
      33             : class Manifest;
      34             : }
      35             : 
      36             : namespace esys::repo::manifest
      37             : {
      38             : class Repository;
      39             : }
      40             : 
      41             : namespace esys::repo::sharing
      42             : {
      43             : 
      44             : /*! \class Provider esys/repo/sharing/providerregistry.h
      45             :  * \brief One authorized shareable workspace project
      46             :  */
      47             : class ESYSREPO_API Provider
      48             : {
      49             : public:
      50           4 :     Provider() = default;
      51             : 
      52             :     void set_repository(std::shared_ptr<manifest::Repository> repo);
      53             :     std::shared_ptr<manifest::Repository> get_repository() const;
      54             : 
      55             :     void set_normalized_identity(const std::string &identity);
      56             :     const std::string &get_normalized_identity() const;
      57             : 
      58             :     void set_config(const Config &config);
      59             :     const Config &get_config() const;
      60             : 
      61             : private:
      62             :     std::shared_ptr<manifest::Repository> m_repository;
      63             :     std::string m_normalized_identity;
      64             :     Config m_config;
      65             : };
      66             : 
      67             : /*! \class ProviderRegistry esys/repo/sharing/providerregistry.h
      68             :  * \brief Build from root Manifest; match by normalized URL identity
      69             :  */
      70             : class ESYSREPO_API ProviderRegistry
      71             : {
      72             : public:
      73          29 :     ProviderRegistry() = default;
      74             : 
      75             :     //! Collect ``<sharing>`` providers; reject ``path="."``; fail on bad identity
      76             :     Result build(const Manifest &manifest);
      77             : 
      78             :     void clear();
      79             : 
      80             :     const std::vector<Provider> &get_providers() const;
      81             : 
      82             :     //! All normalized identities that are registered as shareable
      83             :     std::set<std::string> registered_identities() const;
      84             : 
      85             :     /*! Match dependency identity to exactly one provider.
      86             :      *  Zero → empty OK result (no match). Multiple → ``SHARING_AMBIGUOUS_PROVIDER``.
      87             :      */
      88             :     Result_t<std::shared_ptr<Provider>> match(const std::string &normalized_identity) const;
      89             : 
      90             : private:
      91             :     std::vector<Provider> m_providers;
      92             :     std::map<std::string, std::vector<std::size_t>> m_by_identity;
      93             : };
      94             : 
      95             : } // namespace esys::repo::sharing

Generated by: LCOV version 1.14