Blender  V2.93
deg_builder_map.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) 2018 Blender Foundation.
17  * All rights reserved.
18  */
19 
25 
26 #include "DNA_ID.h"
27 
28 namespace blender::deg {
29 
30 bool BuilderMap::checkIsBuilt(ID *id, int tag) const
31 {
32  return (getIDTag(id) & tag) == tag;
33 }
34 
35 void BuilderMap::tagBuild(ID *id, int tag)
36 {
37  id_tags_.lookup_or_add(id, 0) |= tag;
38 }
39 
41 {
42  int &id_tag = id_tags_.lookup_or_add(id, 0);
43  const bool result = (id_tag & tag) == tag;
44  id_tag |= tag;
45  return result;
46 }
47 
48 int BuilderMap::getIDTag(ID *id) const
49 {
50  return id_tags_.lookup_default(id, 0);
51 }
52 
53 } // namespace blender::deg
ID and Library types, which are fundamental for sdna.
Value lookup_default(const Key &key, const Value &default_value) const
Definition: BLI_map.hh:524
Value & lookup_or_add(const Key &key, const Value &value)
Definition: BLI_map.hh:544
int getIDTag(ID *id) const
void tagBuild(ID *id, int tag=TAG_COMPLETE)
bool checkIsBuiltAndTag(ID *id, int tag=TAG_COMPLETE)
Map< ID *, int > id_tags_
bool checkIsBuilt(ID *id, int tag=TAG_COMPLETE) const
Definition: DNA_ID.h:273