forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransformHasher.hh
48 lines (40 loc) · 1.54 KB
/
TransformHasher.hh
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
//----------------------------------*-C++-*----------------------------------//
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/TransformHasher.hh
//---------------------------------------------------------------------------//
#pragma once
#include <cstdlib>
#include "VariantTransform.hh"
namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Calculate a hash value of a transform for deduplication.
*/
class TransformHasher
{
public:
//!@{
//! \name Type aliases
using result_type = std::size_t;
//!@}
public:
// By default, calculate a hash based on the stored data
template<class T>
result_type operator()(T const&) const;
// Special hash for "no transformation"
result_type operator()(NoTransformation const&) const;
// Special hash for "signed permutation"
result_type operator()(SignedPermutation const&) const;
};
//---------------------------------------------------------------------------//
// FREE FUNCTIONS
//---------------------------------------------------------------------------//
// Calculate a hash for a variant transform
TransformHasher::result_type
visit(TransformHasher const&, VariantTransform const& transform);
//---------------------------------------------------------------------------//
} // namespace celeritas