forked from gfrd/egfrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticleID.hpp
62 lines (53 loc) · 1.58 KB
/
ParticleID.hpp
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
#ifndef PARTICLE_ID_HPP
#define PARTICLE_ID_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
#include "Identifier.hpp"
struct ParticleID: public Identifier<ParticleID, unsigned long long, int>
// The ParticleID is a class for the identification of particles
{
typedef Identifier<ParticleID, unsigned long long, int> base_type;
ParticleID(value_type const& value = value_type(0, 0))
: base_type(value) {}
};
#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<>
struct hash<ParticleID>
// Hashing function??
{
std::size_t operator()(ParticleID const& val) const
{
return static_cast<std::size_t>(val().first ^ val().second);
}
};
#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
template<typename Tstrm_, typename Ttraits_>
inline std::basic_ostream<Tstrm_, Ttraits_>& operator<<(std::basic_ostream<Tstrm_, Ttraits_>& strm,
const ParticleID& v)
// Provides a stream of characters (a string) of the 'particle id' that allows for printing.
{
strm << "PID(" << v().first << ":" << v().second << ")";
return strm;
}
#endif /* PARTICLE_ID_HPP */