LCOV - code coverage report
Current view: top level - src/esys/repo/manifest - repository_manifest.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 59 59 100.0 %
Date: 2026-08-12 14:26:50 Functions: 20 21 95.2 %

          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         490 : Repository::Repository() = default;
      29             : 
      30          60 : Repository::Repository(const std::string &name, const std::string &path)
      31          60 :     : m_name(name)
      32          60 :     , m_path(path)
      33             : {
      34          60 : }
      35             : 
      36         550 : Repository::~Repository() = default;
      37             : 
      38         488 : void Repository::set_name(const std::string &name)
      39             : {
      40         488 :     m_name = name;
      41         488 : }
      42             : 
      43        1086 : const std::string &Repository::get_name() const
      44             : {
      45        1086 :     return m_name;
      46             : }
      47             : 
      48         488 : void Repository::set_path(const std::string &path)
      49             : {
      50         488 :     boost::filesystem::path gen_path = path;
      51             : 
      52        1464 :     m_path = gen_path.generic_path().string();
      53         488 : }
      54             : 
      55        2055 : const std::string &Repository::get_path() const
      56             : {
      57        2055 :     return m_path;
      58             : }
      59             : 
      60         138 : void Repository::set_revision(const std::string &revision)
      61             : {
      62         138 :     m_revision = revision;
      63         138 : }
      64             : 
      65         417 : const std::string &Repository::get_revision() const
      66             : {
      67         417 :     return m_revision;
      68             : }
      69             : 
      70         888 : void Repository::set_location(const std::string &location_str)
      71             : {
      72         888 :     m_location_str = location_str;
      73         888 : }
      74             : 
      75          20 : const std::string &Repository::get_location_str() const
      76             : {
      77          20 :     return m_location_str;
      78             : }
      79             : 
      80         835 : void Repository::set_location(Location *location)
      81             : {
      82         835 :     m_location = location;
      83         835 :     if (location == nullptr) return;
      84             : 
      85         835 :     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           4 : void Repository::set_sync_s(std::optional<bool> sync_s)
     112             : {
     113           4 :     m_sync_s = sync_s;
     114           4 : }
     115             : 
     116         244 : const std::optional<bool> &Repository::get_sync_s() const
     117             : {
     118         244 :     return m_sync_s;
     119             : }
     120             : 
     121           8 : bool Repository::operator==(const Repository &repository) const
     122             : {
     123           8 :     if (get_name() != repository.get_name()) return false;
     124           8 :     if (get_path() != repository.get_path()) return false;
     125           8 :     if (get_revision() != repository.get_revision()) return false;
     126           8 :     if (get_location_str() != repository.get_location_str()) return false;
     127           8 :     if (get_url() != repository.get_url()) return false;
     128          16 :     if (get_sync_s() != repository.get_sync_s()) return false;
     129             : 
     130           8 :     if (get_groups().size() != repository.get_groups().size()) return false;
     131             : 
     132          14 :     for (std::size_t idx = 0; idx < get_groups().size(); ++idx)
     133             :     {
     134           6 :         if (get_groups()[idx]->get_name() != repository.get_groups()[idx]->get_name()) return false;
     135             :     }
     136             : 
     137             :     return true;
     138             : }
     139             : 
     140           8 : bool Repository::operator!=(const Repository &repository) const
     141             : {
     142           8 :     return !operator==(repository);
     143             : }
     144             : 
     145             : } // namespace esys::repo::manifest

Generated by: LCOV version 1.14