HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
layer.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 PXR_USD_SDF_LAYER_H
25 #define PXR_USD_SDF_LAYER_H
26 
27 /// \file sdf/layer.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/data.h"
33 #include "pxr/usd/sdf/identity.h"
36 #include "pxr/usd/sdf/path.h"
37 #include "pxr/usd/sdf/proxyTypes.h"
38 #include "pxr/usd/sdf/spec.h"
39 #include "pxr/usd/sdf/types.h"
40 #include "pxr/usd/ar/assetInfo.h"
42 #include "pxr/base/vt/value.h"
43 
44 #include <hboost/optional.hpp>
45 
46 #include <atomic>
47 #include <functional>
48 #include <memory>
49 #include <set>
50 #include <string>
51 #include <vector>
52 
54 
57 
58 struct Sdf_AssetInfo;
59 
60 /// \class SdfLayer
61 ///
62 /// A unit of scene description that you combine with other units of scene
63 /// description to form a shot, model, set, shader, and so on.
64 ///
65 /// SdfLayer objects provide a persistent way to store layers on the
66 /// filesystem in .menva files. Currently the supported file format is
67 /// <c>.menva</c>, the ASCII file format.
68 ///
69 /// The FindOrOpen() method returns a new SdfLayer object with scene description
70 /// from a <c>.menva</c> file. Once read, a layer remembers which asset it was
71 /// read from. The Save() method saves the layer back out to the original file.
72 /// You can use the Export() method to write the layer to a different
73 /// location. You can use the GetIdentifier() method to get the layer's Id or
74 /// GetRealPath() to get the resolved, full file path.
75 ///
76 /// Layers can have a timeCode range (startTimeCode and endTimeCode). This range
77 /// represents the suggested playback range, but has no impact on the extent of
78 /// the animation data that may be stored in the layer. The metadatum
79 /// "timeCodesPerSecond" is used to annotate how the time ordinate for samples
80 /// contained in the file scales to seconds. For example, if timeCodesPerSecond
81 /// is 24, then a sample at time ordinate 24 should be viewed exactly one second
82 /// after the sample at time ordinate 0.
83 ///
84 /// Compared to Menv2x, layers are most closely analogous to
85 /// hooksets, <c>.hook</c> files, and <c>.cue</c> files.
86 ///
87 /// \todo
88 /// \li Insert a discussion of subLayers semantics here.
89 ///
90 /// \todo
91 /// \li Should have validate... methods for rootPrims
92 ///
93 class SdfLayer
94  : public TfRefBase
95  , public TfWeakBase
96 {
97 public:
98  /// Destructor
99  SDF_API
100  virtual ~SdfLayer();
101 
102  /// Noncopyable
103  SdfLayer(const SdfLayer&) = delete;
104  SdfLayer& operator=(const SdfLayer&) = delete;
105 
106  ///
107  /// \name Primary API
108  /// @{
109 
110  /// Returns the schema this layer adheres to. This schema provides details
111  /// about the scene description that may be authored in this layer.
112  SDF_API const SdfSchemaBase& GetSchema() const;
113 
114  /// Returns the file format used by this layer.
115  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
116 
117  /// Type for specifying additional file format-specific arguments to
118  /// layer API.
119  typedef std::map<std::string, std::string> FileFormatArguments;
120 
121  /// Returns the file format-specific arguments used during the construction
122  /// of this layer.
124 
125  /// Creates a new empty layer with the given identifier.
126  ///
127  /// The \p identifier must be either a real filesystem path or an asset
128  /// path without version modifier. Attempting to create a layer using an
129  /// identifier with a version specifier (e.g. layer.menva@300100,
130  /// layer.menva#5) raises a coding error, and returns a null layer
131  /// pointer.
132  ///
133  /// Additional arguments may be supplied via the \p args parameter.
134  /// These arguments may control behavior specific to the layer's
135  /// file format.
136  SDF_API
137  static SdfLayerRefPtr CreateNew(const std::string &identifier,
138  const std::string &realPath = std::string(),
139  const FileFormatArguments &args =
141 
142  /// Creates a new empty layer with the given identifier for a given file
143  /// format class.
144  ///
145  /// This function has the same behavior as the other CreateNew function,
146  /// but uses the explicitly-specified \p fileFormat instead of attempting
147  /// to discern the format from \p identifier.
148  SDF_API
149  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
150  const std::string &identifier,
151  const std::string &realPath = std::string(),
152  const FileFormatArguments &args =
154 
155  /// Creates a new empty layer with the given identifier for a given file
156  /// format class.
157  ///
158  /// This is so that Python File Format classes can create layers
159  /// (CreateNew() doesn't work, because it already saves during
160  /// construction of the layer. That is something specific (python
161  /// generated) layer types may choose to not do.)
162  ///
163  /// The new layer will not be dirty.
164  ///
165  /// Additional arguments may be supplied via the \p args parameter.
166  /// These arguments may control behavior specific to the layer's
167  /// file format.
168  SDF_API
169  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
170  const std::string &identifier,
171  const std::string &realPath = std::string(),
172  const FileFormatArguments &args =
174 
175  /// Returns the layer for the given path if found in the layer registry.
176  /// If the layer cannot be found, a null handle is returned.
177  SDF_API
178  static SdfLayerHandle Find(
179  const std::string &identifier,
181 
182  /// Returns the layer for \p layerPath, assumed to be relative to the path
183  /// of the \p anchor layer. If the \p anchor layer is invalid, a coding
184  /// error is raised, and a null handle is returned. If \p layerPath is not
185  /// relative, this method is equivalent to \c Find(layerPath).
186  SDF_API
187  static SdfLayerHandle FindRelativeToLayer(
188  const SdfLayerHandle &anchor,
189  const std::string &layerPath,
191 
192  /// Return an existing layer with the given \p identifier and \p args, or
193  /// else load it from disk. If the layer can't be found or loaded,
194  /// an error is posted and a null layer is returned.
195  ///
196  /// Arguments in \p args will override any arguments specified in
197  /// \p identifier.
198  SDF_API
199  static SdfLayerRefPtr FindOrOpen(
200  const std::string &identifier,
202 
203  /// Load the given layer from disk as a new anonymous layer. If the
204  /// layer can't be found or loaded, an error is posted and a null
205  /// layer is returned.
206  ///
207  /// The anonymous layer does not retain any knowledge of the backing
208  /// file on the filesystem.
209  ///
210  /// \p metadataOnly is a flag that asks for only the layer metadata
211  /// to be read in, which can be much faster if that is all that is
212  /// required. Note that this is just a hint: some FileFormat readers
213  /// may disregard this flag and still fully populate the layer contents.
214  ///
215  /// An optional \p tag may be specified. See CreateAnonymous for details.
216  SDF_API
218  const std::string &layerPath,
219  bool metadataOnly = false,
220  const std::string& tag = std::string());
221 
222  /// Returns the data from the absolute root path of this layer.
223  SDF_API
224  SdfDataRefPtr GetMetadata() const;
225 
226  /// Returns handles for all layers currently held by the layer registry.
227  SDF_API
229 
230  /// Returns whether this layer has no significant data.
231  SDF_API
232  bool IsEmpty() const;
233 
234  /// Copies the content of the given layer into this layer.
235  /// Source layer is unmodified.
236  SDF_API
237  void TransferContent(const SdfLayerHandle& layer);
238 
239  /// Creates a new \e anonymous layer with an optional \p tag. An anonymous
240  /// layer is a layer with a system assigned identifier, that cannot be
241  /// saved to disk via Save(). Anonymous layers have an identifier, but no
242  /// real path or other asset information fields.
243  ///
244  /// Anonymous layers may be tagged, which can be done to aid debugging
245  /// subsystems that make use of anonymous layers. The tag becomes the
246  /// display name of an anonymous layer, and is also included in the
247  /// generated identifier. Untagged anonymous layers have an empty display
248  /// name.
249  ///
250  /// Additional arguments may be supplied via the \p args parameter.
251  /// These arguments may control behavior specific to the layer's
252  /// file format.
253  SDF_API
255  const std::string& tag = std::string(),
257 
258  /// Create an anonymous layer with a specific \p format.
259  SDF_API
261  const std::string &tag, const SdfFileFormatConstPtr &format,
263 
264  /// Returns true if this layer is an anonymous layer.
265  SDF_API
266  bool IsAnonymous() const;
267 
268  /// Returns true if the \p identifier is an anonymous layer unique
269  /// identifier.
270  SDF_API
271  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
272 
273  /// Returns the display name for the given \p identifier, using the same
274  /// rules as GetDisplayName.
275  SDF_API
277  const std::string& identifier);
278 
279  /// @}
280  /// \name File I/O
281  /// @{
282 
283  /// Converts \e layerPath to a file system path.
284  SDF_API
285  static std::string ComputeRealPath(const std::string &layerPath);
286 
287  /// Returns \c true if successful, \c false if an error occurred.
288  /// Returns \c false if the layer has no remembered file name or the
289  /// layer type cannot be saved. The layer will not be overwritten if the
290  /// file exists and the layer is not dirty unless \p force is true.
291  SDF_API
292  bool Save(bool force = false) const;
293 
294  /// Exports this layer to a file.
295  /// Returns \c true if successful, \c false if an error occurred.
296  ///
297  /// If \p comment is not empty, the layer gets exported with the given
298  /// comment. Additional arguments may be supplied via the \p args parameter.
299  /// These arguments may control behavior specific to the exported layer's
300  /// file format.
301  ///
302  /// Note that the file name or comment of the original layer is not
303  /// updated. This only saves a copy of the layer to the given filename.
304  /// Subsequent calls to Save() will still save the layer to it's
305  /// previously remembered file name.
306  SDF_API
307  bool Export(const std::string& filename,
308  const std::string& comment = std::string(),
309  const FileFormatArguments& args = FileFormatArguments()) const;
310 
311  /// Writes this layer to the given string.
312  ///
313  /// Returns \c true if successful and sets \p result, otherwise
314  /// returns \c false.
315  SDF_API
316  bool ExportToString(std::string* result) const;
317 
318  /// Reads this layer from the given string.
319  ///
320  /// Returns \c true if successful, otherwise returns \c false.
321  SDF_API
322  bool ImportFromString(const std::string &string);
323 
324  /// Clears the layer of all content.
325  ///
326  /// This restores the layer to a state as if it had just been created
327  /// with CreateNew(). This operation is Undo-able.
328  ///
329  /// The fileName and whether journaling is enabled are not affected
330  /// by this method.
331  SDF_API
332  void Clear();
333 
334  /// Reloads the layer from its persistent representation.
335  ///
336  /// This restores the layer to a state as if it had just been created
337  /// with FindOrOpen(). This operation is Undo-able.
338  ///
339  /// The fileName and whether journaling is enabled are not affected
340  /// by this method.
341  ///
342  /// When called with force = false (the default), Reload attempts to
343  /// avoid reloading layers that have not changed on disk. It does so
344  /// by comparing the file's modification time (mtime) to when the
345  /// file was loaded. If the layer has unsaved modifications, this
346  /// mechanism is not used, and the layer is reloaded from disk.
347  ///
348  /// Passing true to the \p force parameter overrides this behavior,
349  /// forcing the layer to be reloaded from disk regardless of whether
350  /// it has changed.
351  SDF_API
352  bool Reload(bool force = false);
353 
354  /// Reloads the specified layers.
355  ///
356  /// Returns \c false if one or more layers failed to reload.
357  ///
358  /// See \c Reload() for a description of the \p force flag.
359  ///
360  SDF_API
361  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
362  bool force = false);
363 
364  /// Imports the content of the given layer path, replacing the content
365  /// of the current layer.
366  /// Note: If the layer path is the same as the current layer's real path,
367  /// no action is taken (and a warning occurs). For this case use
368  /// Reload().
369  SDF_API
370  bool Import(const std::string &layerPath);
371 
372  /// @}
373  /// \name External references
374  /// @{
375 
376  /// Return paths of all external references of layer.
377  SDF_API
378  std::set<std::string> GetExternalReferences();
379 
380  /// Updates the external references of the layer.
381  ///
382  /// If only the old asset path is given, this update works as delete,
383  /// removing any sublayers or prims referencing the pathtype using the
384  /// old asset path as reference.
385  ///
386  /// If new asset path is supplied, the update works as "rename", updating
387  /// any occurrence of the old reference to the new reference.
388  SDF_API
390  const std::string &oldAssetPath,
391  const std::string &newAssetPath=std::string());
392 
393  /// @}
394  /// \name Identification
395  ///
396  /// A layer's identifier is a string that uniquely identifies a layer.
397  /// At minimum, it is the string by which the layer was created, either
398  /// via FindOrOpen or CreateNew. If additional arguments were passed
399  /// to those functions, those arguments will be encoded in the identifier.
400  ///
401  /// For example:
402  /// FindOrOpen('foo.sdf', args={'a':'b', 'c':'d'}).identifier
403  /// => "foo.sdf?sdf_args:a=b&c=d"
404  ///
405  /// Note that this means the identifier may in general not be a path.
406  ///
407  /// The identifier format is subject to change; consumers should NOT
408  /// parse layer identifiers themselves, but should use the supplied
409  /// SplitIdentifier and CreateIdentifier helper functions.
410  ///
411  /// @{
412 
413  /// Splits the given layer identifier into its constituent layer path
414  /// and arguments.
415  SDF_API
416  static bool SplitIdentifier(
417  const std::string& identifier,
418  std::string* layerPath,
419  FileFormatArguments* arguments);
420 
421  /// Joins the given layer path and arguments into an identifier.
422  SDF_API
424  const std::string& layerPath,
425  const FileFormatArguments& arguments);
426 
427  /// Returns the layer identifier.
428  SDF_API
429  const std::string& GetIdentifier() const;
430 
431  /// Sets the layer identifier.
432  /// Note that the new identifier must have the same arguments (if any)
433  /// as the old identifier.
434  SDF_API
435  void SetIdentifier(const std::string& identifier);
436 
437  /// Update layer asset information. Calling this method re-resolves the
438  /// layer identifier, which updates asset information such as the layer
439  /// file revision, real path, and repository path. If \p fileVersion is
440  /// supplied, it is used as the layer version if the identifier does not
441  /// have a version or label specifier. This is typically used to tell Sd
442  /// what the version of a layer is after submitting a new revision to the
443  /// asset system.
444  SDF_API
445  void UpdateAssetInfo(const std::string& fileVersion = std::string());
446 
447  /// Returns the layer's display name.
448  ///
449  /// The display name is the base filename of the identifier.
450  SDF_API
451  std::string GetDisplayName() const;
452 
453  /// Returns the file system path where this layer exists or may exist
454  /// after a call to Save.
455  SDF_API
456  const std::string& GetRealPath() const;
457 
458  /// Returns the file extension to use for this layer.
459  /// If this layer was loaded from disk, it should match the extension
460  /// of the file format it was loaded as; if this is an anonymous
461  /// in-memory layer it will be the default extension.
462  SDF_API
464 
465  /// Returns the asset system version of this layer. If a layer is loaded
466  /// from a location that is not version managed, or a configured asset
467  /// system is not present when the layer is loaded or created, the version
468  /// is empty. By default, asset version tracking is disabled; this method
469  /// returns empty unless asset version tracking is enabled.
470  SDF_API
471  const std::string& GetVersion() const;
472 
473  /// Returns the layer identifier in asset path form. In the presence of a
474  /// properly configured path resolver, the asset path is a double-slash
475  /// prefixed depot path. If the path resolver is not configured, the asset
476  /// path of a layer is empty.
477  SDF_API
478  const std::string& GetRepositoryPath() const;
479 
480  /// Returns the asset name associated with this layer.
481  SDF_API
482  const std::string& GetAssetName() const;
483 
484  /// Returns resolve information from the last time the layer identifier
485  /// was resolved.
486  SDF_API
487  const VtValue& GetAssetInfo() const;
488 
489  /// Make the given \p relativePath absolute using the identifier of this
490  /// layer. If this layer does not have an identifier, or if the layer
491  /// identifier is itself relative, \p relativePath is returned unmodified.
492  SDF_API
493  std::string ComputeAbsolutePath(const std::string &relativePath);
494 
495  /// @}
496 
497  /// \name Fields
498  ///
499  /// All scene description for a given object is stored as a set of
500  /// key/value pairs called fields. These methods provide direct access to
501  /// those fields, though most clients should use the Spec API to ensure
502  /// data consistency.
503  ///
504  /// These methods all take SdfPath to identify the queried spec.
505  ///
506  /// @{
507 
508  /// Return the specifiers for \a path. This returns default constructed
509  /// specifiers if no spec exists at \a path.
510  SDF_API
511  SdfSpecType GetSpecType(const SdfPath& path) const;
512 
513  /// Return whether a spec exists at \a path.
514  SDF_API
515  bool HasSpec(const SdfPath& path) const;
516 
517  /// Return the names of all the fields that are set at \p path.
518  SDF_API
519  std::vector<TfToken> ListFields(const SdfPath& path) const;
520 
521  /// Return whether a value exists for the given \a path and \a fieldName.
522  /// Optionally returns the value if it exists.
523  SDF_API
524  bool HasField(const SdfPath& path, const TfToken& fieldName,
525  VtValue *value=NULL) const;
526  SDF_API
527  bool HasField(const SdfPath& path, const TfToken& fieldName,
528  SdfAbstractDataValue *value) const;
529 
530  /// Returns \c true if the object has a non-empty value with name
531  /// \p name and type \p T. If value ptr is provided, returns the
532  /// value found.
533  template <class T>
534  bool HasField(const SdfPath& path, const TfToken &name,
535  T* value) const
536  {
537  if (!value) {
538  return HasField(path, name, static_cast<VtValue *>(NULL));
539  }
540 
541  SdfAbstractDataTypedValue<T> outValue(value);
542  const bool hasValue = HasField(
543  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
544 
546  return hasValue && outValue.isValueBlock;
547  }
548 
549  return hasValue && (!outValue.isValueBlock);
550  }
551 
552  /// Return the type of the value for \p name on spec \p path. If no such
553  /// field exists, return typeid(void).
554  std::type_info const &GetFieldTypeid(
555  const SdfPath &path, const TfToken &name) const {
556  return _data->GetTypeid(path, name);
557  }
558 
559  /// Return whether a value exists for the given \a path and \a fieldName and
560  /// \a keyPath. The \p keyPath is a ':'-separated path addressing an
561  /// element in sub-dictionaries. Optionally returns the value if it exists.
562  SDF_API
563  bool HasFieldDictKey(const SdfPath& path,
564  const TfToken &fieldName,
565  const TfToken &keyPath,
566  VtValue *value=NULL) const;
567  SDF_API
568  bool HasFieldDictKey(const SdfPath& path,
569  const TfToken &fieldName,
570  const TfToken &keyPath,
571  SdfAbstractDataValue *value) const;
572 
573  /// Returns \c true if the object has a non-empty value with name \p name
574  /// and \p keyPath and type \p T. If value ptr is provided, returns the
575  /// value found. The \p keyPath is a ':'-separated path addressing an
576  /// element in sub-dictionaries.
577  template <class T>
578  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
579  const TfToken &keyPath, T* value) const
580  {
581  if (!value) {
582  return HasFieldDictKey(path, name, keyPath,
583  static_cast<VtValue *>(NULL));
584  }
585 
586  SdfAbstractDataTypedValue<T> outValue(value);
587  return HasFieldDictKey(path, name, keyPath,
588  static_cast<SdfAbstractDataValue *>(&outValue));
589  }
590 
591 
592  /// Return the value for the given \a path and \a fieldName. Returns an
593  /// empty value if none is set.
594  SDF_API
595  VtValue GetField(const SdfPath& path,
596  const TfToken& fieldName) const;
597 
598  /// Return the value for the given \a path and \a fieldName. Returns the
599  /// provided \a defaultValue value if none is set.
600  template <class T>
601  inline T GetFieldAs(const SdfPath& path,
602  const TfToken& fieldName, const T& defaultValue = T()) const
603  {
604  return _data->GetAs<T>(path, fieldName, defaultValue);
605  }
606 
607  /// Return the value for the given \a path and \a fieldName at \p
608  /// keyPath. Returns an empty value if none is set. The \p keyPath is a
609  /// ':'-separated path addressing an element in sub-dictionaries.
610  SDF_API
612  const TfToken& fieldName,
613  const TfToken& keyPath) const;
614 
615  /// Set the value of the given \a path and \a fieldName.
616  SDF_API
617  void SetField(const SdfPath& path, const TfToken& fieldName,
618  const VtValue& value);
619  SDF_API
620  void SetField(const SdfPath& path, const TfToken& fieldName,
622 
623  /// Set the value of the given \a path and \a fieldName.
624  template <class T>
625  void SetField(const SdfPath& path, const TfToken& fieldName,
626  const T& val)
627  {
628  // Ideally, this would make use of the SdfAbstractDataConstValue
629  // API to avoid unnecessarily copying the value into a VtValue.
630  // However, Sdf needs to create a VtValue for change processing.
631  // If the underlying SdAbstractData implementation also needs a
632  // VtValue, using the SdfAbstractDataConstValue API would cause
633  // another copy to be made. So, it's more efficient to just create
634  // the VtValue once here and push that along.
635  SetField(path, fieldName, VtValue(val));
636  }
637 
638  /// Set the value of the given \a path and \a fieldName. The \p keyPath is a
639  /// ':'-separated path addressing an element in sub-dictionaries.
640  SDF_API
641  void SetFieldDictValueByKey(const SdfPath& path,
642  const TfToken& fieldName,
643  const TfToken& keyPath,
644  const VtValue& value);
645  SDF_API
646  void SetFieldDictValueByKey(const SdfPath& path,
647  const TfToken& fieldName,
648  const TfToken& keyPath,
650 
651  /// Set the value of the given \a path and \a fieldName. The \p keyPath is
652  /// a ':'-separated path addressing an element in sub-dictionaries.
653  template <class T>
654  void SetFieldDictValueByKey(const SdfPath& path,
655  const TfToken& fieldName,
656  const TfToken& keyPath,
657  const T& val)
658  {
659  // Ideally, this would make use of the SdfAbstractDataConstValue
660  // API to avoid unnecessarily copying the value into a VtValue.
661  // However, Sdf needs to create a VtValue for change processing.
662  // If the underlying SdAbstractData implementation also needs
663  // VtValue, using the SdfAbstractDataConstValue API would cause
664  // another copy to be made. So, it's more efficient to just create
665  // the VtValue once here and push that along.
666  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
667  }
668 
669  /// Remove the field at \p path and \p fieldName, if one exists.
670  SDF_API
671  void EraseField(const SdfPath& path, const TfToken& fieldName);
672 
673  /// Remove the field at \p path and \p fieldName and \p keyPath, if one
674  /// exists. The \p keyPath is a ':'-separated path addressing an
675  /// element in sub-dictionaries.
676  SDF_API
677  void EraseFieldDictValueByKey(const SdfPath& path,
678  const TfToken& fieldName,
679  const TfToken& keyPath);
680 
681  /// \name Traversal
682  /// @{
683 
684  /// Callback function for Traverse. This callback will be invoked with
685  /// the path of each spec that is visited.
686  /// \sa Traverse
687  typedef std::function<void(const SdfPath&)> TraversalFunction;
688 
689  // Traverse will perform a traversal of the scene description hierarchy
690  // rooted at \a path, calling \a func on each spec that it finds.
691  SDF_API
692  void Traverse(const SdfPath& path, const TraversalFunction& func);
693 
694  /// @}
695 
696  /// \name Metadata
697  /// @{
698 
699  /// Returns the color configuration asset-path for this layer.
700  ///
701  /// The default value is an empty asset-path.
702  SDF_API
704 
705  /// Sets the color configuration asset-path for this layer.
706  SDF_API
707  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
708 
709  /// Returns true if color configuration metadata is set in this layer.
710  /// \sa GetColorConfiguration(), SetColorConfiguration()
711  SDF_API
712  bool HasColorConfiguration() const;
713 
714  /// Clears the color configuration metadata authored in this layer.
715  /// \sa HasColorConfiguration(), SetColorConfiguration()
716  SDF_API
718 
719  /// Returns the color management system used to interpret the color
720  /// configuration asset-path authored in this layer.
721  ///
722  /// The default value is an empty token, which implies that the clients
723  /// will have to determine the color management system from the color
724  /// configuration asset path (i.e. from its file extension), if it's
725  /// specified.
726  SDF_API
728 
729  /// Sets the color management system used to interpret the color
730  /// configuration asset-path authored this layer.
731  SDF_API
732  void SetColorManagementSystem(const TfToken &cms);
733 
734  /// Returns true if colorManagementSystem metadata is set in this layer.
735  /// \sa GetColorManagementSystem(), SetColorManagementSystem()
736  SDF_API
737  bool HasColorManagementSystem() const;
738 
739  /// Clears the 'colorManagementSystem' metadata authored in this layer.
740  /// \sa HascolorManagementSystem(), SetColorManagementSystem()
741  SDF_API
743 
744  /// Returns the comment string for this layer.
745  ///
746  /// The default value for comment is "".
747  SDF_API
748  std::string GetComment() const;
749 
750  /// Sets the comment string for this layer.
751  SDF_API
752  void SetComment(const std::string &comment);
753 
754  /// Return the defaultPrim metadata for this layer. This field
755  /// indicates the name of which root prim should be targeted by a reference
756  /// or payload to this layer that doesn't specify a prim path.
757  ///
758  /// The default value is the empty token.
759  SDF_API
760  TfToken GetDefaultPrim() const;
761 
762  /// Set the default prim metadata for this layer. The root prim with this
763  /// name will be targeted by a reference or a payload to this layer that
764  /// doesn't specify a prim path. Note that this must be a root prim
765  /// <b>name</b> not a path. E.g. "rootPrim" rather than "/rootPrim". See
766  /// GetDefaultPrim().
767  SDF_API
768  void SetDefaultPrim(const TfToken &name);
769 
770  /// Clear the default prim metadata for this layer. See GetDefaultPrim()
771  /// and SetDefaultPrim().
772  SDF_API
773  void ClearDefaultPrim();
774 
775  /// Return true if the default prim metadata is set in this layer. See
776  /// GetDefaultPrim() and SetDefaultPrim().
777  SDF_API
778  bool HasDefaultPrim();
779 
780  /// Returns the documentation string for this layer.
781  ///
782  /// The default value for documentation is "".
783  SDF_API
785 
786  /// Sets the documentation string for this layer.
787  SDF_API
788  void SetDocumentation(const std::string &documentation);
789 
790  /// Returns the layer's start timeCode.
791  ///
792  /// The start and end timeCodes of a layer represent the suggested playback
793  /// range. However, time-varying content is not limited to the timeCode range
794  /// of the layer.
795  ///
796  /// The default value for startTimeCode is 0.
797  SDF_API
798  double GetStartTimeCode() const;
799 
800  /// Sets the layer's start timeCode.
801  SDF_API
802  void SetStartTimeCode(double startTimecode);
803 
804  /// Returns true if the layer has a startTimeCode opinion.
805  SDF_API
806  bool HasStartTimeCode() const;
807 
808  /// Clear the startTimeCode opinion.
809  SDF_API
810  void ClearStartTimeCode();
811 
812  /// Returns the layer's end timeCode.
813  /// The start and end timeCode of a layer represent a suggested playback range.
814  /// However, time-varying content is not limited to the timeCode range of the
815  /// layer.
816  ///
817  /// The default value for endTimeCode is 0.
818  SDF_API
819  double GetEndTimeCode() const;
820 
821  /// Sets the layer's end timeCode.
822  SDF_API
823  void SetEndTimeCode(double endTimeCode);
824 
825  /// Returns true if the layer has an endTimeCode opinion.
826  SDF_API
827  bool HasEndTimeCode() const;
828 
829  /// Clear the endTimeCode opinion.
830  SDF_API
831  void ClearEndTimeCode();
832 
833  /// Returns the layer's timeCodes per second.
834  ///
835  /// Scales the time ordinate for samples contained in the file to seconds.
836  /// If timeCodesPerSecond is 24, then a sample at time ordinate 24 should
837  /// be viewed exactly one second after the sample at time ordinate 0.
838  ///
839  /// If this layer doesn't have an authored value for timeCodesPerSecond, but
840  /// it does have an authored value for framesPerSecond, this method will
841  /// return the value of framesPerSecond. This "dynamic fallback" allows
842  /// layers to lock framesPerSecond and timeCodesPerSecond to the same value
843  /// by specifying only framesPerSecond.
844  ///
845  /// The default value of timeCodesPerSecond (which is used only if there is
846  /// no authored value for either timeCodesPerSecond or framesPerSecond) is
847  /// 24.
848  SDF_API
849  double GetTimeCodesPerSecond() const;
850 
851  /// Sets the layer's timeCodes per second
852  SDF_API
853  void SetTimeCodesPerSecond(double timeCodesPerSecond);
854 
855  /// Returns true if the layer has a timeCodesPerSecond opinion.
856  SDF_API
857  bool HasTimeCodesPerSecond() const;
858 
859  /// Clear the timeCodesPerSecond opinion.
860  SDF_API
862 
863  /// Returns the layer's frames per second.
864  ///
865  /// This makes an advisory statement about how the contained data can be
866  /// most usefully consumed and presented. It's primarily an indication of
867  /// the expected playback rate for the data, but a timeline editing tool
868  /// might also want to use this to decide how to scale and label its
869  /// timeline.
870  ///
871  /// The default value for framesPerSecond is 24.
872  SDF_API
873  double GetFramesPerSecond() const;
874 
875  /// Sets the layer's frames per second
876  SDF_API
877  void SetFramesPerSecond(double framesPerSecond);
878 
879  /// Returns true if the layer has a frames per second opinion.
880  SDF_API
881  bool HasFramesPerSecond() const;
882 
883  /// Clear the framesPerSecond opinion.
884  SDF_API
885  void ClearFramesPerSecond();
886 
887  /// Returns the layer's frame precision.
888  SDF_API
889  int GetFramePrecision() const;
890 
891  /// Sets the layer's frame precision.
892  SDF_API
893  void SetFramePrecision(int framePrecision);
894 
895  /// Returns true if the layer has a frames precision opinion.
896  SDF_API
897  bool HasFramePrecision() const;
898 
899  /// Clear the framePrecision opinion.
900  SDF_API
901  void ClearFramePrecision();
902 
903  /// Returns the layer's owner.
904  SDF_API
905  std::string GetOwner() const;
906 
907  /// Sets the layer's owner.
908  SDF_API
909  void SetOwner(const std::string& owner);
910 
911  /// Returns true if the layer has an owner opinion.
912  SDF_API
913  bool HasOwner() const;
914 
915  /// Clear the owner opinion.
916  SDF_API
917  void ClearOwner();
918 
919  /// Returns the layer's session owner.
920  /// Note: This should only be used by session layers.
921  SDF_API
923 
924  /// Sets the layer's session owner.
925  /// Note: This should only be used by session layers.
926  SDF_API
927  void SetSessionOwner(const std::string& owner);
928 
929  /// Returns true if the layer has a session owner opinion.
930  SDF_API
931  bool HasSessionOwner() const;
932 
933  // Clear the session owner opinion.
934  SDF_API
935  void ClearSessionOwner();
936 
937  /// Returns true if the layer's sublayers are expected to have owners.
938  SDF_API
939  bool GetHasOwnedSubLayers() const;
940 
941  /// Sets whether the layer's sublayers are expected to have owners.
942  SDF_API
943  void SetHasOwnedSubLayers(bool);
944 
945  /// Returns the CustomLayerData dictionary associated with this layer.
946  ///
947  /// This is a dictionary is custom metadata that is associated with
948  /// this layer. It allows users to encode any set of information for
949  /// human or program consumption.
950  SDF_API
952 
953  /// Sets the CustomLayerData dictionary associated with this layer.
954  SDF_API
956 
957  /// Returns true if CustomLayerData is authored on the layer.
958  SDF_API
959  bool HasCustomLayerData() const;
960 
961  /// Clears out the CustomLayerData dictionary associated with this layer.
962  SDF_API
963  void ClearCustomLayerData();
964 
965  /// @}
966  /// \name Prims
967  /// @{
968 
969  // Type for root prims view.
971 
972  /// Returns a vector of the layer's root prims
973  SDF_API
974  RootPrimsView GetRootPrims() const;
975 
976  /// Sets a new vector of root prims.
977  /// You can re-order, insert and remove prims but cannot
978  /// rename them this way. If any of the listed prims have
979  /// an existing owner, they will be reparented.
980  SDF_API
981  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
982 
983  /// Adds a new root prim at the given index.
984  /// If the index is -1, the prim is inserted at the end.
985  /// The layer will take ownership of the prim, via a TfRefPtr.
986  /// Returns true if successful, false if failed (for example,
987  /// due to a duplicate name).
988  SDF_API
989  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
990 
991  /// Remove a root prim.
992  SDF_API
993  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
994 
995  /// Cause \p spec to be removed if it no longer affects the scene when the
996  /// last change block is closed, or now if there are no change blocks.
997  SDF_API
998  void ScheduleRemoveIfInert(const SdfSpec& spec);
999 
1000  /// Removes scene description that does not affect the scene in the
1001  /// layer namespace beginning with \p prim.
1002  ///
1003  /// Calling this method on a prim will only clean up prims with specifier
1004  /// 'over' that are not contributing any opinions. The \p prim will only
1005  /// be removed if all of its nameChildren are also inert. The hierarchy
1006  /// \p prim is defined in will be pruned up to the layer root for each
1007  /// successive inert parent that has specifier 'over'.
1008  ///
1009  /// note: PrimSpecs that contain any PropertySpecs, even PropertySpecs with
1010  /// required fields only (see PropertySpec::HasRequiredFieldsOnly)
1011  /// are not considered inert, and thus the prim won't be removed.
1012  SDF_API
1013  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1014 
1015  /// Removes prop if it has only required fields (i.e. is not
1016  /// contributing any opinions to the scene other than property
1017  /// instantiation).
1018  ///
1019  /// The hierarchy \p prop is defined in will then be pruned up to the
1020  /// layer root for each successive inert parent.
1021  SDF_API
1022  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1023 
1024  /// Removes all scene description in this layer that does not affect the
1025  /// scene.
1026  ///
1027  /// This method walks the layer namespace hierarchy and removes any prims
1028  /// and that are not contributing any opinions.
1029  SDF_API
1031 
1032  /// Returns the list of prim names for this layer's reorder rootPrims
1033  /// statement.
1034  ///
1035  /// See SetRootPrimOrder() for more info.
1036  SDF_API
1038 
1039  /// Given a list of (possible sparse) prim names, authors a reorder
1040  /// rootPrims statement for this prim.
1041  ///
1042  /// This reorder statement can modify the order of root prims that have
1043  /// already been explicitly ordered with InsertRootPrim() or SetRootPrims();
1044  /// but only during composition. Therefore, GetRootPrims(),
1045  /// InsertRootPrim(), SetRootPrims(), etc. do not read, author, or pay any
1046  /// attention to this statement.
1047  SDF_API
1048  void SetRootPrimOrder(const std::vector<TfToken>& names);
1049 
1050  /// Adds a new root prim name in the root prim order.
1051  /// If the index is -1, the name is inserted at the end.
1052  SDF_API
1053  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1054 
1055  /// Removes a root prim name from the root prim order.
1056  SDF_API
1057  void RemoveFromRootPrimOrder(const TfToken & name);
1058 
1059  /// Removes a root prim name from the root prim order by index.
1060  SDF_API
1062 
1063  /// Reorders the given list of prim names according to the reorder rootPrims
1064  /// statement for this layer.
1065  ///
1066  /// This routine employs the standard list editing operations for ordered
1067  /// items in a ListEditor.
1068  SDF_API
1069  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1070 
1071  /// @}
1072  /// \name Sublayers
1073  /// @{
1074 
1075  /// Returns a proxy for this layer's sublayers.
1076  ///
1077  /// Sub-layers are the weaker layers directly included by this layer.
1078  /// They're in order from strongest to weakest and they're all weaker
1079  /// than this layer.
1080  ///
1081  /// Edits through the proxy changes the sublayers. If this layer does
1082  /// not have any sublayers the proxy is empty.
1083  SDF_API
1085 
1086  /// Sets the paths of the layer's sublayers.
1087  SDF_API
1088  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1089 
1090  /// Returns the number of sublayer paths (and offsets).
1091  SDF_API
1092  size_t GetNumSubLayerPaths() const;
1093 
1094  /// Inserts new sublayer path at the given index.
1095  ///
1096  /// The default index of -1 means to insert at the end.
1097  SDF_API
1098  void InsertSubLayerPath(const std::string& path, int index = -1);
1099 
1100  /// Removes sublayer path at the given index.
1101  SDF_API
1102  void RemoveSubLayerPath(int index);
1103 
1104  /// Returns the layer offsets for all the subLayer paths.
1105  SDF_API
1107 
1108  /// Returns the layer offset for the subLayer path at the given index.
1109  SDF_API
1111 
1112  /// Sets the layer offset for the subLayer path at the given index.
1113  SDF_API
1114  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1115 
1116  /// @}
1117  /// \name Muting
1118  /// @{
1119 
1120  /// Returns the set of muted layer paths.
1121  SDF_API
1122  static std::set<std::string> GetMutedLayers();
1123 
1124  /// Returns \c true if the current layer is muted.
1125  SDF_API
1126  bool IsMuted() const;
1127 
1128  /// Returns \c true if the specified layer path is muted.
1129  SDF_API
1130  static bool IsMuted(const std::string &path);
1131 
1132  /// Mutes the current layer if \p muted is \c true, and unmutes it
1133  /// otherwise.
1134  SDF_API
1135  void SetMuted(bool muted);
1136 
1137  /// Add the specified path to the muted layers set.
1138  SDF_API
1139  static void AddToMutedLayers(const std::string &mutedPath);
1140 
1141  /// Remove the specified path from the muted layers set.
1142  SDF_API
1143  static void RemoveFromMutedLayers(const std::string &mutedPath);
1144 
1145  /// @}
1146  /// \name Lookup
1147  /// @{
1148 
1149  /// Returns the layer's pseudo-root prim.
1150  ///
1151  /// The layer's root prims are namespace children of the pseudo-root.
1152  /// The pseudo-root exists to make the namespace hierarchy a tree
1153  /// instead of a forest. This simplifies the implementation of
1154  /// some algorithms.
1155  ///
1156  /// A layer always has a pseudo-root prim.
1157  SDF_API
1158  SdfPrimSpecHandle GetPseudoRoot() const;
1159 
1160  /// Returns the object at the given \p path.
1161  ///
1162  /// There is no distinction between an absolute and relative path
1163  /// at the SdLayer level.
1164  ///
1165  /// Returns \c NULL if there is no object at \p path.
1166  SDF_API
1167  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1168 
1169  /// Returns the prim at the given \p path.
1170  ///
1171  /// Returns \c NULL if there is no prim at \p path.
1172  /// This is simply a more specifically typed version of
1173  /// \c GetObjectAtPath().
1174  SDF_API
1175  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1176 
1177  /// Returns a property at the given \p path.
1178  ///
1179  /// Returns \c NULL if there is no property at \p path.
1180  /// This is simply a more specifically typed version of
1181  /// \c GetObjectAtPath().
1182  SDF_API
1183  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1184 
1185  /// Returns an attribute at the given \p path.
1186  ///
1187  /// Returns \c NULL if there is no attribute at \p path.
1188  /// This is simply a more specifically typed version of
1189  /// \c GetObjectAtPath().
1190  SDF_API
1191  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1192 
1193  /// Returns a relationship at the given \p path.
1194  ///
1195  /// Returns \c NULL if there is no relationship at \p path.
1196  /// This is simply a more specifically typed version of
1197  /// \c GetObjectAtPath().
1198  SDF_API
1199  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1200 
1201  /// @}
1202  /// \name Permissions
1203  /// @{
1204 
1205  /// Returns true if the caller is allowed to modify the layer and
1206  /// false otherwise. A layer may have to perform some action to acquire
1207  /// permission to be edited.
1208  SDF_API
1209  bool PermissionToEdit() const;
1210 
1211  /// Returns true if the caller is allowed to save the layer to its
1212  /// existing fileName and false otherwise.
1213  SDF_API
1214  bool PermissionToSave() const;
1215 
1216  /// Sets permission to edit.
1217  SDF_API
1218  void SetPermissionToEdit(bool allow);
1219 
1220  /// Sets permission to save.
1221  SDF_API
1222  void SetPermissionToSave(bool allow);
1223 
1224  /// @}
1225  /// \name Batch namespace editing
1226  /// @{
1227 
1228  /// Check if a batch of namespace edits will succeed. This returns
1229  /// \c SdfNamespaceEditDetail::Okay if they will succeed as a batch,
1230  /// \c SdfNamespaceEditDetail::Unbatched if the edits will succeed but
1231  /// will be applied unbatched, and \c SdfNamespaceEditDetail::Error
1232  /// if they will not succeed. No edits will be performed in any case.
1233  ///
1234  /// If \p details is not \c NULL and the method does not return \c Okay
1235  /// then details about the problems will be appended to \p details. A
1236  /// problem may cause the method to return early, so \p details may not
1237  /// list every problem.
1238  ///
1239  /// Note that Sdf does not track backpointers so it's unable to fix up
1240  /// targets/connections to namespace edited objects. Clients must fix
1241  /// those to prevent them from falling off. In addition, this method
1242  /// will report failure if any relational attribute with a target to
1243  /// a namespace edited object is subsequently edited (in the same
1244  /// batch). Clients should perform edits on relational attributes
1245  /// first.
1246  ///
1247  /// Clients may wish to report unbatch details to the user to confirm
1248  /// that the edits should be applied unbatched. This will give the
1249  /// user a chance to correct any problems that cause batching to fail
1250  /// and try again.
1251  SDF_API
1254  SdfNamespaceEditDetailVector* details = NULL) const;
1255 
1256  /// Performs a batch of namespace edits. Returns \c true on success
1257  /// and \c false on failure. On failure, no namespace edits will have
1258  /// occurred.
1259  SDF_API
1260  bool Apply(const SdfBatchNamespaceEdit&);
1261 
1262  /// @}
1263  /// \name Layer state
1264  /// @{
1265 
1266  /// Returns the state delegate used to manage this layer's authoring
1267  /// state.
1268  SDF_API
1269  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1270 
1271  /// Sets the state delegate used to manage this layer's authoring
1272  /// state. The 'dirty' state of this layer will be transferred to
1273  /// the new delegate.
1274  SDF_API
1275  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1276 
1277  /// Returns \c true if the layer is dirty, i.e. has changed from
1278  /// its persistent representation.
1279  SDF_API
1280  bool IsDirty() const;
1281 
1282  /// @}
1283 
1284  /// \name Time-sample API
1285  /// @{
1286  SDF_API
1287  std::set<double> ListAllTimeSamples() const;
1288 
1289  SDF_API
1290  std::set<double>
1291  ListTimeSamplesForPath(const SdfPath& path) const;
1292 
1293  SDF_API
1294  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1295 
1296  SDF_API
1297  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1298 
1299  SDF_API
1300  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1301  double time,
1302  double* tLower, double* tUpper);
1303 
1304  SDF_API
1305  bool QueryTimeSample(const SdfPath& path, double time,
1306  VtValue *value=NULL) const;
1307  SDF_API
1308  bool QueryTimeSample(const SdfPath& path, double time,
1309  SdfAbstractDataValue *value) const;
1310 
1311  template <class T>
1312  bool QueryTimeSample(const SdfPath& path, double time,
1313  T* data) const
1314  {
1315  if (!data) {
1316  return QueryTimeSample(path, time);
1317  }
1318 
1319  SdfAbstractDataTypedValue<T> outValue(data);
1320  const bool hasValue = QueryTimeSample(
1321  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1322 
1324  return hasValue && outValue.isValueBlock;
1325  }
1326 
1327  return hasValue && (!outValue.isValueBlock);
1328  }
1329 
1330  SDF_API
1331  void SetTimeSample(const SdfPath& path, double time,
1332  const VtValue & value);
1333  SDF_API
1334  void SetTimeSample(const SdfPath& path, double time,
1336 
1337  template <class T>
1338  void SetTimeSample(const SdfPath& path, double time,
1339  const T& value)
1340  {
1341  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1342  const SdfAbstractDataConstValue& untypedInValue = inValue;
1343  return SetTimeSample(path, time, untypedInValue);
1344  }
1345 
1346  SDF_API
1347  void EraseTimeSample(const SdfPath& path, double time);
1348 
1349  /// @}
1350 
1351  // Debugging
1352  // @{
1353 
1354  SDF_API
1355  static void DumpLayerInfo();
1356 
1357  // Write this layer's SdfData to a file in a simple generic format.
1358  SDF_API
1359  bool WriteDataFile(const std::string &filename);
1360 
1361  // @}
1362 
1363 protected:
1364  // Private constructor -- use New(), FindOrCreate(), etc.
1365  // Precondition: _layerRegistryMutex must be locked.
1366  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1367  const std::string &identifier,
1368  const std::string &realPath = std::string(),
1369  const ArAssetInfo& assetInfo = ArAssetInfo(),
1371  bool validateAuthoring = false);
1372 
1373 private:
1374  // Create a new layer.
1375  // Precondition: _layerRegistryMutex must be locked.
1376  static SdfLayerRefPtr _CreateNew(
1377  SdfFileFormatConstPtr fileFormat,
1378  const std::string& identifier,
1379  const std::string& realPath,
1380  const ArAssetInfo& assetInfo = ArAssetInfo(),
1382 
1383  static SdfLayerRefPtr _CreateNewWithFormat(
1384  const SdfFileFormatConstPtr &fileFormat,
1385  const std::string& identifier,
1386  const std::string& realPath,
1387  const ArAssetInfo& assetInfo = ArAssetInfo(),
1389 
1390  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1391  const SdfFileFormatConstPtr &fileFormat,
1392  const std::string& tag,
1393  const FileFormatArguments& args);
1394 
1395  // Finish initializing this layer (which may have succeeded or not)
1396  // and publish the results to other threads by unlocking the mutex.
1397  // Sets _initializationWasSuccessful and unlocks _initializationMutex.
1398  void _FinishInitialization(bool success);
1399 
1400  // Layers retrieved from the layer registry may still be in the
1401  // process of having their contents initialized. Other threads
1402  // retrieving layers from the registry must wait until initialization
1403  // is complete, using this method. See _initializationMutex.
1404  // Returns _initializationWasSuccessful.
1405  //
1406  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1407  // ensure that it is not deleted out from under them, in
1408  // case initialization fails. (This method cannot acquire the
1409  // reference itself internally without being susceptible to a race.)
1410  bool _WaitForInitializationAndCheckIfSuccessful();
1411 
1412  // Returns whether or not this menv layer should post change
1413  // notification. This simply returns (!_GetIsLoading())
1414  bool _ShouldNotify() const;
1415 
1416  // This function keeps track of the last state of IsDirty() before
1417  // updating it. It returns false if the last saved dirty state is the
1418  // same than the current state. It returns true if the state differs and
1419  // will update the 'last dirty state' to the current state. So, after
1420  // returning true, it would return false for subsequent calls until the
1421  // IsDirty() state would change again...
1422  bool _UpdateLastDirtinessState() const;
1423 
1424  // Returns a handle to the spec at the given path if it exists and matches
1425  // type T.
1426  template <class T>
1427  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1428 
1429  // Returns true if a spec can be retrieved at the given path, false
1430  // otherwise. This function will return the canonicalized path to the
1431  // spec as well as the spec type.
1432  bool _CanGetSpecAtPath(const SdfPath& path,
1433  SdfPath* canonicalPath, SdfSpecType* specType) const;
1434 
1435  /// Initialize layer internals that are based on it's path.
1436  /// This includes the asset path and show path the layer to be loaded
1437  /// reflects at the point of initialization.
1438  void _InitializeFromIdentifier(
1439  const std::string &identifier,
1440  const std::string &realPath = std::string(),
1441  const std::string &fileVersion = std::string(),
1442  const ArAssetInfo& assetInfo = ArAssetInfo());
1443 
1444  // Helper for computing the necessary information to lookup a layer
1445  // in the registry or open the layer.
1446  struct _FindOrOpenLayerInfo;
1447  static bool _ComputeInfoToFindOrOpenLayer(
1448  const std::string& identifier,
1450  _FindOrOpenLayerInfo* info,
1451  bool computeAssetInfo = false);
1452 
1453  // Open a layer, adding an entry to the registry and releasing
1454  // the registry lock.
1455  // Precondition: _layerRegistryMutex must be locked.
1456  template <class Lock>
1457  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1458  Lock &lock,
1459  const _FindOrOpenLayerInfo& info,
1460  bool metadataOnly);
1461 
1462  // Helper function to try to find the layer with \p identifier and
1463  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1464  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1465  // released upon return. Otherwise the lock is released upon return if a
1466  // layer is found successfully. If no layer is found then the lock is
1467  // upgraded to a writer lock upon return. Note that this upgrade may not be
1468  // atomic, but this function ensures that if upon return there does not
1469  // exist a matching layer in the registry.
1470  template <class ScopedLock>
1471  static SdfLayerRefPtr
1472  _TryToFindLayer(const std::string &identifier,
1473  const std::string &resolvedPath,
1474  ScopedLock &lock, bool retryAsWriter);
1475 
1476  /// Returns true if the spec at the specified path has no effect on the
1477  /// scene.
1478  ///
1479  /// If ignoreChildren is true, this will ignore prim and property
1480  /// children of prim specs. Property specs are always considered to be
1481  /// non-inert unless they have only required fields and
1482  /// requiredFieldOnlyPropertiesareInert is set to false.
1483  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1484  bool requiredFieldOnlyPropertiesAreInert = false) const;
1485 
1486  /// Return true if the entire subtree rooted at \a path does not affect the
1487  /// scene. For this purpose, property specs that have only required fields
1488  /// are considered inert.
1489  ///
1490  /// If this function returns true and \p inertSpecs is given, it will be
1491  /// populated with the paths to all inert prim and property specs at and
1492  /// beneath \p path. These paths will be sorted so that child paths
1493  /// appear before their parent path.
1494  bool _IsInertSubtree(const SdfPath &path,
1495  std::vector<SdfPath>* inertSpecs = nullptr);
1496 
1497  /// Cause \p spec to be removed if it does not affect the scene. This
1498  /// removes any empty descendants before checking if \p spec itself is
1499  /// inert. Property specs are always considered non-inert, so this will
1500  /// remove them if they have only required fields (see
1501  /// PropertySpec::HasOnlyRequiredFields). This also removes inert ancestors.
1502  void _RemoveIfInert(const SdfSpec& spec);
1503 
1504  /// Performs a depth first search of the namespace hierarchy, beginning at
1505  /// \p prim, removing prims that do not affect the scene. The return value
1506  /// indicates whether the prim passed in is now inert as a result of this
1507  /// call, and can itself be removed.
1508  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1509 
1510  /// If \p prim is inert (has no affect on the scene), removes prim, then
1511  /// prunes inert parent prims back to the root.
1512  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1513 
1514  /// Returns whether this layer is validating authoring operations.
1515  bool _ValidateAuthoring() const { return _validateAuthoring; }
1516 
1517  /// Returns the path used in the muted layers set.
1518  std::string _GetMutedPath() const;
1519 
1520  // If old and new asset path is given, rename all external prim
1521  // references referring to the old path.
1522  void _UpdateReferencePaths(const SdfPrimSpecHandle &parent,
1523  const std::string &oldLayerPath,
1524  const std::string &newLayerPath);
1525 
1526  // Set the clean state to the current state.
1527  void _MarkCurrentStateAsClean() const;
1528 
1529  // Return the field definition for \p fieldName if \p fieldName is a
1530  // required field for the spec type identified by \p path.
1531  inline SdfSchema::FieldDefinition const *
1532  _GetRequiredFieldDef(const SdfPath &path,
1533  const TfToken &fieldName,
1534  SdfSpecType specType = SdfSpecTypeUnknown) const;
1535 
1536  // Set a value.
1537  template <class T>
1538  void _SetValue(const TfToken& key, T value);
1539 
1540  // Get a value.
1541  template <class T>
1542  T _GetValue(const TfToken& key) const;
1543 
1544  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1545  _ReloadResult _Reload(bool force);
1546 
1547  // Reads contents of asset specified by \p identifier with resolved
1548  // path \p resolvedPath into this layer.
1549  bool _Read(const std::string& identifier,
1550  const std::string& resolvedPath,
1551  bool metadataOnly);
1552 
1553  // Saves this layer if it is dirty or the layer doesn't already exist
1554  // on disk. If \p force is true, the layer will be written out
1555  // regardless of those conditions.
1556  bool _Save(bool force) const;
1557 
1558  // A helper method used by Save and Export.
1559  // This method allows Save to specify the existing file format and Export
1560  // to use the format provided by the file extension in newFileName. If no
1561  // file format can be discovered from the file name, the existing file
1562  // format associated with the layer will be used in both cases. This allows
1563  // users to export and save to any file name, regardless of extension.
1564  bool _WriteToFile(const std::string& newFileName,
1565  const std::string& comment,
1566  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1568  const;
1569 
1570  // Swap contents of _data and data. This operation does not register
1571  // inverses or emit change notification.
1572  void _SwapData(SdfAbstractDataRefPtr &data);
1573 
1574  // Set _data to match data, calling other primitive setter methods
1575  // to provide fine-grained inverses and notification.
1576  void _SetData(const SdfAbstractDataPtr &data);
1577 
1578  // Returns const handle to _data.
1579  SdfAbstractDataConstPtr _GetData() const;
1580 
1581  // Inverse primitive for setting a single field.
1582  template <class T>
1583  void _PrimSetField(const SdfPath& path,
1584  const TfToken& fieldName,
1585  const T& value,
1586  const VtValue *oldValue = NULL,
1587  bool useDelegate = true);
1588 
1589  // Inverse primitive for setting a single key in a dict-valued field.
1590  template <class T>
1591  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1592  const TfToken& fieldName,
1593  const TfToken& keyPath,
1594  const T& value,
1595  const VtValue *oldValue = NULL,
1596  bool useDelegate = true);
1597 
1598  // Primitive for appending a child to the list of children.
1599  template <class T>
1600  void _PrimPushChild(const SdfPath& parentPath,
1601  const TfToken& fieldName,
1602  const T& value,
1603  bool useDelegate = true);
1604  template <class T>
1605  void _PrimPopChild(const SdfPath& parentPath,
1606  const TfToken& fieldName,
1607  bool useDelegate = true);
1608 
1609  // Move all the fields at all paths at or below \a oldPath to be
1610  // at a corresponding location at or below \a newPath. This does
1611  // not update the children fields of the parents of these paths.
1612  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1613 
1614  // Inverse primitive for moving a spec.
1615  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1616  bool useDelegate = true);
1617 
1618  // Create a new spec of type \p specType at \p path.
1619  // Returns true if spec was successfully created, false otherwise.
1620  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1621 
1622  // Delete all the fields at or below the specified path. This does
1623  // not update the children field of the parent of \a path.
1624  bool _DeleteSpec(const SdfPath &path);
1625 
1626  // Inverse primitive for deleting a spec.
1627  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1628  bool useDelegate = true);
1629 
1630  // Inverse primitive for deleting a spec.
1631  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1632  bool useDelegate = true);
1633 
1634  // Inverse primitive for setting time samples.
1635  template <class T>
1636  void _PrimSetTimeSample(const SdfPath& path, double time,
1637  const T& value,
1638  bool useDelegate = true);
1639 
1640  // Helper method for Traverse. Visits the children of \a path using the
1641  // specified \a ChildPolicy.
1642  template <typename ChildPolicy>
1643  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1644 
1645 private:
1646  SdfLayerHandle _self;
1647 
1648  // File format and arguments for this layer.
1649  SdfFileFormatConstPtr _fileFormat;
1650  FileFormatArguments _fileFormatArgs;
1651 
1652  // Registry of Sdf Identities
1653  mutable Sdf_IdentityRegistry _idRegistry;
1654 
1655  // The underlying SdfData which stores all the data in the layer.
1656  SdfAbstractDataRefPtr _data;
1657 
1658  // The state delegate for this layer.
1659  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1660 
1661  // Atomic variable protecting layer initialization -- the interval between
1662  // adding a layer to the layer registry and finishing the process of
1663  // initializing its contents, at which point we can truly publish the layer
1664  // for consumption by concurrent threads. We add the layer to the registry
1665  // before initialization completes so that other threads can discover and
1666  // wait for it to finish initializing.
1667  std::atomic<bool> _initializationComplete;
1668 
1669  // This is an optional<bool> that is only set once initialization
1670  // is complete, while _initializationMutex is locked. If the
1671  // optional<bool> is unset, initialization is still underway.
1672  hboost::optional<bool> _initializationWasSuccessful;
1673 
1674  // remembers the last 'IsDirty' state.
1675  mutable bool _lastDirtyState;
1676 
1677  // Asset information for this layer.
1678  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1679 
1680  // Modification timestamp of the backing file asset when last read.
1681  mutable VtValue _assetModificationTime;
1682 
1683  // Mutable revision number for cache invalidation.
1684  mutable size_t _mutedLayersRevisionCache;
1685 
1686  // Cache of whether or not this layer is muted. Only valid if
1687  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1688  mutable bool _isMutedCache;
1689 
1690  // Layer permission bits.
1691  bool _permissionToEdit;
1692  bool _permissionToSave;
1693 
1694  // Whether layer edits are validated.
1695  bool _validateAuthoring;
1696 
1697  // Allow access to _ValidateAuthoring() and _IsInert().
1698  friend class SdfSpec;
1699  friend class SdfPropertySpec;
1700  friend class SdfAttributeSpec;
1701 
1702  friend class Sdf_ChangeManager;
1703 
1704  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1705  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1706 
1707  // Give the file format access to our data. Limit breaking encapsulation
1708  // to the base SdFileFormat class so we don't have to friend every
1709  // implementation here.
1710  friend class SdfFileFormat;
1711 
1712  // Give layer state delegates access to our data as well as to
1713  // the various _Prim functions.
1715 };
1716 
1718 
1719 #endif // PXR_USD_SDF_LAYER_H
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
SDF_API void ClearColorConfiguration()
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
SDF_API bool HasDefaultPrim()
SDF_API void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)
Definition: layer.h:93
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Definition: layer.h:601
SDF_API SdfAssetPath GetColorConfiguration() const
SDF_API void EraseTimeSample(const SdfPath &path, double time)
Result
Validity of an edit.
GT_API const UT_StringHolder filename
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API bool WriteDataFile(const std::string &filename)
SDF_API void RemoveInertSceneDescription()
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
GLuint const GLchar * name
Definition: glew.h:1814
SDF_API VtDictionary GetCustomLayerData() const
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API void EraseFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath)
bool HasFieldDictKey(const SdfPath &path, const TfToken &name, const TfToken &keyPath, T *value) const
Definition: layer.h:578
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(SdfFileFormat)
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API bool ExportToString(std::string *result) const
const Args & args
Definition: printf.h:628
GT_API const UT_StringHolder time
SDF_API const VtValue & GetAssetInfo() const
GLuint index
Definition: glew.h:1814
static SDF_API bool SplitIdentifier(const std::string &identifier, std::string *layerPath, FileFormatArguments *arguments)
GLuint const GLfloat * val
Definition: glew.h:2794
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API void SetDefaultPrim(const TfToken &name)
std::map< std::string, std::string > FileFormatArguments
Definition: layer.h:119
SDF_API bool QueryTimeSample(const SdfPath &path, double time, VtValue *value=NULL) const
SDF_API void ClearSessionOwner()
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
std::type_info const & GetFieldTypeid(const SdfPath &path, const TfToken &name) const
Definition: layer.h:554
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API void Traverse(const SdfPath &path, const TraversalFunction &func)
TF_API const TfNullPtrType TfNullPtr
TF_DECLARE_WEAK_AND_REF_PTRS(SdfLayerStateDelegateBase)
Definition: spec.h:51
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
friend class Sdf_ChangeManager
Definition: layer.h:1702
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
SDF_API bool PermissionToEdit() const
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
std::set< SdfHandleTo< SdfLayer >::Handle > SdfLayerHandleSet
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
SDF_API void ScheduleRemoveIfInert(const SdfSpec &spec)
std::function< void(const SdfPath &)> TraversalFunction
Definition: layer.h:687
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
SDF_API std::string GetDocumentation() const
SDF_API void SetPermissionToSave(bool allow)
Sets permission to save.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
SDF_API bool Import(const std::string &layerPath)
SDF_API const std::string & GetRepositoryPath() const
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API std::set< double > ListTimeSamplesForPath(const SdfPath &path) const
GLenum GLsizei GLsizei GLsizei GLsizei layers
Definition: glew.h:2864
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API double GetTimeCodesPerSecond() const
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetSessionOwner() const
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
SDF_API bool Reload(bool force=false)
SDF_API double GetStartTimeCode() const
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API void ClearOwner()
Clear the owner opinion.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const std::string &realPath=std::string(), const FileFormatArguments &args=FileFormatArguments())
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
SDF_API void SetColorManagementSystem(const TfToken &cms)
SDF_API void UpdateAssetInfo(const std::string &fileVersion=std::string())
std::vector< SdfLayerOffset > SdfLayerOffsetVector
Definition: layerOffset.h:155
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath=std::string(), const FileFormatArguments &args=FileFormatArguments())
Definition: token.h:87
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
SDF_API void SetSessionOwner(const std::string &owner)
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
static SDF_API std::string ComputeRealPath(const std::string &layerPath)
Converts layerPath to a file system path.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
SDF_API double GetFramesPerSecond() const
SDF_API void ClearDefaultPrim()
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
SDF_API void Clear()
static SDF_API std::string GetDisplayNameFromIdentifier(const std::string &identifier)
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
SDF_API bool ImportFromString(const std::string &string)
GLuint const GLuint * names
Definition: glew.h:2690
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SdfPrimSpecView RootPrimsView
Returns a vector of the layer's root prims.
Definition: layer.h:970
SDF_API void SetRootPrimOrder(const std::vector< TfToken > &names)
SDF_API bool Export(const std::string &filename, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
SDF_API double GetEndTimeCode() const
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API const std::string & GetRealPath() const
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API TfToken GetColorManagementSystem() const
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const T &val)
Definition: layer.h:654
Definition: path.h:288
SdfLayer & operator=(const SdfLayer &)=delete
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
SDF_API bool GetBracketingTimeSamples(double time, double *tLower, double *tUpper)
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
SDF_API std::string GetDisplayName() const
GLsizei const GLchar *const * path
Definition: glew.h:6461
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
#define SDF_API
Definition: api.h:40
SDF_API void SetIdentifier(const std::string &identifier)
GLsizei const GLchar *const * string
Definition: glew.h:1844
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
bool HasField(const SdfPath &path, const TfToken &name, T *value) const
Definition: layer.h:534
GLenum func
Definition: glcorearb.h:782
SDF_API std::string GetFileExtension() const
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
SDF_API bool GetBracketingTimeSamplesForPath(const SdfPath &path, double time, double *tLower, double *tUpper)
SDF_API void TransferContent(const SdfLayerHandle &layer)
void SetField(const SdfPath &path, const TfToken &fieldName, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:625
bool QueryTimeSample(const SdfPath &path, double time, T *data) const
Definition: layer.h:1312
SDF_API bool HasColorManagementSystem() const
SdfSpecType
Definition: types.h:91
SDF_API std::string GetOwner() const
Returns the layer's owner.
SDF_API void SetMuted(bool muted)
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API bool PermissionToSave() const
virtual SDF_API ~SdfLayer()
Destructor.
SDF_API bool HasColorConfiguration() const
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API void SetTimeSample(const SdfPath &path, double time, const VtValue &value)
GLint GLboolean GLint layer
Definition: glew.h:3601
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
SDF_API std::set< std::string > GetExternalReferences()
Return paths of all external references of layer.
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
GLuint64EXT * result
Definition: glew.h:14007
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API TfToken GetDefaultPrim() const
static SDF_API SdfLayerHandle FindRelativeToLayer(const SdfLayerHandle &anchor, const std::string &layerPath, const FileFormatArguments &args=FileFormatArguments())
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
static SDF_API void DumpLayerInfo()
SDF_API size_t GetNumTimeSamplesForPath(const SdfPath &path) const
SDF_API const std::string & GetVersion() const
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
GLsizei const GLfloat * value
Definition: glew.h:1849
SDF_API const SdfSchemaBase & GetSchema() const
SDF_API bool IsDirty() const
SDF_API void ApplyRootPrimOrder(std::vector< TfToken > *vec) const
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void ClearColorManagementSystem()
Definition: value.h:174
SDF_API std::string GetComment() const
SDF_API bool Save(bool force=false) const
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
SDF_API std::set< double > ListAllTimeSamples() const
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
static SDF_API SdfLayerHandle Find(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
void SetTimeSample(const SdfPath &path, double time, const T &value)
Definition: layer.h:1338
SDF_API std::string ComputeAbsolutePath(const std::string &relativePath)
GLintptr offset
Definition: glew.h:1682