ORE Studio 0.0.4
Loading...
Searching...
No Matches
ore_hierarchy_builder.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_ORE_HIERARCHY_ORE_HIERARCHY_BUILDER_HPP
21#define ORES_ORE_HIERARCHY_ORE_HIERARCHY_BUILDER_HPP
22
23#include <filesystem>
24#include <optional>
25#include <string>
26#include <unordered_set>
27#include <vector>
28#include "ores.ore/hierarchy/import_node.hpp"
29#include "ores.logging/make_logger.hpp"
30
31namespace ores::ore::hierarchy {
32
44private:
45 inline static std::string_view logger_name =
46 "ores.ore.hierarchy.ore_hierarchy_builder";
47
48 [[nodiscard]] static auto& lg() {
49 using namespace ores::logging;
50 static auto instance = make_logger(logger_name);
51 return instance;
52 }
53
54public:
62 explicit ore_hierarchy_builder(
63 std::vector<std::filesystem::path> portfolio_files,
64 std::filesystem::path root,
65 std::unordered_set<std::string> exclusions = {});
66
76 std::vector<import_node> build();
77
78private:
79 std::vector<std::string> filtered_components(
80 const std::filesystem::path& relative) const;
81
82 std::size_t find_or_add_portfolio(
83 const std::string& name,
84 std::optional<std::size_t> parent,
85 std::vector<import_node>& nodes) const;
86
87 std::vector<std::filesystem::path> portfolio_files_;
88 std::filesystem::path root_;
89 std::unordered_set<std::string> exclusions_;
90};
91
92}
93
94#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Builds a flat list of portfolio/book import nodes from a set of portfolio XML file paths.
Definition ore_hierarchy_builder.hpp:43
std::vector< import_node > build()
Builds the hierarchy nodes.
Definition ore_hierarchy_builder.cpp:71