Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:17:12

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file orange/transform/TransformHasher.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <cstdlib>
0011 
0012 #include "VariantTransform.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 /*!
0018  * Calculate a hash value of a transform for deduplication.
0019  */
0020 class TransformHasher
0021 {
0022   public:
0023     //!@{
0024     //! \name Type aliases
0025     using result_type = std::size_t;
0026     //!@}
0027 
0028   public:
0029     // By default, calculate a hash based on the stored data
0030     template<class T>
0031     result_type operator()(T const&) const;
0032 
0033     // Special hash for "no transformation"
0034     result_type operator()(NoTransformation const&) const;
0035 
0036     // Special hash for "signed permutation"
0037     result_type operator()(SignedPermutation const&) const;
0038 };
0039 
0040 //---------------------------------------------------------------------------//
0041 // FREE FUNCTIONS
0042 //---------------------------------------------------------------------------//
0043 // Calculate a hash for a variant transform
0044 TransformHasher::result_type
0045 visit(TransformHasher const&, VariantTransform const& transform);
0046 
0047 //---------------------------------------------------------------------------//
0048 }  // namespace celeritas