0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
diagram_filter_factory.h
Go to the documentation of this file.
1/**
2 * @file src/common/model/filters/diagram_filter_factory.h
3 *
4 * Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#pragma once
19
20#include "diagram_filter.h"
22
27
34
41
45
47public:
50 , df{filter}
51 {
52 }
53
54 virtual ~diagram_filter_initializer() = default;
55
56 virtual void initialize() = 0;
57
58protected:
61};
62
64public:
66
68
69 void initialize() override;
70};
71
73public:
75
77
78 void initialize() override;
79
80private:
81 std::vector<std::unique_ptr<filter_visitor>> build(
82 filter_t filter_type, const config::filter &filter_config);
83
84 template <typename FT, typename T, typename... Args>
85 void add_filter(const filter_t &filter_type,
86 const std::vector<T> &filter_config,
87 std::vector<std::unique_ptr<filter_visitor>> &result, Args &&...args)
88 {
89 if (!filter_config.empty()) {
90 auto filter = std::make_unique<FT>(
91 filter_type, filter_config, std::forward<Args>(args)...);
92 filter->set_mode(filter_mode_t::advanced);
93 result.emplace_back(std::move(filter));
94 }
95 }
96};
97
98template <>
100 source_file_dependency_filter_t>(const filter_t &filter_type,
101 const std::vector<common::string_or_regex> &filter_config,
102 std::vector<std::unique_ptr<filter_visitor>> &result, relationship_t &&rt,
103 bool &&direction);
104
106public:
107 static std::unique_ptr<diagram_filter> create(
108 const common::model::diagram &d, const config::diagram &c)
109 {
110 auto filter = std::make_unique<diagram_filter>(
112
114 basic_diagram_filter_initializer init{c, *filter};
115 init.initialize();
116 }
117 else {
119 init.initialize();
120 }
121
122 return filter;
123 }
124};
125
126} // namespace clanguml::common::model