-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathShell.hpp
More file actions
110 lines (90 loc) · 2.42 KB
/
Shell.hpp
File metadata and controls
110 lines (90 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef SHELL_HPP
#define SHELL_HPP
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <ostream>
#if defined(HAVE_TR1_FUNCTIONAL)
#include <tr1/functional>
#elif defined(HAVE_STD_HASH)
#include <functional>
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
#include <boost/functional/hash.hpp>
#endif
template<typename Tshape_, typename Tdid_>
struct Shell
{
typedef Tshape_ shape_type;
typedef Tdid_ domain_id_type;
typedef typename shape_type::position_type position_type;
typedef typename shape_type::length_type length_type;
Shell(): domain_id_(), shape_() {}
Shell(domain_id_type const& domain_id, shape_type const& shape)
: domain_id_(domain_id), shape_(shape) {}
position_type& position()
{
return shape_.position();
}
position_type const& position() const
{
return shape_.position();
}
shape_type& shape()
{
return shape_;
}
shape_type const& shape() const
{
return shape_;
}
domain_id_type const& did() const
{
return domain_id_;
}
domain_id_type& did()
{
return domain_id_;
}
bool operator==(Shell const& rhs) const
{
return domain_id_ == rhs.did() && shape_ == rhs.shape();
}
bool operator!=(Shell const& rhs) const
{
return !operator==(rhs);
}
private:
domain_id_type domain_id_;
shape_type shape_;
};
template<typename Tstrm_, typename Ttraits_, typename Tshape_, typename Tdid_>
inline std::basic_ostream<Tstrm_, Ttraits_>& operator<<(std::basic_ostream<Tstrm_, Ttraits_>& strm, const Shell<Tshape_, Tdid_>& v)
{
strm << "Shell(" << v.shape() << ", " << v.did() << ")";
return strm;
}
#if defined(HAVE_TR1_FUNCTIONAL)
namespace std { namespace tr1 {
#elif defined(HAVE_STD_HASH)
namespace std {
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
namespace boost {
#endif
template<typename Tshape_, typename Tdid_>
struct hash<Shell<Tshape_, Tdid_> >
{
typedef Shell<Tshape_, Tdid_> argument_type;
std::size_t operator()(argument_type const& val)
{
return hash<typename argument_type::shape_type>()(val.shape()) ^
hash<typename argument_type::domain_id_type>()(val.did());
}
};
#if defined(HAVE_TR1_FUNCTIONAL)
} } // namespace std::tr1
#elif defined(HAVE_STD_HASH)
} // namespace std
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
} // namespace boost
#endif
#endif /* SHELL_HPP */