All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
changeList.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef SDF_CHANGELIST_H
25 #define SDF_CHANGELIST_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/path.h"
32 #include "pxr/usd/sdf/types.h"
33 
34 #include <set>
35 #include <map>
36 #include <unordered_map>
37 #include <iosfwd>
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
41 class SdfChangeList;
42 typedef std::map<SdfLayerHandle, SdfChangeList> SdfLayerChangeListMap;
43 
50 {
51 public:
52  enum SubLayerChangeType {
53  SubLayerAdded,
54  SubLayerRemoved,
55  SubLayerOffset
56  };
57 
58 
59  void DidReplaceLayerContent();
60  void DidReloadLayerContent();
61  void DidChangeLayerResolvedPath();
62  void DidChangeLayerIdentifier(const std::string &oldIdentifier);
63  void DidChangeSublayerPaths(const std::string &subLayerPath,
64  SubLayerChangeType changeType);
65 
66  void DidAddPrim(const SdfPath &primPath, bool inert);
67  void DidRemovePrim(const SdfPath &primPath, bool inert);
68  void DidReorderPrims(const SdfPath &parentPath);
69  void DidChangePrimName(const SdfPath &oldPath, const SdfPath &newPath);
70  void DidChangePrimVariantSets(const SdfPath &primPath);
71  void DidChangePrimInheritPaths(const SdfPath &primPath);
72  void DidChangePrimReferences(const SdfPath &primPath);
73  void DidChangePrimSpecializes(const SdfPath &primPath);
74 
75  void DidAddProperty(const SdfPath &propPath, bool hasOnlyRequiredFields);
76  void DidRemoveProperty(const SdfPath &propPath, bool hasOnlyRequiredFields);
77  void DidReorderProperties(const SdfPath &propPath);
78  void DidChangePropertyName(const SdfPath &oldPath, const SdfPath &newPath);
79 
80  void DidChangeAttributeTimeSamples(const SdfPath &attrPath);
81  void DidChangeAttributeConnection(const SdfPath &attrPath);
82  void DidChangeRelationshipTargets(const SdfPath &relPath);
83  void DidAddTarget(const SdfPath &targetPath);
84  void DidRemoveTarget(const SdfPath &targetPath);
85 
86  void DidChangeInfo(const SdfPath &path, const TfToken &key,
87  const VtValue &oldValue, const VtValue &newValue);
88 
107  struct Entry {
108  // Map of info keys that have changed to (old, new) value pairs.
109  typedef std::pair<VtValue, VtValue> InfoChange;
110  typedef std::map<TfToken, InfoChange, TfTokenFastArbitraryLessThan>
111  InfoChangeMap;
112  InfoChangeMap infoChanged;
113 
114  typedef std::pair<std::string, SubLayerChangeType> SubLayerChange;
115  std::vector<SubLayerChange> subLayerChanges;
116 
117  // Empty if didRename is not set
118  SdfPath oldPath;
119 
120  // Empty if didChangeIdentifier is not set
121  std::string oldIdentifier;
122 
123  // Most changes are stored as simple bits.
124  struct _Flags {
125  _Flags() {
126  memset(this, 0, sizeof(*this));
127  }
128 
129  // SdfLayer
130  bool didChangeIdentifier:1;
131  bool didChangeResolvedPath:1;
132  bool didReplaceContent:1;
133  bool didReloadContent:1;
134 
135  // SdfLayer, SdfPrimSpec, SdfRelationshipTarget.
136  bool didReorderChildren:1;
137  bool didReorderProperties:1;
138 
139  // SdfPrimSpec, SdfPropertySpec
140  bool didRename:1;
141 
142  // SdfPrimSpec
143  bool didChangePrimVariantSets:1;
144  bool didChangePrimInheritPaths:1;
145  bool didChangePrimSpecializes:1;
146  bool didChangePrimReferences:1;
147 
148  // SdfPropertySpec
149  bool didChangeAttributeTimeSamples:1;
150  bool didChangeAttributeConnection:1;
151  bool didChangeRelationshipTargets:1;
152  bool didAddTarget:1;
153  bool didRemoveTarget:1;
154 
155  // SdfPrimSpec add/remove
156  bool didAddInertPrim:1;
157  bool didAddNonInertPrim:1;
158  bool didRemoveInertPrim:1;
159  bool didRemoveNonInertPrim:1;
160 
161  // Property add/remove
162  bool didAddPropertyWithOnlyRequiredFields:1;
163  bool didAddProperty:1;
164  bool didRemovePropertyWithOnlyRequiredFields:1;
165  bool didRemoveProperty:1;
166  };
167 
168  _Flags flags;
169  };
170 
172  typedef std::unordered_map<SdfPath, Entry, SdfPath::Hash> EntryList;
173 
174 public:
175  const EntryList & GetEntryList() const { return _entries; }
176 
177  // Change accessors/mutators
178  Entry const &GetEntry( const SdfPath & ) const;
179 
180 private:
181  Entry &_GetEntry(SdfPath const &);
182 
183  EntryList _entries;
184 };
185 
186 // Stream-output operator
187 SDF_API std::ostream& operator<<(std::ostream&, const SdfChangeList &);
188 
189 PXR_NAMESPACE_CLOSE_SCOPE
190 
191 #endif // SDF_CHANGELIST_H
Entry of changes at a single path in namespace.
Definition: changeList.h:107
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
std::unordered_map< SdfPath, Entry, SdfPath::Hash > EntryList
Map of change entries at various paths in a layer.
Definition: changeList.h:172
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
A list of scene description modifications, organized by the namespace paths where the changes occur...
Definition: changeList.h:49
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182