Blender V5.0
IO_dupli_persistent_id.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
6#include "BKE_duplilist.hh"
7
8#include <array>
9#include <cstdint>
10#include <string>
11
12namespace blender::io {
13
14/* Wrapper for DupliObject::persistent_id that can act as a map key. */
16 protected:
17 constexpr static int array_length_ = MAX_DUPLI_RECUR;
18 using PIDArray = std::array<int, array_length_>;
20
21 explicit PersistentID(const PIDArray &persistent_id_values);
22
23 public:
25 explicit PersistentID(const DupliObject *dupli_ob);
26
27 /* Return true if the persistent IDs are the same, ignoring the first digit. */
28 bool is_from_same_instancer_as(const PersistentID &other) const;
29
30 /* Construct the persistent ID of this instance's instancer. */
32
33 /* Construct a string representation by reversing the persistent ID.
34 * In case of a duplicator that is duplicated itself as well, this
35 * results in strings like:
36 * "3" for the duplicated duplicator, and
37 * "3-0", "3-1", etc. for its duplis. */
38 std::string as_object_name_suffix() const;
39
40 uint64_t hash() const;
41
42 friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b);
43
44 private:
45 void copy_values_from(const PIDArray &persistent_id_values);
46};
47
48} // namespace blender::io
constexpr int MAX_DUPLI_RECUR
unsigned long long int uint64_t
friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b)
PersistentID(const PIDArray &persistent_id_values)
std::array< int, array_length_ > PIDArray
PersistentID instancer_pid() const
std::string as_object_name_suffix() const
bool is_from_same_instancer_as(const PersistentID &other) const