BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
abstract_boundary_operator_id.hpp
1 #ifndef bempp_abstract_boundary_operator_id_hpp
2 #define bempp_abstract_boundary_operator_id_hpp
3 
4 #include "../common/common.hpp"
5 #include "../common/deprecated.hpp"
6 #include "../common/shared_ptr.hpp"
7 
8 #include <iostream>
9 #include <boost/functional/hash.hpp>
10 
11 namespace Bempp
12 {
13 
22 {
23 public:
24  virtual ~AbstractBoundaryOperatorId() {}
25  virtual size_t hash() const = 0;
26  virtual void dump() const {}
27  virtual bool isEqual(
28  const AbstractBoundaryOperatorId& other) const = 0;
29 
30  bool operator==(const AbstractBoundaryOperatorId& other) const {
31  return isEqual(other);
32  }
33 
34  bool operator!=(const AbstractBoundaryOperatorId& other) const {
35  return !operator==(other);
36  }
37 };
38 
39 } // namespace Bempp
40 
41 namespace tbb
42 {
43 
44 inline size_t tbb_hasher(
45  const boost::shared_ptr<const Bempp::AbstractBoundaryOperatorId>& id)
46 {
47  return id->hash();
48 }
49 
50 inline size_t tbb_hasher(float id)
51 {
52  return boost::hash<float>()(id);
53 }
54 
55 inline size_t tbb_hasher(double id)
56 {
57  return boost::hash<double>()(id);
58 }
59 
60 } // namespace tbb
61 
62 #include <tbb/concurrent_unordered_map.h>
63 
64 namespace Bempp
65 {
66 
67 // copied from Boost
68 template <typename T>
69 inline void tbb_hash_combine(size_t& seed, const T& v)
70 {
71  seed ^= tbb::tbb_hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
72 }
73 
74 }
75 
76 #endif // bempp_abstract_boundary_operator_id_hpp
Base class for identifiers of an abstract boundary operator.
Definition: abstract_boundary_operator_id.hpp:21