Blender V4.3
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 "DNA_object_types.h" /* For MAX_DUPLI_RECUR */
9
10#include <array>
11#include <iosfwd>
12#include <string>
13
14namespace blender::io {
15
16/* Wrapper for DupliObject::persistent_id that can act as a map key. */
18 protected:
19 constexpr static int array_length_ = MAX_DUPLI_RECUR;
20 using PIDArray = std::array<int, array_length_>;
22
23 explicit PersistentID(const PIDArray &persistent_id_values);
24
25 public:
27 explicit PersistentID(const DupliObject *dupli_ob);
28
29 /* Return true if the persistent IDs are the same, ignoring the first digit. */
30 bool is_from_same_instancer_as(const PersistentID &other) const;
31
32 /* Construct the persistent ID of this instance's instancer. */
34
35 /* Construct a string representation by reversing the persistent ID.
36 * In case of a duplicator that is duplicated itself as well, this
37 * results in strings like:
38 * "3" for the duplicated duplicator, and
39 * "3-0", "3-1", etc. for its duplis. */
40 std::string as_object_name_suffix() const;
41
42 friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b);
43 friend bool operator<(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b);
44 friend std::ostream &operator<<(std::ostream &os, const PersistentID &persistent_id);
45
46 private:
47 void copy_values_from(const PIDArray &persistent_id_values);
48};
49
50} // namespace blender::io
Object is a sort of wrapper for general info.
#define MAX_DUPLI_RECUR
friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b)
friend bool operator<(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b)
friend std::ostream & operator<<(std::ostream &os, const PersistentID &persistent_id)
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