Skip to content

Commit 184fd91

Browse files
committed
Delegation+AbsFact for Maps
1 parent a7aa6bc commit 184fd91

6 files changed

Lines changed: 513 additions & 182 deletions

File tree

sbg/af_map.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*******************************************************************************
2+
3+
This file is part of Set--Based Graph Library.
4+
5+
SBG Library is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
SBG Library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with SBG Library. If not, see <http://www.gnu.org/licenses/>.
17+
18+
******************************************************************************/
19+
20+
#include "sbg/af_map.hpp"
21+
22+
namespace SBG {
23+
24+
namespace LIB {
25+
26+
////////////////////////////////////////////////////////////////////////////////
27+
// Map AF ----------------------------------------------------------------------
28+
////////////////////////////////////////////////////////////////////////////////
29+
30+
MapSetAF::MapSetAF(const SetAF &set_fact) : set_fact_(set_fact) {}
31+
32+
Map MapSetAF::createMap() const
33+
{
34+
return Map(std::make_unique<MapSetDeleg>(set_fact_));
35+
}
36+
37+
Map MapSetAF::createMap(Util::MD_NAT x, Exp exp) const
38+
{
39+
return Map(std::make_unique<MapSetDeleg>(set_fact_, x, exp));
40+
}
41+
42+
Map MapSetAF::createMap(Interval i, LExp le) const
43+
{
44+
return Map(std::make_unique<MapSetDeleg>(set_fact_, i, le));
45+
}
46+
47+
Map MapSetAF::createMap(SetPiece mdi, Exp exp) const
48+
{
49+
return Map(std::make_unique<MapSetDeleg>(set_fact_, mdi, exp));
50+
}
51+
52+
Map MapSetAF::createMap(Set s, Exp exp) const
53+
{
54+
return Map(std::make_unique<MapSetDeleg>(set_fact_, s, exp));
55+
}
56+
57+
} // namespace LIB
58+
59+
} // namespace SBG

sbg/af_map.hpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/** @file af_map.hpp
2+
3+
@brief <b>Map Abstract Factory</b>
4+
5+
It was proposed to try implementing SBG maps with "atomic" domains (i.e.,
6+
the domain is a described with a mdi). For this reason, it was decided that
7+
delegation should be used to provide different implementations, and also an
8+
abstract factory was needed to create objects with the desired implementation.
9+
10+
<hr>
11+
12+
This file is part of Set--Based Graph Library.
13+
14+
SBG Library is free software: you can redistribute it and/or modify
15+
it under the terms of the GNU General Public License as published by
16+
the Free Software Foundation, either version 3 of the License, or
17+
(at your option) any later version.
18+
19+
SBG Library is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
GNU General Public License for more details.
23+
24+
You should have received a copy of the GNU General Public License
25+
along with SBG Library. If not, see <http://www.gnu.org/licenses/>.
26+
27+
******************************************************************************/
28+
29+
#ifndef SBG_AF_MAP_HPP
30+
#define SBG_AF_MAP_HPP
31+
32+
#include "map.hpp"
33+
34+
namespace SBG {
35+
36+
namespace LIB {
37+
38+
struct MapAF {
39+
virtual ~MapAF() = default;
40+
41+
virtual Map createMap() const = 0;
42+
virtual Map createMap(Util::MD_NAT x, Exp exp) const = 0;
43+
virtual Map createMap(Interval i, LExp le) const = 0;
44+
virtual Map createMap(SetPiece mdi, Exp exp) const = 0;
45+
virtual Map createMap(Set s, Exp exp) const = 0;
46+
};
47+
48+
struct MapSetAF : public MapAF {
49+
private:
50+
const SetAF &set_fact_;
51+
52+
public:
53+
MapSetAF(const SetAF &set_fact);
54+
55+
Map createMap() const override;
56+
Map createMap(Util::MD_NAT x, Exp exp) const override;
57+
Map createMap(Interval i, LExp le) const override;
58+
Map createMap(SetPiece mdi, Exp exp) const override;
59+
Map createMap(Set s, Exp exp) const override;
60+
};
61+
62+
} // namespace LIB
63+
64+
} // namespace SBG
65+
66+
#endif

0 commit comments

Comments
 (0)