File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ add_library(slvs-solver INTERFACE)
6565target_sources (slvs-solver INTERFACE
6666 dsc.h
6767 expr .h
68+ handle.h
6869 param.h
6970 platform/platform.h
7071 solvespace.h
Original file line number Diff line number Diff line change 1111#include < cmath>
1212#include < cstddef>
1313#include < cstdint>
14- #include < type_traits>
1514#include < vector>
1615
1716#include " defs.h"
1817#include " util.h"
1918
2019namespace SolveSpace {
2120
22- // / Trait indicating which types are handle types and should get the associated operators.
23- // / Specialize for each handle type and inherit from std::true_type.
24- template <typename T>
25- struct IsHandleOracle : std::false_type {};
26-
27- // Equality-compare any two instances of a handle type.
28- template <typename T>
29- static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
30- operator ==(T const &lhs, T const &rhs) {
31- return lhs.v == rhs.v ;
32- }
33-
34- // Inequality-compare any two instances of a handle type.
35- template <typename T>
36- static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
37- operator !=(T const &lhs, T const &rhs) {
38- return !(lhs == rhs);
39- }
40-
41- // Less-than-compare any two instances of a handle type.
42- template <typename T>
43- static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
44- operator <(T const &lhs, T const &rhs) {
45- return lhs.v < rhs.v ;
46- }
47-
48- template <class T >
49- struct HandleHasher {
50- static_assert (IsHandleOracle<T>::value, " Not a valid handle type" );
51-
52- inline size_t operator ()(const T &h) const {
53- using Hasher = std::hash<decltype (T::v)>;
54- return Hasher{}(h.v );
55- }
56- };
57-
5821class Vector ;
5922class Vector4 ;
6023class Point2d ;
Original file line number Diff line number Diff line change 1+ #ifndef SOVLESPACE_HANDLE_H
2+ #define SOVLESPACE_HANDLE_H
3+
4+ #include < functional>
5+ #include < type_traits>
6+
7+ namespace SolveSpace {
8+
9+ // / Trait indicating which types are handle types and should get the associated operators.
10+ // / Specialize for each handle type and inherit from std::true_type.
11+ template <class T >
12+ struct IsHandleOracle : std::false_type {};
13+
14+ // Equality-compare any two instances of a handle type.
15+ template <class T >
16+ static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
17+ operator ==(T const &lhs, T const &rhs) {
18+ return lhs.v == rhs.v ;
19+ }
20+
21+ // Inequality-compare any two instances of a handle type.
22+ template <class T >
23+ static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
24+ operator !=(T const &lhs, T const &rhs) {
25+ return !(lhs == rhs);
26+ }
27+
28+ // Less-than-compare any two instances of a handle type.
29+ template <class T >
30+ static inline typename std::enable_if<IsHandleOracle<T>::value, bool >::type
31+ operator <(T const &lhs, T const &rhs) {
32+ return lhs.v < rhs.v ;
33+ }
34+
35+ template <class T >
36+ struct HandleHasher {
37+ static_assert (IsHandleOracle<T>::value, " Not a valid handle type" );
38+
39+ inline size_t operator ()(const T &h) const {
40+ using Hasher = std::hash<decltype (T::v)>;
41+ return Hasher{}(h.v );
42+ }
43+ };
44+
45+ } // namespace SolveSpace
46+
47+ #endif // !SOVLESPACE_HANDLE_H
Original file line number Diff line number Diff line change 44#include < cstdint>
55#include < unordered_set>
66
7- #include " dsc .h"
7+ #include " handle .h"
88
99namespace SolveSpace {
1010
@@ -39,7 +39,11 @@ class Param {
3939 void Clear () {}
4040};
4141
42- using ParamList = IdList<Param,hParam>;
42+ // Use a forward declaration in order to avoid pulling dsc.h in for units that
43+ // don't need to use `ParamList`
44+ template <class T , class H > class IdList ;
45+
46+ using ParamList = IdList<Param, hParam>;
4347
4448using ParamSet = std::unordered_set<hParam, HandleHasher<hParam>>;
4549
Original file line number Diff line number Diff line change 1313#include < cstdint>
1414
1515#include " dsc.h"
16+ #include " handle.h"
1617#include " polygon.h"
1718
1819namespace SolveSpace {
You can’t perform that action at this time.
0 commit comments