Cleanup: remove redundant doxygen \file argument
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_relations_keys.cc
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) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file \ingroup depsgraph
21  *
22  * Methods for constructing depsgraph
23  */
24
25 #include "intern/builder/deg_builder_relations.h"
26
27 namespace DEG {
28
29 ////////////////////////////////////////////////////////////////////////////////
30 // Time source.
31
32 TimeSourceKey::TimeSourceKey()
33         : id(NULL)
34 {
35 }
36
37 TimeSourceKey::TimeSourceKey(ID *id)
38         : id(id)
39 {
40 }
41
42 string TimeSourceKey::identifier() const
43 {
44         return string("TimeSourceKey");
45 }
46
47 ////////////////////////////////////////////////////////////////////////////////
48 // Component.
49
50 ComponentKey::ComponentKey()
51         : id(NULL),
52           type(NodeType::UNDEFINED),
53           name("")
54 {
55 }
56
57 ComponentKey::ComponentKey(ID *id, NodeType type, const char *name)
58         : id(id),
59           type(type),
60           name(name)
61 {
62 }
63
64 string ComponentKey::identifier() const
65 {
66         const char *idname = (id) ? id->name : "<None>";
67         string result = string("ComponentKey(");
68         result += idname;
69         result += ", " + string(nodeTypeAsString(type));
70         if (name[0] != '\0') {
71                 result += ", '" + string(name) + "'";
72         }
73         result += ')';
74         return result;
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////
78 // Operation.
79
80 OperationKey::OperationKey()
81         : id(NULL),
82           component_type(NodeType::UNDEFINED),
83           component_name(""),
84           opcode(OperationCode::OPERATION),
85           name(""),
86           name_tag(-1)
87 {
88 }
89
90 OperationKey::OperationKey(ID *id,
91                            NodeType component_type,
92                            const char *name,
93                            int name_tag)
94         : id(id),
95           component_type(component_type),
96           component_name(""),
97           opcode(OperationCode::OPERATION),
98           name(name),
99           name_tag(name_tag)
100 {
101 }
102
103 OperationKey::OperationKey(ID *id,
104                            NodeType component_type,
105                            const char *component_name,
106                            const char *name,
107                            int name_tag)
108         : id(id),
109           component_type(component_type),
110           component_name(component_name),
111           opcode(OperationCode::OPERATION),
112           name(name),
113           name_tag(name_tag)
114 {
115 }
116
117 OperationKey::OperationKey(ID *id,
118                            NodeType component_type,
119                            OperationCode opcode)
120         : id(id),
121           component_type(component_type),
122           component_name(""),
123           opcode(opcode),
124           name(""),
125           name_tag(-1)
126 {
127 }
128
129 OperationKey::OperationKey(ID *id,
130                            NodeType component_type,
131                            const char *component_name,
132                            OperationCode opcode)
133         : id(id),
134           component_type(component_type),
135           component_name(component_name),
136           opcode(opcode),
137           name(""),
138           name_tag(-1)
139 {
140 }
141
142 OperationKey::OperationKey(ID *id,
143                            NodeType component_type,
144                            OperationCode opcode,
145                            const char *name,
146                            int name_tag)
147         : id(id),
148           component_type(component_type),
149           component_name(""),
150           opcode(opcode),
151           name(name),
152           name_tag(name_tag)
153 {
154 }
155
156 OperationKey::OperationKey(ID *id,
157                            NodeType component_type,
158                            const char *component_name,
159                            OperationCode opcode,
160                            const char *name,
161                            int name_tag)
162         : id(id),
163           component_type(component_type),
164           component_name(component_name),
165           opcode(opcode),
166           name(name),
167           name_tag(name_tag)
168 {
169 }
170
171 string OperationKey::identifier() const
172 {
173         string result = string("OperationKey(");
174         result += "type: " + string(nodeTypeAsString(component_type));
175         result += ", component name: '" + string(component_name) + "'";
176         result += ", operation code: " + string(operationCodeAsString(opcode));
177         if (name[0] != '\0') {
178                 result += ", '" + string(name) + "'";
179         }
180         result += ")";
181         return result;
182 }
183
184 ////////////////////////////////////////////////////////////////////////////////
185 // RNA path.
186
187 RNAPathKey::RNAPathKey(ID *id, const char *path, RNAPointerSource source)
188         : id(id),
189           source(source)
190 {
191         /* Create ID pointer for root of path lookup. */
192         PointerRNA id_ptr;
193         RNA_id_pointer_create(id, &id_ptr);
194         /* Try to resolve path. */
195         int index;
196         if (!RNA_path_resolve_full(&id_ptr, path, &ptr, &prop, &index)) {
197                 ptr = PointerRNA_NULL;
198                 prop = NULL;
199         }
200 }
201
202 RNAPathKey::RNAPathKey(ID *id,
203                        const PointerRNA &ptr,
204                        PropertyRNA *prop,
205                        RNAPointerSource source)
206         : id(id),
207           ptr(ptr),
208           prop(prop),
209           source(source)
210 {
211 }
212
213 string RNAPathKey::identifier() const
214 {
215         const char *id_name   = (id) ?  id->name : "<No ID>";
216         const char *prop_name = (prop) ? RNA_property_identifier(prop) : "<No Prop>";
217         return string("RnaPathKey(") + "id: " + id_name +
218                                        ", prop: '" + prop_name +  "')";
219 }
220
221 }  // namespace DEG