The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.
The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.
However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.
This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software ...
This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2020 Blender Foundation */
|
|
#pragma once
|
|
|
|
#include "BKE_duplilist.h"
|
|
|
|
#include "DNA_object_types.h" /* For MAX_DUPLI_RECUR */
|
|
|
|
#include <array>
|
|
#include <optional>
|
|
#include <ostream>
|
|
|
|
namespace blender::io {
|
|
|
|
/* Wrapper for DupliObject::persistent_id that can act as a map key. */
|
|
class PersistentID {
|
|
protected:
|
|
constexpr static int array_length_ = MAX_DUPLI_RECUR;
|
|
typedef std::array<int, array_length_> PIDArray;
|
|
PIDArray persistent_id_;
|
|
|
|
explicit PersistentID(const PIDArray &persistent_id_values);
|
|
|
|
public:
|
|
PersistentID();
|
|
explicit PersistentID(const DupliObject *dupli_ob);
|
|
|
|
/* Return true if the persistent IDs are the same, ignoring the first digit. */
|
|
bool is_from_same_instancer_as(const PersistentID &other) const;
|
|
|
|
/* Construct the persistent ID of this instance's instancer. */
|
|
PersistentID instancer_pid() const;
|
|
|
|
/* Construct a string representation by reversing the persistent ID.
|
|
* In case of a duplicator that is duplicated itself as well, this
|
|
* results in strings like:
|
|
* "3" for the duplicated duplicator, and
|
|
* "3-0", "3-1", etc. for its duplis. */
|
|
std::string as_object_name_suffix() const;
|
|
|
|
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);
|
|
|
|
private:
|
|
void copy_values_from(const PIDArray &persistent_id_values);
|
|
};
|
|
|
|
} // namespace blender::io
|