diff --git a/src/OpenFOAM/primitives/hashes/Hash/Hash.H b/src/OpenFOAM/primitives/hashes/Hash/Hash.H index e5fbb2823be856f5ddd981b560563d1f1f42c921..e4f67371da3eb9a6eddd8234b6b3d3030d4cc26b 100644 --- a/src/OpenFOAM/primitives/hashes/Hash/Hash.H +++ b/src/OpenFOAM/primitives/hashes/Hash/Hash.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,6 +37,8 @@ Description #include "uLabel.H" #include "Hasher.H" #include "pTraits.H" +#include "fileName.H" +#include "wordRe.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -99,6 +101,107 @@ public: }; +//- Hash specialization for hashing strings +template<> +class Hash<Foam::string> +{ +public: + + Hash() + {} + + unsigned operator()(const string& p, unsigned seed) const + { + return string::hash()(p, seed); + } + unsigned operator()(const string& p) const + { + return string::hash()(p); + } +}; + + +//- Hash specialization for hashing words +template<> +class Hash<Foam::word> +{ +public: + + Hash() + {} + + unsigned operator()(const word& p, unsigned seed) const + { + return word::hash()(p, seed); + } + unsigned operator()(const word& p) const + { + return word::hash()(p); + } +}; + + +//- Hash specialization for hashing fileNames +template<> +class Hash<Foam::fileName> +{ +public: + + Hash() + {} + + unsigned operator()(const fileName& p, unsigned seed) const + { + return fileName::hash()(p, seed); + } + unsigned operator()(const fileName& p) const + { + return fileName::hash()(p); + } +}; + + +//- Hash specialization for hashing wordRes +template<> +class Hash<Foam::wordRe> +{ +public: + + Hash() + {} + + unsigned operator()(const wordRe& p, unsigned seed) const + { + return wordRe::hash()(p, seed); + } + unsigned operator()(const wordRe& p) const + { + return wordRe::hash()(p); + } +}; + + +//- Hash specialization for hashing keyTypes +template<> +class Hash<Foam::keyType> +{ +public: + + Hash() + {} + + unsigned operator()(const keyType& p, unsigned seed) const + { + return keyType::hash()(p, seed); + } + unsigned operator()(const keyType& p) const + { + return keyType::hash()(p); + } +}; + + + //- Hash specialization for hashing pointer addresses. // Treat a pointer like a long. // This should work for both 32-bit and 64-bit pointers.