1 #ifndef DALI_SCENE3D_LOADER_HASH_H_
2 #define DALI_SCENE3D_LOADER_HASH_H_
4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
25 namespace Dali::Scene3D::Loader
28 * @brief Rudimentary hash generator that follows a builder pattern.
33 static constexpr uint64_t DEFAULT_SEED = 61081;
35 explicit Hash(uint64_t initial = DEFAULT_SEED);
38 * @brief Applies a boolean to the hash.
39 * @return Its updated self.
44 * @brief Applies a signed 32-bit integer to the hash.
45 * @return Its updated self.
50 * @brief Applies an unsigned 32-bit integer to the hash.
51 * @return Its updated self.
53 Hash& Add(uint32_t i);
56 * @brief Applies an unsigned 64-bit integer to the hash.
57 * @return Its updated self.
59 Hash& Add(uint64_t i);
62 * @brief Applies a float to the hash.
63 * @return Its updated self.
68 * @brief Applies a c-string to the hash.
69 * @return Its updated self.
71 Hash& Add(const char* cStr);
74 * @brief Applies a c-string @a cStr of @a len characters, to the hash.
75 * @return Its updated self.
77 Hash& Add(const char* cStr, size_t len);
80 * @brief Applies a string to the hash.
81 * @return Its updated self.
83 Hash& Add(const std::string& str);
86 * @brief Applies a series of bytes between @a i0 and @a i1 to the hash.
87 * @return Its updated self.
89 Hash& AddBytes(const uint8_t* i0, const uint8_t* i1);
92 * @brief Applies the bytes of an object @a value, to the hash.
93 * @return Its updated self.
96 Hash& AddObjectBytes(const T& value);
98 operator uint64_t() const;
103 uint64_t Concatenate(uint64_t value);
107 Hash& Hash::AddObjectBytes(const T& value)
109 auto i0 = reinterpret_cast<const uint8_t*>(&value);
110 auto i1 = i0 + sizeof(T);
113 mValue = Concatenate(*i0);
119 } // namespace Dali::Scene3D::Loader
121 #endif // DALI_SCENE3D_LOADER_HASH_H_