LCOV - code coverage report
Current view: top level - src/esys/repo/manifest - directory_manifest.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 46 59 78.0 %
Date: 2026-08-01 10:43:40 Functions: 18 21 85.7 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/manifest/directory.h
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2023 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/directory.h"
      20             : 
      21             : namespace esys::repo::manifest
      22             : {
      23             : 
      24          87 : Directory::Item::Item() = default;
      25             : 
      26          87 : Directory::Item::~Item() = default;
      27             : 
      28          87 : void Directory::Item::set_name(const std::string &name)
      29             : {
      30          87 :     m_name = name;
      31          87 : }
      32             : 
      33          72 : const std::string &Directory::Item::get_name() const
      34             : {
      35          72 :     return m_name;
      36             : }
      37             : 
      38          87 : void Directory::Item::set_url_ssh(const std::string &url_ssh)
      39             : {
      40          87 :     m_url_ssh = url_ssh;
      41          87 : }
      42             : 
      43          35 : const std::string &Directory::Item::get_url_ssh() const
      44             : {
      45          35 :     return m_url_ssh;
      46             : }
      47             : 
      48          87 : void Directory::Item::set_url_https(const std::string &url_https)
      49             : {
      50          87 :     m_url_https = url_https;
      51          87 : }
      52             : 
      53          40 : const std::string &Directory::Item::get_url_https() const
      54             : {
      55          40 :     return m_url_https;
      56             : }
      57             : 
      58          10 : bool Directory::Item::operator==(const Item &other) const
      59             : {
      60          10 :     if (get_name() != other.get_name()) return false;
      61          10 :     if (get_url_ssh() != other.get_url_ssh()) return false;
      62          10 :     if (get_url_https() != other.get_url_https()) return false;
      63             :     return true;
      64             : }
      65             : 
      66          10 : bool Directory::Item::operator!=(const Item &other) const
      67             : {
      68          10 :     return !operator==(other);
      69             : }
      70             : 
      71           5 : Directory::Directory() = default;
      72             : 
      73           5 : Directory::~Directory() = default;
      74             : 
      75           7 : void Directory::set_name(const std::string &name)
      76             : {
      77           7 :     m_name = name;
      78           7 : }
      79             : 
      80          10 : const std::string &Directory::get_name() const
      81             : {
      82          10 :     return m_name;
      83             : }
      84             : 
      85           0 : void Directory::add_item(const std::string &name, const std::string &url_ssh, const std::string &url_https)
      86             : {
      87           0 :     auto item = std::make_shared<Item>();
      88           0 :     item->set_name(name);
      89           0 :     item->set_url_ssh(url_ssh);
      90           0 :     item->set_url_https(url_https);
      91             : 
      92           0 :     add_item(item);
      93           0 : }
      94             : 
      95          27 : void Directory::add_item(std::shared_ptr<Item> item)
      96             : {
      97          27 :     m_items.push_back(item);
      98          27 :     m_map_items[item->get_name()] = item;
      99          27 : }
     100             : 
     101          40 : const std::vector<std::shared_ptr<Directory::Item>> &Directory::get_items() const
     102             : {
     103          40 :     return m_items;
     104             : }
     105             : 
     106           0 : std::shared_ptr<Directory::Item> Directory::find(const std::string &name) const
     107             : {
     108           0 :     auto it = m_map_items.find(name);
     109           0 :     if (it == m_map_items.end()) return nullptr;
     110           0 :     return it->second;
     111             : }
     112             : 
     113           2 : void Directory::clear()
     114             : {
     115           2 :     set_name("");
     116             : 
     117           2 :     m_items.clear();
     118           2 :     m_map_items.clear();
     119           2 : }
     120             : 
     121           4 : bool Directory::operator==(const Directory &other) const
     122             : {
     123           4 :     if (get_name() != other.get_name()) return false;
     124             : 
     125           2 :     if (get_items().size() != other.get_items().size()) return false;
     126             : 
     127          12 :     for (auto idx = 0; idx < get_items().size(); ++idx)
     128             :     {
     129          10 :         if (*get_items()[idx] != *other.get_items()[idx]) return false;
     130             :     }
     131             :     return true;
     132             : }
     133             : 
     134           0 : bool Directory::operator!=(const Directory &other) const
     135             : {
     136           0 :     return !operator==(other);
     137             : }
     138             : 
     139             : } // namespace esys::repo::manifest

Generated by: LCOV version 1.14