Wildmeshing Toolkit
Loading...
Searching...
No Matches
Hashable.cpp
Go to the documentation of this file.
1#include "Hashable.hpp"
2#include <fmt/format.h>
3#include <fmt/ranges.h>
4#include <stdexcept>
5#include <vector>
6
7
8namespace wmtk::utils {
9Hashable::Hashable() = default;
10Hashable::Hashable(const Hashable&) = default;
11Hashable::Hashable(Hashable&&) = default;
12Hashable& Hashable::operator=(const Hashable&) = default;
13Hashable& Hashable::operator=(Hashable&&) = default;
14Hashable::~Hashable() = default;
15std::size_t Hashable::hash() const
16{
17 auto ch = child_hashes();
18 // if (ch.size() == 0) {
19 // throw std::runtime_error(
20 // "Hash base implementation was called without any child hashes. Either guarantee there
21 // " "is a child in child_hashes overload or overload this hash() function directly");
22 // }
23 std::vector<std::string> data;
24 for (const auto& [key, value] : ch) {
25 data.emplace_back(fmt::format("({}:{})", key, value));
26 }
27
28 std::string strdata = fmt::format("{}", fmt::join(data, ","));
29 return std::hash<std::string>{}(strdata);
30}
31
32std::map<std::string, size_t> Hashable::child_hashes() const
33{
34 return {};
35}
36} // namespace wmtk::utils
virtual std::map< std::string, size_t > child_hashes() const
Definition Hashable.cpp:32