Skip to content

Commit 0726f39

Browse files
committed
<refactor>[SBG]: deleted remaining factories usages
1 parent 1e5add5 commit 0726f39

15 files changed

Lines changed: 108 additions & 148 deletions

algorithms/cc/cc.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
******************************************************************************/
1919

2020
#include "algorithms/cc/cc.hpp"
21-
#include "sbg/pwmap_fact.hpp"
2221
#include "sbg/set.hpp"
2322
#include "util/logger.hpp"
2423
#include "util/time_profiler.hpp"
@@ -37,8 +36,8 @@ PWMap connectedComponents(const SBG& sbg)
3736

3837
Set V = sbg.V();
3938
if (!V.isEmpty()) {
40-
PWMap rmap = PWMAP_FACT.createPWMap(V);
41-
PWMap old_rmap = PWMAP_FACT.createPWMap();
39+
PWMap rmap{V};
40+
PWMap old_rmap;
4241

4342
if (sbg.E().isEmpty()) {
4443
return rmap;
@@ -70,7 +69,7 @@ PWMap connectedComponents(const SBG& sbg)
7069
return rmap;
7170
}
7271

73-
return PWMAP_FACT.createPWMap();
72+
return PWMap{};
7473
}
7574

7675
} // namespace LIB

algorithms/misc/causalization_builders.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919

2020
#include "algorithms/misc/causalization_builders.hpp"
2121
#include "sbg/bipartite_sbg.hpp"
22-
#include "sbg/set.hpp"
23-
#include "sbg/set_fact.hpp"
24-
#include "sbg/pw_map.hpp"
25-
#include "sbg/pwmap_fact.hpp"
2622
#include "sbg/map.hpp"
23+
#include "sbg/pw_map.hpp"
24+
#include "sbg/set.hpp"
2725
#include "util/time_profiler.hpp"
2826

