Blender  V2.93
depsgraph_registry.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) 2019 Blender Foundation.
17  * All rights reserved.
18  */
19 
25 
26 #include "BLI_utildefines.h"
27 
28 #include "intern/depsgraph.h"
29 
30 namespace blender::deg {
31 
34 {
35  static GraphRegistry graph_registry;
36  return graph_registry;
37 }
38 
40 {
41  Main *bmain = depsgraph->bmain;
43 }
44 
46 {
47  Main *bmain = depsgraph->bmain;
48  GraphRegistry &graph_registry = get_graph_registry();
49  VectorSet<Depsgraph *> &graphs = graph_registry.lookup(bmain);
50  graphs.remove(depsgraph);
51 
52  // If this was the last depsgraph associated with the main, remove the main entry as well.
53  if (graphs.is_empty()) {
54  graph_registry.remove(bmain);
55  }
56 }
57 
59 {
61  if (graphs != nullptr) {
62  return *graphs;
63  }
64  return {};
65 }
66 
67 } // namespace blender::deg
const Value & lookup(const Key &key) const
Definition: BLI_map.hh:499
Value & lookup_or_add_default(const Key &key)
Definition: BLI_map.hh:594
bool remove(const Key &key)
Definition: BLI_map.hh:337
const Value * lookup_ptr(const Key &key) const
Definition: BLI_map.hh:477
bool is_empty() const
bool remove(const Key &key)
const Depsgraph * depsgraph
Span< Depsgraph * > get_all_registered_graphs(Main *bmain)
static GraphRegistry & get_graph_registry()
void unregister_graph(Depsgraph *depsgraph)
void register_graph(Depsgraph *depsgraph)
Definition: BKE_main.h:116