Blender  V2.93
depsgraph_relation.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2020 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "intern/depsgraph_relation.h" /* own include */
25 
26 #include "BLI_utildefines.h"
27 
28 #include "intern/depsgraph_type.h"
29 #include "intern/node/deg_node.h"
30 
31 namespace blender::deg {
32 
33 Relation::Relation(Node *from, Node *to, const char *description)
34  : from(from), to(to), name(description), flag(0)
35 {
36  /* Hook it up to the nodes which use it.
37  *
38  * NOTE: We register relation in the nodes which this link connects to here
39  * in constructor but we don't un-register it in the destructor.
40  *
41  * Reasoning:
42  *
43  * - Destructor is currently used on global graph destruction, so there's no
44  * real need in avoiding dangling pointers, all the memory is to be freed
45  * anyway.
46  *
47  * - Un-registering relation is not a cheap operation, so better to have it
48  * as an explicit call if we need this. */
49  from->outlinks.append(this);
50  to->inlinks.append(this);
51 }
52 
54 {
55  /* Sanity check. */
56  BLI_assert(from != nullptr && to != nullptr);
57 }
58 
60 {
61  /* Sanity check. */
62  BLI_assert(from != nullptr && to != nullptr);
65 }
66 
67 } // namespace blender::deg
#define BLI_assert(a)
Definition: BLI_assert.h:58
void append(const T &value)
Definition: BLI_vector.hh:438
void remove_first_occurrence_and_reorder(const T &value)
Definition: BLI_vector.hh:728
StackEntry * from
Relations inlinks
Definition: deg_node.h:175
Relations outlinks
Definition: deg_node.h:176
Relation(Node *from, Node *to, const char *description)