Line data Source code
1 : /*! 2 : * \file esys/repo/sharing/occurrence.h 3 : * \brief One discovered dependency occurrence (ADR-0042) 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 : 22 : #include <string> 23 : 24 : namespace esys::repo::sharing 25 : { 26 : 27 : enum class DeclarationKind 28 : { 29 : Unknown = 0, 30 : Submodule, 31 : LocalManifest, 32 : }; 33 : 34 : enum class MaterializationStatus 35 : { 36 : None = 0, //!< Not yet decided / unmatched keeps existing behavior 37 : Pending, //!< Matched; materialization not yet applied 38 : Worktree, //!< Linked worktree present (ADR-0041) 39 : Skipped, //!< Skipped (e.g. gitlink disagreement) 40 : Error, //!< Failed 41 : }; 42 : 43 : /*! \class Occurrence esys/repo/sharing/occurrence.h "esys/repo/sharing/occurrence.h" 44 : * \brief Normalized dependency observation for inventory / matching 45 : */ 46 : class ESYSREPO_API Occurrence 47 : { 48 : public: 49 9 : Occurrence() = default; 50 : 51 : void set_consumer_path(const std::string &path); 52 : const std::string &get_consumer_path() const; 53 : 54 : void set_dependency_path(const std::string &path); 55 : const std::string &get_dependency_path() const; 56 : 57 : void set_declaration_kind(DeclarationKind kind); 58 : DeclarationKind get_declaration_kind() const; 59 : 60 : void set_provenance(const std::string &text); 61 : const std::string &get_provenance() const; 62 : 63 : void set_original_url(const std::string &url); 64 : const std::string &get_original_url() const; 65 : 66 : void set_normalized_identity(const std::string &identity); 67 : const std::string &get_normalized_identity() const; 68 : 69 : void set_required_revision(const std::string &rev); 70 : const std::string &get_required_revision() const; 71 : 72 : void set_required_commit(const std::string &sha); 73 : const std::string &get_required_commit() const; 74 : 75 : void set_matched_provider_path(const std::string &path); 76 : const std::string &get_matched_provider_path() const; 77 : 78 : void set_materialization_status(MaterializationStatus status); 79 : MaterializationStatus get_materialization_status() const; 80 : 81 : void set_error(const std::string &text); 82 : const std::string &get_error() const; 83 : 84 : //! Key for inventory replace: consumer_path + '\\0' + dependency_path 85 : std::string scope_key() const; 86 : 87 : private: 88 : std::string m_consumer_path; 89 : std::string m_dependency_path; 90 : DeclarationKind m_declaration_kind = DeclarationKind::Unknown; 91 : std::string m_provenance; 92 : std::string m_original_url; 93 : std::string m_normalized_identity; 94 : std::string m_required_revision; 95 : std::string m_required_commit; 96 : std::string m_matched_provider_path; 97 : MaterializationStatus m_materialization_status = MaterializationStatus::None; 98 : std::string m_error; 99 : }; 100 : 101 : } // namespace esys::repo::sharing