Line data Source code
1 : /*! 2 : * \file esys/repo/manifest/repository_manifest.cpp 3 : * \brief 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2020-2021 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 : #include "esys/repo/esysrepo_prec.h" 19 : #include "esys/repo/manifest/repository.h" 20 : #include "esys/repo/manifest/group.h" 21 : #include "esys/repo/manifest/location.h" 22 : 23 : #include <boost/filesystem.hpp> 24 : 25 : namespace esys::repo::manifest 26 : { 27 : 28 480 : Repository::Repository() = default; 29 : 30 55 : Repository::Repository(const std::string &name, const std::string &path) 31 55 : : m_name(name) 32 55 : , m_path(path) 33 : { 34 55 : } 35 : 36 535 : Repository::~Repository() = default; 37 : 38 479 : void Repository::set_name(const std::string &name) 39 : { 40 479 : m_name = name; 41 479 : } 42 : 43 1062 : const std::string &Repository::get_name() const 44 : { 45 1062 : return m_name; 46 : } 47 : 48 479 : void Repository::set_path(const std::string &path) 49 : { 50 479 : boost::filesystem::path gen_path = path; 51 : 52 1437 : m_path = gen_path.generic_path().string(); 53 479 : } 54 : 55 1808 : const std::string &Repository::get_path() const 56 : { 57 1808 : return m_path; 58 : } 59 : 60 136 : void Repository::set_revision(const std::string &revision) 61 : { 62 136 : m_revision = revision; 63 136 : } 64 : 65 339 : const std::string &Repository::get_revision() const 66 : { 67 339 : return m_revision; 68 : } 69 : 70 866 : void Repository::set_location(const std::string &location_str) 71 : { 72 866 : m_location_str = location_str; 73 866 : } 74 : 75 20 : const std::string &Repository::get_location_str() const 76 : { 77 20 : return m_location_str; 78 : } 79 : 80 813 : void Repository::set_location(Location *location) 81 : { 82 813 : m_location = location; 83 813 : if (location == nullptr) return; 84 : 85 813 : set_location(location->get_name()); 86 : } 87 : 88 201 : Location *Repository::get_location() const 89 : { 90 201 : return m_location; 91 : } 92 : 93 19 : std::string Repository::get_url() const 94 : { 95 19 : if (get_location() == nullptr) return ""; 96 : 97 19 : std::string url = get_location()->get_address() + "/" + get_name(); 98 38 : return url; 99 19 : } 100 : 101 116 : std::vector<Group *> &Repository::get_groups() 102 : { 103 116 : return m_groups; 104 : } 105 : 106 42 : const std::vector<Group *> &Repository::get_groups() const 107 : { 108 42 : return m_groups; 109 : } 110 : 111 8 : bool Repository::operator==(const Repository &repository) const 112 : { 113 8 : if (get_name() != repository.get_name()) return false; 114 8 : if (get_path() != repository.get_path()) return false; 115 8 : if (get_revision() != repository.get_revision()) return false; 116 8 : if (get_location_str() != repository.get_location_str()) return false; 117 8 : if (get_url() != repository.get_url()) return false; 118 : 119 8 : if (get_groups().size() != repository.get_groups().size()) return false; 120 : 121 14 : for (std::size_t idx = 0; idx < get_groups().size(); ++idx) 122 : { 123 6 : if (get_groups()[idx]->get_name() != repository.get_groups()[idx]->get_name()) return false; 124 : } 125 : 126 : return true; 127 : } 128 : 129 8 : bool Repository::operator!=(const Repository &repository) const 130 : { 131 8 : return !operator==(repository); 132 : } 133 : 134 : } // namespace esys::repo::manifest