2927
#include <tuple>
@@ -43,7 +41,7 @@ std::tuple<SBG::LIB::Set, SBG::LIB::PWMap> buildSCCVertices(
4341
M.compact();
4442
SBG::LIB::Set V = M;
4543
SBG::LIB::PWMap auxVmap = data.bsbg().Emap().restrict(M);
46-
SBG::LIB::PWMap Vmap = SBG::LIB::PWMAP_FACT.createPWMap();
44+
SBG::LIB::PWMap Vmap;
4745
for (const SBG::LIB::Map& m : auxVmap) {
4846
SBG::LIB::Set domain = m.domain();
4947
domain.compact();
@@ -99,21 +97,21 @@ void partitionEmap(SBG::LIB::DirectedSBG& dsbg)
9997

10098
std::size_t arity = V.arity();
10199
SBG::LIB::NAT j = 1;
102-
SBG::LIB::PWMap partitioned_Emap = SBG::LIB::PWMAP_FACT.createPWMap();
100+
SBG::LIB::PWMap partitioned_Emap;
103101
dsbg.foreachSetEdge([&](const SBG::LIB::MD_NAT& SE)
104102
{
105-
SBG::LIB::Set E = Emap.preImage(SBG::LIB::SET_FACT.createSet(SE));
103+
SBG::LIB::Set E = Emap.preImage(SBG::LIB::Set{SE});
106104
SBG::LIB::Set SV_starts = Vmap.image(mapB.image(E));
107105
SBG::LIB::Set SV_ends = Vmap.image(mapD.image(E));
108106
if (SV_starts.cardinal()*SV_ends.cardinal() > 1) {
109107
SBG::LIB::Set remaining1 = SV_starts;
110108
while (!remaining1.isEmpty()) {
111-
SBG::LIB::Set SV1 = SBG::LIB::SET_FACT.createSet(remaining1.minElem());
109+
SBG::LIB::Set SV1 = SBG::LIB::Set{remaining1.minElem()};
112110
SBG::LIB::Set V1 = Vmap.preImage(SV1);
113111

114112
SBG::LIB::Set remaining2 = SV_ends;
115113
while (!remaining2.isEmpty()) {
116-
SBG::LIB::Set SV2 = SBG::LIB::SET_FACT.createSet(remaining2.minElem());
114+
SBG::LIB::Set SV2 = SBG::LIB::Set{remaining2.minElem()};
117115
SBG::LIB::Set V2 = Vmap.preImage(SV2);
118116

119117
SBG::LIB::Set edges_V1_V2 = mapB.preImage(V1).intersection(
@@ -140,13 +138,13 @@ SBG::LIB::DirectedSBG buildLoopDetectionSBG(const SBG::LIB::MatchData& data)
140138
{
141139
SBG::Util::Internal::TimeProfiler profiler{"SBG Loop Detection builder: "};
142140

143-
SBG::LIB::Set V = SBG::LIB::SET_FACT.createSet();
144-
SBG::LIB::PWMap Vmap = SBG::LIB::PWMAP_FACT.createPWMap();
141+
SBG::LIB::Set V;
142+
SBG::LIB::PWMap Vmap;
145143
std::tie(V, Vmap) = buildSCCVertices(data);
146144

147-
SBG::LIB::PWMap mapB = SBG::LIB::PWMAP_FACT.createPWMap();
148-
SBG::LIB::PWMap mapD = SBG::LIB::PWMAP_FACT.createPWMap();
149-
SBG::LIB::PWMap Emap = SBG::LIB::PWMAP_FACT.createPWMap();
145+
SBG::LIB::PWMap mapB;
146+
SBG::LIB::PWMap mapD;
147+
SBG::LIB::PWMap Emap;
150148
std::tie(mapB, mapD, Emap) = buildSCCEdges(data, Vmap);
151149

152150
SBG::LIB::DirectedSBG dsbg{V, Vmap, mapB, mapD, Emap};

eval/eval_exec.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
1818
******************************************************************************/
1919

20-
#include "algorithms/matching/matching_fact.hpp"
21-
#include "algorithms/mfvs/mfvs_fact.hpp"
22-
#include "algorithms/scc/scc_fact.hpp"
23-
#include "algorithms/sorting/topological/ts_fact.hpp"
20+
#include "algorithms/matching/matching_impl.hpp"
21+
#include "algorithms/mfvs/mfvs_impl.hpp"
22+
#include "algorithms/scc/scc_impl.hpp"
23+
#include "algorithms/sorting/topological/ts_impl.hpp"
2424
#include "eval/eval_exec.hpp"
2525
#include "eval/file_evaluator.hpp"
2626
#include "eval/input_translator.hpp"
2727
#include "eval/file_evaluator.hpp"
2828
#include "eval/visitors/autom_impl_visitor.hpp"
2929
#include "parser/file_parser.hpp"
30-
#include "sbg/set_fact.hpp"
31-
#include "sbg/pwmap_fact.hpp"
30+
#include "sbg/pwmap_impl.hpp"
31+
#include "sbg/set_impl.hpp"
3232
#include "util/debug.hpp"
3333
#include "util/logger.hpp"
3434
#include "util/time_profiler.hpp"
@@ -51,13 +51,13 @@ void printHeader(Util::prog_opts::variables_map vm)
5151
{
5252
if (vm.count("debug")) {
5353
std::cout << "-----------------------------------\n";
54-
std::cout << "Set implementation: " << LIB::SET_FACT.kind() << "\n";
55-
std::cout << "PWMap implementation: " << LIB::PWMAP_FACT.kind() << "\n";
54+
std::cout << "Set implementation: " << LIB::SET_IMPL.kind() << "\n";
55+
std::cout << "PWMap implementation: " << LIB::PWMAP_IMPL.kind() << "\n";
5656
std::cout << "-----------------------------------\n";
57-
std::cout << "Matching algorithm: " << LIB::MATCH_FACT.kind() << "\n";
58-
std::cout << "SCC algorithm: " << LIB::SCC_FACT.kind() << "\n";
59-
std::cout << "MFVS algorithm: " << LIB::MFVS_FACT.kind() << "\n";
60-
std::cout << "Topological sorting algorithm: " << LIB::TS_FACT.kind()
57+
std::cout << "Matching algorithm: " << LIB::MATCH_IMPL.kind() << "\n";
58+
std::cout << "SCC algorithm: " << LIB::SCC_IMPL.kind() << "\n";
59+
std::cout << "MFVS algorithm: " << LIB::MFVS_IMPL.kind() << "\n";
60+
std::cout << "Topological sorting algorithm: " << LIB::TS_IMPL.kind()
6161
<< "\n";
6262
}
6363
std::cout << "-----------------------------------\n";

eval/user_impl_map.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
1818
******************************************************************************/
1919

20-
#include "algorithms/scc/scc_fact.hpp"
21-
#include "algorithms/mfvs/mfvs_fact.hpp"
2220
#include "eval/user_impl_map.hpp"
2321
#include "sbg/pw_map.hpp"
24-
#include "sbg/pwmap_fact.hpp"
2522
#include "sbg/set.hpp"
26-
#include "sbg/set_fact.hpp"
2723
#include "util/debug.hpp"
2824

2925
namespace SBG {
@@ -143,21 +139,21 @@ void setSetFactory(int set_impl)
143139
{
144140
LIB::SetKind set_fact = std::get<LIB::SetKind>(detail::IMPL_MAP.getFactory(
145141
"set", set_impl));
146-
LIB::SET_FACT.set_set_fact(set_fact);
142+
LIB::SET_IMPL.set_set_fact(set_fact);
147143
}
148144

149145
void setPWFactory(int pw_impl)
150146
{
151147
LIB::PWMapKind pwmap_fact = std::get<LIB::PWMapKind>(
152148
detail::IMPL_MAP.getFactory("pwmap", pw_impl));
153-
LIB::PWMAP_FACT.set_pwmap_fact(pwmap_fact);
149+
LIB::PWMAP_IMPL.set_pwmap_fact(pwmap_fact);
154150
}
155151

156152
void setSCCFactory(int scc_impl)
157153
{
158154
LIB::SCCKind scc_fact = std::get<LIB::SCCKind>(
159155
detail::IMPL_MAP.getFactory("scc", scc_impl));
160-
LIB::SCC_FACT.set_scc_fact(scc_fact);
156+
LIB::SCC_IMPL.set_scc_fact(scc_fact);
161157

162158
return;
163159
}
@@ -166,7 +162,7 @@ void setMFVSFactory(int mfvs_impl)
166162
{
167163
LIB::MFVSKind mfvs_fact = std::get<LIB::MFVSKind>(
168164
detail::IMPL_MAP.getFactory("mfvs", mfvs_impl));
169-
LIB::MFVS_FACT.set_mfvs_fact(mfvs_fact);
165+
LIB::MFVS_IMPL.set_mfvs_fact(mfvs_fact);
170166

171167
return;
172168
}

eval/user_impl_map.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
#ifndef SBGRAPH_EVAL_USER_IMPL_MAP_HPP_
3030
#define SBGRAPH_EVAL_USER_IMPL_MAP_HPP_
3131

32-
#include "algorithms/mfvs/min_feedback_vertex_set.hpp"
33-
#include "algorithms/matching/matching.hpp"
34-
#include "algorithms/scc/scc.hpp"
35-
#include "algorithms/sorting/topological/topological_sorting.hpp"
32+
#include "algorithms/matching/matching_impl.hpp"
33+
#include "algorithms/mfvs/mfvs_impl.hpp"
34+
#include "algorithms/scc/scc_impl.hpp"
35+
#include "algorithms/sorting/topological/ts_impl.hpp"
3636
#include "sbg/pw_map.hpp"
37+
#include "sbg/pwmap_impl.hpp"
3738
#include "sbg/set.hpp"
39+
#include "sbg/set_impl.hpp"
3840

3941
#include <functional>
4042
#include <unordered_map>

eval/visitors/autom_impl_visitor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "eval/visitors/autom_impl_visitor.hpp"
2222
#include "eval/visitors/stm_evaluator.hpp"
2323
#include "eval/visitors/set_impl_visitor.hpp"
24-
#include "sbg/pwmap_fact.hpp"
2524

2625
namespace SBG {
2726

eval/visitors/expr_evaluator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "eval/visitors/linear_expr_evaluator.hpp"
2323
#include "eval/visitors/nat_evaluator.hpp"
2424
#include "eval/visitors/rational_evaluator.hpp"
25-
#include "sbg/pwmap_fact.hpp"
26-
#include "sbg/set_fact.hpp"
2725
#include "util/debug.hpp"
2826

2927
namespace SBG {
@@ -143,12 +141,12 @@ ExprBaseType ExprEvaluator::operator()(AST::Interval v) const
143141
LIB::NAT s = boost::apply_visitor(nat_evaluator, v.step());
144142
LIB::NAT e = boost::apply_visitor(nat_evaluator, v.end());
145143

146-
return LIB::SET_FACT.createSet(b, s, e);
144+
return LIB::Set{b, s, e};
147145
}
148146

149147
ExprBaseType ExprEvaluator::operator()(AST::MultiDimInter v) const
150148
{
151-
LIB::Set result = LIB::SET_FACT.createSet();
149+
LIB::Set result;
152150

153151
int i = 0;
154152
for (const AST::Expr& e : v.intervals()) {
@@ -171,7 +169,7 @@ ExprBaseType ExprEvaluator::operator()(AST::MultiDimInter v) const
171169

172170
ExprBaseType ExprEvaluator::operator()(AST::Set v) const
173171
{
174-
LIB::Set result = LIB::SET_FACT.createSet();
172+
LIB::Set result;
175173

176174
for (const AST::Expr& e : v.pieces()) {
177175
LIB::Set jth_element = eval<LIB::Set>(*this, e, "Set");
@@ -228,7 +226,7 @@ ExprBaseType ExprEvaluator::operator()(AST::LinearMap v) const
228226

229227
ExprBaseType ExprEvaluator::operator()(AST::PWLMap v) const
230228
{
231-
LIB::PWMap result = LIB::PWMAP_FACT.createPWMap();
229+
LIB::PWMap result;
232230

233231
for (const AST::Expr& e : v.maps()) {
234232
result.insert(eval<LIB::Map>(*this, e, "Map"));

eval/visitors/func_evaluator.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@
1919

2020
#include "eval/visitors/func_evaluator.hpp"
2121
#include "algorithms/cc/cc.hpp"
22-
#include "algorithms/mfvs/min_feedback_vertex_set.hpp"
23-
#include "algorithms/mfvs/mfvs_fact.hpp"
2422
#include "algorithms/matching/matching.hpp"
25-
#include "algorithms/matching/matching_fact.hpp"
23+
#include "algorithms/mfvs/min_feedback_vertex_set.hpp"
2624
#include "algorithms/misc/causalization_builders.hpp"
2725
#include "algorithms/misc/causalization_json.hpp"
2826
#include "algorithms/scc/scc.hpp"
29-
#include "algorithms/scc/scc_fact.hpp"
3027
#include "algorithms/sorting/topological/topological_sorting.hpp"
31-
#include "algorithms/sorting/topological/ts_fact.hpp"
3228
#include "eval/base_type.hpp"
3329
#include "sbg/bipartite_sbg.hpp"
3430
#include "sbg/expression.hpp"
@@ -39,7 +35,6 @@
3935
#include "sbg/rational.hpp"
4036
#include "sbg/set.hpp"
4137
#include "sbg/pw_map.hpp"
42-
#include "sbg/pwmap_fact.hpp"
4338
#include "util/debug.hpp"
4439
#include "util/defs.hpp"
4540

@@ -627,7 +622,7 @@ ExprBaseType BuiltInFunctions::matchingEvaluator(const EBTList& args)
627622
Util::ERROR_UNLESS(args.size() == 2
628623
, "matchingEvaluator: wrong number of arguments\n");
629624

630-
LIB::Matching match_impl = LIB::MATCH_FACT.createMatchAlgorithm();
625+
LIB::Matching match_impl;
631626
const auto matching_evaluator = Util::Overload {
632627
[&match_impl](LIB::BipartiteSBG a, LIB::NAT b) {
633628
return ExprBaseType{match_impl.calculate(copy(b, a))};
@@ -649,7 +644,7 @@ ExprBaseType BuiltInFunctions::sccEvaluator(const EBTList& args)
649644
Util::ERROR_UNLESS(args.size() == 1
650645
, "sccEvaluator: wrong number of arguments\n");
651646

652-
LIB::SCC scc_impl = LIB::SCC_FACT.createSCCAlgorithm();
647+
LIB::SCC scc_impl;
653648
const auto scc_evaluator = Util::Overload {
654649
[&scc_impl](LIB::DirectedSBG a) {
655650
return ExprBaseType{scc_impl.calculate(a).rmap()};
@@ -671,7 +666,7 @@ ExprBaseType BuiltInFunctions::matchSCCEvaluator(const EBTList& args)
671666

672667
const LIB::MatchData match_result = std::get<LIB::MatchData>(match_base_type);
673668
LIB::DirectedSBG dsbg = misc::buildLoopDetectionSBG(match_result);
674-
LIB::SCC scc_impl = LIB::SCC_FACT.createSCCAlgorithm();
669+
LIB::SCC scc_impl;
675670
LIB::SCCData scc_result = scc_impl.calculate(dsbg);
676671

677672
return ExprBaseType{scc_result.rmap()};
@@ -682,7 +677,7 @@ ExprBaseType BuiltInFunctions::mfvsEvaluator(const EBTList& args)
682677
Util::ERROR_UNLESS(args.size() == 1
683678
, "mfvsEvaluator: wrong number of arguments\n");
684679

685-
LIB::MinFeedbackVertexSet mfvs_impl = LIB::MFVS_FACT.createMFVSAlgorithm();
680+
LIB::MinFeedbackVertexSet mfvs_impl;
686681
const auto mfvs_evaluator = Util::Overload {
687682
[&mfvs_impl](LIB::DirectedSBG a) {
688683
return ExprBaseType{mfvs_impl.calculate(a)};
@@ -705,11 +700,11 @@ ExprBaseType BuiltInFunctions::matchSCCMFVSEvaluator(const EBTList& args)
705700

706701
const LIB::MatchData match_result = std::get<LIB::MatchData>(match_base_type);
707702
LIB::DirectedSBG dsbg = misc::buildLoopDetectionSBG(match_result);
708-
LIB::SCC scc_impl = LIB::SCC_FACT.createSCCAlgorithm();
703+
LIB::SCC scc_impl;
709704
LIB::SCCData scc_result = scc_impl.calculate(dsbg);
710705

711706
dsbg = misc::buildTearingSBG(scc_result);
712-
LIB::MinFeedbackVertexSet mfvs_impl = LIB::MFVS_FACT.createMFVSAlgorithm();
707+
LIB::MinFeedbackVertexSet mfvs_impl;
713708
return ExprBaseType{mfvs_impl.calculate(dsbg)};
714709
}
715710

@@ -718,10 +713,10 @@ ExprBaseType BuiltInFunctions::topoSortEvaluator(const EBTList& args)
718713
Util::ERROR_UNLESS(args.size() == 1
719714
, "topoSortEvaluator: wrong number of arguments\n");
720715

721-
LIB::TopologicalSorting ts_impl = LIB::TS_FACT.createTSAlgorithm();
716+
LIB::TopologicalSorting ts_impl;
722717
const auto ts_evaluator = Util::Overload {
723718
[&ts_impl](LIB::DirectedSBG a) {
724-
return ExprBaseType{ts_impl.calculate(a, LIB::PWMAP_FACT.createPWMap())};
719+
return ExprBaseType{ts_impl.calculate(a, SBG::LIB::PWMap{})};
725720
},
726721
[](auto a) {
727722
Util::ERROR("topoSortEvaluator: wrong argument ", a, " for sort\n");
@@ -740,15 +735,15 @@ ExprBaseType BuiltInFunctions::causalizationEvaluator(const EBTList& args)
740735

741736
const LIB::MatchData match_result = std::get<LIB::MatchData>(match_base_type);
742737
LIB::DirectedSBG dsbg = misc::buildLoopDetectionSBG(match_result);
743-
LIB::SCC scc_impl = LIB::SCC_FACT.createSCCAlgorithm();
738+
LIB::SCC scc_impl;
744739
LIB::SCCData scc_result = scc_impl.calculate(dsbg);
745740

746741
dsbg = misc::buildTearingSBG(scc_result);
747-
LIB::MinFeedbackVertexSet mfvs_impl = LIB::MFVS_FACT.createMFVSAlgorithm();
742+
LIB::MinFeedbackVertexSet mfvs_impl;
748743
LIB::Set mfvs_result = mfvs_impl.calculate(dsbg);
749744

750745
dsbg = misc::buildVerticalSortingSBG(scc_result, mfvs_result);
751-
LIB::TopologicalSorting ts_impl = LIB::TS_FACT.createTSAlgorithm();
746+
LIB::TopologicalSorting ts_impl;
752747
LIB::PWMap ts_result = ts_impl.calculate(dsbg, scc_result.rmap());
753748

754749
misc::CausalizationResult causalized{match_result.M(), scc_result.rmap()

test/performance/bm_exec.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
******************************************************************************/
1919

2020
#include "test/performance/bm_exec.hpp"
21-
#include "algorithms/matching/matching_fact.hpp"
22-
#include "algorithms/scc/scc_fact.hpp"
21+
#include "algorithms/matching/matching_impl.hpp"
22+
#include "algorithms/scc/scc_impl.hpp"
2323
#include "eval/user_impl_map.hpp"
24-
#include "sbg/pwmap_fact.hpp"
25-
#include "sbg/set_fact.hpp"
24+
#include "sbg/pwmap_impl.hpp"
25+
#include "sbg/set_impl.hpp"
2626
#include "test/performance/boost/boost_bm.hpp"
2727
#include "test/performance/matching_bm.hpp"
2828
#include "test/performance/pwmap_bm.hpp"
@@ -52,11 +52,11 @@ void printHeader(Util::prog_opts::variables_map vm)
5252
{
5353
if (vm.count("debug")) {
5454
std::cout << "-----------------------------------\n";
55-
std::cout << "Set implementation: " << LIB::SET_FACT.kind() << "\n";
56-
std::cout << "PWMap implementation: " << LIB::PWMAP_FACT.kind() << "\n";
55+
std::cout << "Set implementation: " << LIB::SET_IMPL.kind() << "\n";
56+
std::cout << "PWMap implementation: " << LIB::PWMAP_IMPL.kind() << "\n";
5757
std::cout << "-----------------------------------\n";
58-
std::cout << "Matching algorithm: " << LIB::MATCH_FACT.kind() << "\n";
59-
std::cout << "SCC algorithm: " << LIB::SCC_FACT.kind() << "\n\n";
58+
std::cout << "Matching algorithm: " << LIB::MATCH_IMPL.kind() << "\n";
59+
std::cout << "SCC algorithm: " << LIB::SCC_IMPL.kind() << "\n\n";
6060
}
6161
}
6262

0 commit comments

Comments
 (0)