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 //
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
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
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"
34 #include "pxr/usd/sdf/layerHints.h"
37 #include "pxr/usd/sdf/path.h"
38 #include "pxr/usd/sdf/proxyTypes.h"
39 #include "pxr/usd/sdf/spec.h"
40 #include "pxr/usd/sdf/types.h"
41 #include "pxr/usd/ar/ar.h"
42 #include "pxr/usd/ar/assetInfo.h"
45 #include "pxr/base/vt/value.h"
47 #include <boost/optional.hpp>
49 #include <atomic>
50 #include <functional>
51 #include <memory>
52 #include <set>
53 #include <string>
54 #include <vector>
61 struct Sdf_AssetInfo;
96 class SdfLayer
97  : public TfRefBase
98  , public TfWeakBase
99 {
100 public:
102  SDF_API
103  virtual ~SdfLayer();
106  SdfLayer(const SdfLayer&) = delete;
107  SdfLayer& operator=(const SdfLayer&) = delete;
115  SDF_API const SdfSchemaBase& GetSchema() const;
118  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
122  typedef std::map<std::string, std::string> FileFormatArguments;
126  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
133  SDF_API
134  static SdfLayerRefPtr CreateNew(const std::string &identifier,
135  const FileFormatArguments &args =
144  SDF_API
145  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
146  const std::string &identifier,
147  const FileFormatArguments &args =
158  SDF_API
159  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
160  const std::string &identifier,
161  const FileFormatArguments &args =
170  SDF_API
171  static SdfLayerHandle Find(
172  const std::string &identifier,
173  const FileFormatArguments &args = FileFormatArguments());
185  SDF_API
186  static SdfLayerHandle FindRelativeToLayer(
187  const SdfLayerHandle &anchor,
188  const std::string &identifier,
189  const FileFormatArguments &args = FileFormatArguments());
197  SDF_API
198  static SdfLayerRefPtr FindOrOpen(
199  const std::string &identifier,
200  const FileFormatArguments &args = FileFormatArguments());
212  SDF_API
214  const SdfLayerHandle &anchor,
215  const std::string &identifier,
216  const FileFormatArguments &args = FileFormatArguments());
231  SDF_API
233  const std::string &layerPath,
234  bool metadataOnly = false,
235  const std::string& tag = std::string());
238  SDF_API
239  SdfDataRefPtr GetMetadata() const;
244  SDF_API
245  SdfLayerHints GetHints() const;
248  SDF_API
249  static SdfLayerHandleSet GetLoadedLayers();
252  SDF_API
253  bool IsEmpty() const;
257  SDF_API
258  void TransferContent(const SdfLayerHandle& layer);
274  SDF_API
276  const std::string& tag = std::string(),
277  const FileFormatArguments& args = FileFormatArguments());
280  SDF_API
282  const std::string &tag, const SdfFileFormatConstPtr &format,
283  const FileFormatArguments& args = FileFormatArguments());
286  SDF_API
287  bool IsAnonymous() const;
291  SDF_API
292  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
296  SDF_API
297  static std::string GetDisplayNameFromIdentifier(
298  const std::string& identifier);
308  SDF_API
309  bool Save(bool force = false) const;
323  SDF_API
324  bool Export(const std::string& filename,
325  const std::string& comment = std::string(),
326  const FileFormatArguments& args = FileFormatArguments()) const;
332  SDF_API
333  bool ExportToString(std::string* result) const;
338  SDF_API
339  bool ImportFromString(const std::string &string);
348  SDF_API
349  void Clear();
372  SDF_API
373  bool Reload(bool force = false);
381  SDF_API
382  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
383  bool force = false);
390  SDF_API
391  bool Import(const std::string &layerPath);
399  SDF_API
400  std::set<std::string> GetExternalReferences() const;
404  SDF_API
406  const std::string &oldAssetPath,
407  const std::string &newAssetPath=std::string());
416  SDF_API
417  std::set<std::string> GetCompositionAssetDependencies() const;
428  SDF_API
430  const std::string &oldAssetPath,
431  const std::string &newAssetPath=std::string());
441  SDF_API
442  std::set<std::string> GetExternalAssetDependencies() const;
466  SDF_API
467  static bool SplitIdentifier(
468  const std::string& identifier,
469  std::string* layerPath,
470  FileFormatArguments* arguments);
473  SDF_API
474  static std::string CreateIdentifier(
475  const std::string& layerPath,
476  const FileFormatArguments& arguments);
479  SDF_API
480  const std::string& GetIdentifier() const;
485  SDF_API
486  void SetIdentifier(const std::string& identifier);
492 #if AR_VERSION == 1
493  SDF_API
494  void UpdateAssetInfo(const std::string& fileVersion = std::string());
495 #else
496  SDF_API
497  void UpdateAssetInfo();
498 #endif
503  SDF_API
504  std::string GetDisplayName() const;
508  SDF_API
509  const ArResolvedPath& GetResolvedPath() const;
513  SDF_API
514  const std::string& GetRealPath() const;
520  SDF_API
521  std::string GetFileExtension() const;
528  SDF_API
529  const std::string& GetVersion() const;
535  SDF_API
536  const std::string& GetRepositoryPath() const;
539  SDF_API
540  const std::string& GetAssetName() const;
544  SDF_API
545  const VtValue& GetAssetInfo() const;
562  SDF_API
563  std::string ComputeAbsolutePath(const std::string& assetPath) const;
580  SDF_API
581  SdfSpecType GetSpecType(const SdfPath& path) const;
584  SDF_API
585  bool HasSpec(const SdfPath& path) const;
588  SDF_API
589  std::vector<TfToken> ListFields(const SdfPath& path) const;
593  SDF_API
594  bool HasField(const SdfPath& path, const TfToken& fieldName,
595  VtValue *value=NULL) const;
596  SDF_API
597  bool HasField(const SdfPath& path, const TfToken& fieldName,
598  SdfAbstractDataValue *value) const;
603  template <class T>
604  bool HasField(const SdfPath& path, const TfToken &name,
605  T* value) const
606  {
607  if (!value) {
608  return HasField(path, name, static_cast<VtValue *>(NULL));
609  }
611  SdfAbstractDataTypedValue<T> outValue(value);
612  const bool hasValue = HasField(
613  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
615  if (std::is_same<T, SdfValueBlock>::value) {
616  return hasValue && outValue.isValueBlock;
617  }
619  return hasValue && (!outValue.isValueBlock);
620  }
624  std::type_info const &GetFieldTypeid(
625  const SdfPath &path, const TfToken &name) const {
626  return _data->GetTypeid(path, name);
627  }
632  SDF_API
633  bool HasFieldDictKey(const SdfPath& path,
634  const TfToken &fieldName,
635  const TfToken &keyPath,
636  VtValue *value=NULL) const;
637  SDF_API
638  bool HasFieldDictKey(const SdfPath& path,
639  const TfToken &fieldName,
640  const TfToken &keyPath,
641  SdfAbstractDataValue *value) const;
647  template <class T>
648  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
649  const TfToken &keyPath, T* value) const
650  {
651  if (!value) {
652  return HasFieldDictKey(path, name, keyPath,
653  static_cast<VtValue *>(NULL));
654  }
656  SdfAbstractDataTypedValue<T> outValue(value);
657  return HasFieldDictKey(path, name, keyPath,
658  static_cast<SdfAbstractDataValue *>(&outValue));
659  }
664  SDF_API
665  VtValue GetField(const SdfPath& path,
666  const TfToken& fieldName) const;
670  template <class T>
671  inline T GetFieldAs(const SdfPath& path,
672  const TfToken& fieldName, const T& defaultValue = T()) const
673  {
674  return _data->GetAs<T>(path, fieldName, defaultValue);
675  }
680  SDF_API
682  const TfToken& fieldName,
683  const TfToken& keyPath) const;
686  SDF_API
687  void SetField(const SdfPath& path, const TfToken& fieldName,
688  const VtValue& value);
689  SDF_API
690  void SetField(const SdfPath& path, const TfToken& fieldName,
691  const SdfAbstractDataConstValue& value);
694  template <class T>
695  void SetField(const SdfPath& path, const TfToken& fieldName,
696  const T& val)
697  {
698  // Ideally, this would make use of the SdfAbstractDataConstValue
699  // API to avoid unnecessarily copying the value into a VtValue.
700  // However, Sdf needs to create a VtValue for change processing.
701  // If the underlying SdAbstractData implementation also needs a
702  // VtValue, using the SdfAbstractDataConstValue API would cause
703  // another copy to be made. So, it's more efficient to just create
704  // the VtValue once here and push that along.
705  SetField(path, fieldName, VtValue(val));
706  }
710  SDF_API
711  void SetFieldDictValueByKey(const SdfPath& path,
712  const TfToken& fieldName,
713  const TfToken& keyPath,
714  const VtValue& value);
715  SDF_API
716  void SetFieldDictValueByKey(const SdfPath& path,
717  const TfToken& fieldName,
718  const TfToken& keyPath,
719  const SdfAbstractDataConstValue& value);
723  template <class T>
724  void SetFieldDictValueByKey(const SdfPath& path,
725  const TfToken& fieldName,
726  const TfToken& keyPath,
727  const T& val)
728  {
729  // Ideally, this would make use of the SdfAbstractDataConstValue
730  // API to avoid unnecessarily copying the value into a VtValue.
731  // However, Sdf needs to create a VtValue for change processing.
732  // If the underlying SdAbstractData implementation also needs
733  // VtValue, using the SdfAbstractDataConstValue API would cause
734  // another copy to be made. So, it's more efficient to just create
735  // the VtValue once here and push that along.
736  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
737  }
740  SDF_API
741  void EraseField(const SdfPath& path, const TfToken& fieldName);
746  SDF_API
747  void EraseFieldDictValueByKey(const SdfPath& path,
748  const TfToken& fieldName,
749  const TfToken& keyPath);
757  typedef std::function<void(const SdfPath&)> TraversalFunction;
759  // Traverse will perform a traversal of the scene description hierarchy
760  // rooted at \a path, calling \a func on each spec that it finds.
761  SDF_API
762  void Traverse(const SdfPath& path, const TraversalFunction& func);
772  SDF_API
776  SDF_API
777  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
781  SDF_API
782  bool HasColorConfiguration() const;
786  SDF_API
796  SDF_API
801  SDF_API
802  void SetColorManagementSystem(const TfToken &cms);
806  SDF_API
807  bool HasColorManagementSystem() const;
811  SDF_API
817  SDF_API
818  std::string GetComment() const;
821  SDF_API
822  void SetComment(const std::string &comment);
829  SDF_API
830  TfToken GetDefaultPrim() const;
837  SDF_API
838  void SetDefaultPrim(const TfToken &name);
842  SDF_API
843  void ClearDefaultPrim();
847  SDF_API
848  bool HasDefaultPrim();
853  SDF_API
854  std::string GetDocumentation() const;
857  SDF_API
858  void SetDocumentation(const std::string &documentation);
867  SDF_API
868  double GetStartTimeCode() const;
871  SDF_API
872  void SetStartTimeCode(double startTimecode);
875  SDF_API
876  bool HasStartTimeCode() const;
879  SDF_API
880  void ClearStartTimeCode();
888  SDF_API
889  double GetEndTimeCode() const;
892  SDF_API
893  void SetEndTimeCode(double endTimeCode);
896  SDF_API
897  bool HasEndTimeCode() const;
900  SDF_API
901  void ClearEndTimeCode();
918  SDF_API
919  double GetTimeCodesPerSecond() const;
922  SDF_API
923  void SetTimeCodesPerSecond(double timeCodesPerSecond);
926  SDF_API
927  bool HasTimeCodesPerSecond() const;
930  SDF_API
942  SDF_API
943  double GetFramesPerSecond() const;
946  SDF_API
947  void SetFramesPerSecond(double framesPerSecond);
950  SDF_API
951  bool HasFramesPerSecond() const;
954  SDF_API
955  void ClearFramesPerSecond();
958  SDF_API
959  int GetFramePrecision() const;
962  SDF_API
963  void SetFramePrecision(int framePrecision);
966  SDF_API
967  bool HasFramePrecision() const;
970  SDF_API
971  void ClearFramePrecision();
974  SDF_API
975  std::string GetOwner() const;
978  SDF_API
979  void SetOwner(const std::string& owner);
982  SDF_API
983  bool HasOwner() const;
986  SDF_API
987  void ClearOwner();
991  SDF_API
992  std::string GetSessionOwner() const;
996  SDF_API
997  void SetSessionOwner(const std::string& owner);
1000  SDF_API
1001  bool HasSessionOwner() const;
1003  // Clear the session owner opinion.
1004  SDF_API
1005  void ClearSessionOwner();
1008  SDF_API
1009  bool GetHasOwnedSubLayers() const;
1012  SDF_API
1013  void SetHasOwnedSubLayers(bool);
1020  SDF_API
1024  SDF_API
1025  void SetCustomLayerData(const VtDictionary& value);
1028  SDF_API
1029  bool HasCustomLayerData() const;
1032  SDF_API
1033  void ClearCustomLayerData();
1039  // Type for root prims view.
1043  SDF_API
1044  RootPrimsView GetRootPrims() const;
1050  SDF_API
1051  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1058  SDF_API
1059  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1062  SDF_API
1063  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1067  SDF_API
1068  void ScheduleRemoveIfInert(const SdfSpec& spec);
1082  SDF_API
1083  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1091  SDF_API
1092  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1099  SDF_API
1106  SDF_API
1117  SDF_API
1118  void SetRootPrimOrder(const std::vector<TfToken>& names);
1122  SDF_API
1123  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1126  SDF_API
1127  void RemoveFromRootPrimOrder(const TfToken & name);
1130  SDF_API
1131  void RemoveFromRootPrimOrderByIndex(int index);
1138  SDF_API
1139  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1157  SDF_API
1161  SDF_API
1162  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1165  SDF_API
1166  size_t GetNumSubLayerPaths() const;
1171  SDF_API
1172  void InsertSubLayerPath(const std::string& path, int index = -1);
1175  SDF_API
1176  void RemoveSubLayerPath(int index);
1179  SDF_API
1180  SdfLayerOffsetVector GetSubLayerOffsets() const;
1183  SDF_API
1184  SdfLayerOffset GetSubLayerOffset(int index) const;
1187  SDF_API
1188  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1195  SDF_API
1196  static std::set<std::string> GetMutedLayers();
1199  SDF_API
1200  bool IsMuted() const;
1203  SDF_API
1204  static bool IsMuted(const std::string &path);
1208  SDF_API
1209  void SetMuted(bool muted);
1212  SDF_API
1213  static void AddToMutedLayers(const std::string &mutedPath);
1216  SDF_API
1217  static void RemoveFromMutedLayers(const std::string &mutedPath);
1231  SDF_API
1232  SdfPrimSpecHandle GetPseudoRoot() const;
1240  SDF_API
1241  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1248  SDF_API
1249  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1256  SDF_API
1257  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1264  SDF_API
1265  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1272  SDF_API
1273  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1282  SDF_API
1283  bool PermissionToEdit() const;
1287  SDF_API
1288  bool PermissionToSave() const;
1291  SDF_API
1292  void SetPermissionToEdit(bool allow);
1295  SDF_API
1296  void SetPermissionToSave(bool allow);
1325  SDF_API
1328  SdfNamespaceEditDetailVector* details = NULL) const;
1333  SDF_API
1334  bool Apply(const SdfBatchNamespaceEdit&);
1342  SDF_API
1343  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1348  SDF_API
1349  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1353  SDF_API
1354  bool IsDirty() const;
1360  SDF_API
1361  std::set<double> ListAllTimeSamples() const;
1363  SDF_API
1364  std::set<double>
1365  ListTimeSamplesForPath(const SdfPath& path) const;
1367  SDF_API
1368  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1370  SDF_API
1371  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1373  SDF_API
1374  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1375  double time,
1376  double* tLower, double* tUpper);
1378  SDF_API
1379  bool QueryTimeSample(const SdfPath& path, double time,
1380  VtValue *value=NULL) const;
1381  SDF_API
1382  bool QueryTimeSample(const SdfPath& path, double time,
1383  SdfAbstractDataValue *value) const;
1385  template <class T>
1386  bool QueryTimeSample(const SdfPath& path, double time,
1387  T* data) const
1388  {
1389  if (!data) {
1390  return QueryTimeSample(path, time);
1391  }
1393  SdfAbstractDataTypedValue<T> outValue(data);
1394  const bool hasValue = QueryTimeSample(
1395  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1397  if (std::is_same<T, SdfValueBlock>::value) {
1398  return hasValue && outValue.isValueBlock;
1399  }
1401  return hasValue && (!outValue.isValueBlock);
1402  }
1404  SDF_API
1405  void SetTimeSample(const SdfPath& path, double time,
1406  const VtValue & value);
1407  SDF_API
1408  void SetTimeSample(const SdfPath& path, double time,
1409  const SdfAbstractDataConstValue& value);
1411  template <class T>
1412  void SetTimeSample(const SdfPath& path, double time,
1413  const T& value)
1414  {
1415  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1416  const SdfAbstractDataConstValue& untypedInValue = inValue;
1417  return SetTimeSample(path, time, untypedInValue);
1418  }
1420  SDF_API
1421  void EraseTimeSample(const SdfPath& path, double time);
1425  // Debugging
1426  // @{
1428  SDF_API
1429  static void DumpLayerInfo();
1431  // Write this layer's SdfData to a file in a simple generic format.
1432  SDF_API
1433  bool WriteDataFile(const std::string &filename);
1435  // @}
1437 protected:
1438  // Private constructor -- use New(), FindOrCreate(), etc.
1439  // Precondition: _layerRegistryMutex must be locked.
1440  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1441  const std::string &identifier,
1442  const std::string &realPath = std::string(),
1443  const ArAssetInfo& assetInfo = ArAssetInfo(),
1444  const FileFormatArguments &args = FileFormatArguments(),
1445  bool validateAuthoring = false);
1447 private:
1448  // Create a new layer.
1449  // Precondition: _layerRegistryMutex must be locked.
1450  static SdfLayerRefPtr _CreateNew(
1451  SdfFileFormatConstPtr fileFormat,
1452  const std::string& identifier,
1453  const FileFormatArguments& args);
1455  static SdfLayerRefPtr _CreateNewWithFormat(
1456  const SdfFileFormatConstPtr &fileFormat,
1457  const std::string& identifier,
1458  const std::string& realPath,
1459  const ArAssetInfo& assetInfo = ArAssetInfo(),
1460  const FileFormatArguments& args = FileFormatArguments());
1462  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1463  const SdfFileFormatConstPtr &fileFormat,
1464  const std::string& tag,
1465  const FileFormatArguments& args);
1467  // Finish initializing this layer (which may have succeeded or not)
1468  // and publish the results to other threads by unlocking the mutex.
1469  // Sets _initializationWasSuccessful and unlocks _initializationMutex.
1470  void _FinishInitialization(bool success);
1472  // Layers retrieved from the layer registry may still be in the
1473  // process of having their contents initialized. Other threads
1474  // retrieving layers from the registry must wait until initialization
1475  // is complete, using this method. See _initializationMutex.
1476  // Returns _initializationWasSuccessful.
1477  //
1478  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1479  // ensure that it is not deleted out from under them, in
1480  // case initialization fails. (This method cannot acquire the
1481  // reference itself internally without being susceptible to a race.)
1482  bool _WaitForInitializationAndCheckIfSuccessful();
1484  // Returns whether or not this menv layer should post change
1485  // notification. This simply returns (!_GetIsLoading())
1486  bool _ShouldNotify() const;
1488  // This function keeps track of the last state of IsDirty() before
1489  // updating it. It returns false if the last saved dirty state is the
1490  // same than the current state. It returns true if the state differs and
1491  // will update the 'last dirty state' to the current state. So, after
1492  // returning true, it would return false for subsequent calls until the
1493  // IsDirty() state would change again...
1494  bool _UpdateLastDirtinessState() const;
1496  // Returns a handle to the spec at the given path if it exists and matches
1497  // type T.
1498  template <class T>
1499  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1501  // Returns true if a spec can be retrieved at the given path, false
1502  // otherwise. This function will return the canonicalized path to the
1503  // spec as well as the spec type.
1504  bool _CanGetSpecAtPath(const SdfPath& path,
1505  SdfPath* canonicalPath, SdfSpecType* specType) const;
1510  void _InitializeFromIdentifier(
1511  const std::string &identifier,
1512  const std::string &realPath = std::string(),
1513  const std::string &fileVersion = std::string(),
1514  const ArAssetInfo& assetInfo = ArAssetInfo());
1516  // Helper for computing the necessary information to lookup a layer
1517  // in the registry or open the layer.
1518  struct _FindOrOpenLayerInfo;
1519  static bool _ComputeInfoToFindOrOpenLayer(
1520  const std::string& identifier,
1521  const SdfLayer::FileFormatArguments& args,
1522  _FindOrOpenLayerInfo* info,
1523  bool computeAssetInfo = false);
1525  // Open a layer, adding an entry to the registry and releasing
1526  // the registry lock.
1527  // Precondition: _layerRegistryMutex must be locked.
1528  template <class Lock>
1529  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1530  Lock &lock,
1531  const _FindOrOpenLayerInfo& info,
1532  bool metadataOnly);
1534  // Helper function for finding a layer with \p identifier and \p args.
1535  // \p lock must be unlocked initially and will be locked by this
1536  // function when needed. See docs for \p retryAsWriter argument on
1537  // _TryToFindLayer for details on the final state of the lock when
1538  // this function returns.
1539  template <class ScopedLock>
1540  static SdfLayerRefPtr
1541  _Find(const std::string &identifier,
1542  const FileFormatArguments &args,
1543  ScopedLock &lock, bool retryAsWriter);
1545  // Helper function to try to find the layer with \p identifier and
1546  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1547  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1548  // released upon return. Otherwise the lock is released upon return if a
1549  // layer is found successfully. If no layer is found then the lock is
1550  // upgraded to a writer lock upon return. Note that this upgrade may not be
1551  // atomic, but this function ensures that if upon return there does not
1552  // exist a matching layer in the registry.
1553  template <class ScopedLock>
1554  static SdfLayerRefPtr
1555  _TryToFindLayer(const std::string &identifier,
1556  const std::string &resolvedPath,
1557  ScopedLock &lock, bool retryAsWriter);
1566  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1567  bool requiredFieldOnlyPropertiesAreInert = false) const;
1577  bool _IsInertSubtree(const SdfPath &path,
1578  std::vector<SdfPath>* inertSpecs = nullptr);
1585  void _RemoveIfInert(const SdfSpec& spec);
1591  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1595  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1598  bool _ValidateAuthoring() const { return _validateAuthoring; }
1601  std::string _GetMutedPath() const;
1603  // If old and new asset path is given, rename all external prim
1604  // composition dependency referring to the old path.
1605  void _UpdatePrimCompositionDependencyPaths(
1606  const SdfPrimSpecHandle &parent,
1607  const std::string &oldLayerPath,
1608  const std::string &newLayerPath);
1610  // Set the clean state to the current state.
1611  void _MarkCurrentStateAsClean() const;
1613  // Return the field definition for \p fieldName if \p fieldName is a
1614  // required field for the spec type identified by \p path.
1615  inline SdfSchema::FieldDefinition const *
1616  _GetRequiredFieldDef(const SdfPath &path,
1617  const TfToken &fieldName,
1618  SdfSpecType specType = SdfSpecTypeUnknown) const;
1620  // Return the field definition for \p fieldName if \p fieldName is a
1621  // required field for \p specType subject to \p schema.
1622  static inline SdfSchema::FieldDefinition const *
1623  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1624  const TfToken &fieldName,
1625  SdfSpecType specType);
1627  // Helper to list all fields on \p data at \p path subject to \p schema.
1628  static std::vector<TfToken>
1629  _ListFields(SdfSchemaBase const &schema,
1630  SdfAbstractData const &data, const SdfPath& path);
1632  // Helper for HasField for \p path in \p data subject to \p schema.
1633  static inline bool
1634  _HasField(const SdfSchemaBase &schema,
1635  const SdfAbstractData &data,
1636  const SdfPath& path,
1637  const TfToken& fieldName,
1638  VtValue *value);
1640  // Helper to get a field value for \p path in \p data subject to \p schema.
1641  static inline VtValue
1642  _GetField(const SdfSchemaBase &schema,
1643  const SdfAbstractData &data,
1644  const SdfPath& path,
1645  const TfToken& fieldName);
1647  // Set a value.
1648  template <class T>
1649  void _SetValue(const TfToken& key, T value);
1651  // Get a value.
1652  template <class T>
1653  T _GetValue(const TfToken& key) const;
1655  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1656  _ReloadResult _Reload(bool force);
1658  // Reads contents of asset specified by \p identifier with resolved
1659  // path \p resolvedPath into this layer.
1660  bool _Read(const std::string& identifier,
1661  const std::string& resolvedPath,
1662  bool metadataOnly);
1664  // Saves this layer if it is dirty or the layer doesn't already exist
1665  // on disk. If \p force is true, the layer will be written out
1666  // regardless of those conditions.
1667  bool _Save(bool force) const;
1669  // A helper method used by Save and Export.
1670  // This method allows Save to specify the existing file format and Export
1671  // to use the format provided by the file extension in newFileName. If no
1672  // file format can be discovered from the file name, the existing file
1673  // format associated with the layer will be used in both cases. This allows
1674  // users to export and save to any file name, regardless of extension.
1675  bool _WriteToFile(const std::string& newFileName,
1676  const std::string& comment,
1677  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1678  const FileFormatArguments& args = FileFormatArguments())
1679  const;
1681  // Swap contents of _data and data. This operation does not register
1682  // inverses or emit change notification.
1683  void _SwapData(SdfAbstractDataRefPtr &data);
1685  // Set _data to match data, calling other primitive setter methods to
1686  // provide fine-grained inverses and notification. If \p data might adhere
1687  // to a different schema than this layer's, pass a pointer to it as \p
1688  // newDataSchema. In this case, check to see if fields from \p data are
1689  // known to this layer's schema, and if not, omit them and issue a TfError
1690  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1691  // known fields.
1692  void _SetData(const SdfAbstractDataPtr &newData,
1693  const SdfSchemaBase *newDataSchema=nullptr);
1695  // Returns const handle to _data.
1696  SdfAbstractDataConstPtr _GetData() const;
1698  // Inverse primitive for setting a single field.
1699  template <class T>
1700  void _PrimSetField(const SdfPath& path,
1701  const TfToken& fieldName,
1702  const T& value,
1703  const VtValue *oldValue = NULL,
1704  bool useDelegate = true);
1706  // Inverse primitive for setting a single key in a dict-valued field.
1707  template <class T>
1708  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1709  const TfToken& fieldName,
1710  const TfToken& keyPath,
1711  const T& value,
1712  const VtValue *oldValue = NULL,
1713  bool useDelegate = true);
1715  // Primitive for appending a child to the list of children.
1716  template <class T>
1717  void _PrimPushChild(const SdfPath& parentPath,
1718  const TfToken& fieldName,
1719  const T& value,
1720  bool useDelegate = true);
1721  template <class T>
1722  void _PrimPopChild(const SdfPath& parentPath,
1723  const TfToken& fieldName,
1724  bool useDelegate = true);
1726  // Move all the fields at all paths at or below \a oldPath to be
1727  // at a corresponding location at or below \a newPath. This does
1728  // not update the children fields of the parents of these paths.
1729  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1731  // Inverse primitive for moving a spec.
1732  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1733  bool useDelegate = true);
1735  // Create a new spec of type \p specType at \p path.
1736  // Returns true if spec was successfully created, false otherwise.
1737  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1739  // Delete all the fields at or below the specified path. This does
1740  // not update the children field of the parent of \a path.
1741  bool _DeleteSpec(const SdfPath &path);
1743  // Inverse primitive for deleting a spec.
1744  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1745  bool useDelegate = true);
1747  // Inverse primitive for deleting a spec.
1748  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1749  bool useDelegate = true);
1751  // Inverse primitive for setting time samples.
1752  template <class T>
1753  void _PrimSetTimeSample(const SdfPath& path, double time,
1754  const T& value,
1755  bool useDelegate = true);
1757  // Helper method for Traverse. Visits the children of \a path using the
1758  // specified \a ChildPolicy.
1759  template <typename ChildPolicy>
1760  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1762 private:
1763  SdfLayerHandle _self;
1765  // File format and arguments for this layer.
1766  SdfFileFormatConstPtr _fileFormat;
1767  FileFormatArguments _fileFormatArgs;
1769  // Registry of Sdf Identities
1770  mutable Sdf_IdentityRegistry _idRegistry;
1772  // The underlying SdfData which stores all the data in the layer.
1773  SdfAbstractDataRefPtr _data;
1775  // The state delegate for this layer.
1776  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1778  // Atomic variable protecting layer initialization -- the interval between
1779  // adding a layer to the layer registry and finishing the process of
1780  // initializing its contents, at which point we can truly publish the layer
1781  // for consumption by concurrent threads. We add the layer to the registry
1782  // before initialization completes so that other threads can discover and
1783  // wait for it to finish initializing.
1784  std::atomic<bool> _initializationComplete;
1786  // This is an optional<bool> that is only set once initialization
1787  // is complete, while _initializationMutex is locked. If the
1788  // optional<bool> is unset, initialization is still underway.
1789  boost::optional<bool> _initializationWasSuccessful;
1791  // remembers the last 'IsDirty' state.
1792  mutable bool _lastDirtyState;
1794  // Asset information for this layer.
1795  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1797  // Modification timestamp of the backing file asset when last read.
1798  mutable VtValue _assetModificationTime;
1800  // All external asset dependencies, with their modification timestamps, of
1801  // the layer when last read.
1802  mutable VtDictionary _externalAssetModificationTimes;
1804  // Mutable revision number for cache invalidation.
1805  mutable size_t _mutedLayersRevisionCache;
1807  // Cache of whether or not this layer is muted. Only valid if
1808  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1809  mutable bool _isMutedCache;
1811  // Layer permission bits.
1812  bool _permissionToEdit;
1813  bool _permissionToSave;
1815  // Whether layer edits are validated.
1816  bool _validateAuthoring;
1818  // Layer hints as of the most recent save operation.
1819  mutable SdfLayerHints _hints;
1821  // Allow access to _ValidateAuthoring() and _IsInert().
1822  friend class SdfSpec;
1823  friend class SdfPropertySpec;
1824  friend class SdfAttributeSpec;
1826  friend class Sdf_ChangeManager;
1828  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1829  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1831  // Give the file format access to our data. Limit breaking encapsulation
1832  // to the base SdFileFormat class so we don't have to friend every
1833  // implementation here.
1834  friend class SdfFileFormat;
1836  // Give layer state delegates access to our data as well as to
1837  // the various _Prim functions.
1838  friend class SdfLayerStateDelegateBase;
1839 };
1843 #endif // PXR_USD_SDF_LAYER_H
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer's authoring state.
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
A unit of scene description that you combine with other units of scene description to form a shot,...
Definition: layer.h:96
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API bool PermissionToSave() const
Returns true if the caller is allowed to save the layer to its existing fileName and false otherwise.
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for the given path and fieldName.
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
SDF_API bool UpdateCompositionAssetDependency(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
Updates the asset path of a composation dependency in this layer.
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
Standard pointer typedefs.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:59
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
Returns the object at the given path.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName and keyPath.
SDF_API double GetStartTimeCode() const
Returns the layer's start timeCode.
SDF_API void UpdateAssetInfo()
Update layer asset information.
SDF_API bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
SDF_API bool IsDirty() const
Returns true if the layer is dirty, i.e.
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
SDF_API std::string ComputeAbsolutePath(const std::string &assetPath) const
Returns the path to the asset specified by assetPath using this layer to anchor the path if necessary...
SDF_API std::string GetOwner() const
Returns the layer's owner.
SDF_API std::string GetComment() const
Returns the comment string for this layer.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:477
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:519
static SDF_API SdfLayerRefPtr FindOrOpenRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:394
SDF_API std::set< std::string > GetExternalAssetDependencies() const
Returns a set of resolved paths to all external asset dependencies the layer needs to generate its co...
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
A map with string keys and VtValue values.
Definition: dictionary.h:63
std::function< void(const SdfPath &)> TraversalFunction
Callback function for Traverse.
Definition: layer.h:757
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
Adds a new root prim at the given index.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:62
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
Base class for all Sdf spec classes.
Definition: spec.h:51
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API double GetFramesPerSecond() const
Returns the layer's frames per second.
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
Removes scene description that does not affect the scene in the layer namespace beginning with prim.
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
Removes prop if it has only required fields (i.e.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
SDF_API bool Export(const std::string &filename, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
Exports this layer to a file.
SDF_API bool ImportFromString(const std::string &string)
Reads this layer from the given string.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API std::set< std::string > GetCompositionAssetDependencies() const
Return paths of all assets this layer depends on due to composition fields.
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
Inserts new sublayer path at the given index.
SdfHandle is a smart ptr that calls IsDormant() on the pointed-to object as an extra expiration check...
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
Basic Sdf data types.
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
Return the value for the given path and fieldName at keyPath.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
SDF_API void RemoveInertSceneDescription()
Removes all scene description in this layer that does not affect the scene.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer's authoring state.
static SDF_API SdfLayerHandle Find(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args.
SDF_API bool PermissionToEdit() const
Returns true if the caller is allowed to modify the layer and false otherwise.
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
Sets a new vector of root prims.
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
Returns the list of prim names for this layer's reorder rootPrims statement.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void SetMuted(bool muted)
Mutes the current layer if muted is true, and unmutes it otherwise.
SDF_API bool HasDefaultPrim()
Return true if the default prim metadata is set in this layer.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path for this layer.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API bool Reload(bool force=false)
Reloads the layer from its persistent representation.
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:56
Class defining various attributes for a field.
Definition: schema.h:72
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API void SetIdentifier(const std::string &identifier)
Sets the layer identifier.
A description of an arbitrarily complex namespace edit.
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema this layer adheres to.
Represents a single list of list editing operations.
Definition: listProxy.h:57
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
SDF_API void TransferContent(const SdfLayerHandle &layer)
Copies the content of the given layer into this layer.
bool HasField(const SdfPath &path, const TfToken &name, T *value) const
Returns true if the object has a non-empty value with name name and type T.
Definition: layer.h:604
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API TfToken GetColorManagementSystem() const
Returns the color management system used to interpret the color configuration asset-path authored in ...
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:444
virtual SDF_API ~SdfLayer()
SDF_API void SetRootPrimOrder(const std::vector< TfToken > &names)
Given a list of (possible sparse) prim names, authors a reorder rootPrims statement for this prim.
Validity of an edit.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
static SDF_API SdfLayerHandle FindRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:122
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
SDF_API void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)
Set the value of the given path and fieldName.
void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:724
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
Returns the prim at the given path.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
Check if a batch of namespace edits will succeed.
SDF_API const std::string & GetVersion() const
Returns the asset system version of this layer.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier for a given file format class.
SDF_API void ScheduleRemoveIfInert(const SdfSpec &spec)
Cause spec to be removed if it no longer affects the scene when the last change block is closed,...
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer's pseudo-root prim.
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
Adds a new root prim name in the root prim order.
bool HasFieldDictKey(const SdfPath &path, const TfToken &name, const TfToken &keyPath, T *value) const
Returns true if the object has a non-empty value with name name and keyPath and type T.
Definition: layer.h:648
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
Returns a proxy for this layer's sublayers.
SDF_API bool HasColorManagementSystem() const
Returns true if colorManagementSystem metadata is set in this layer.
SDF_API std::string GetDisplayName() const
Returns the layer's display name.
SDF_API void ClearOwner()
Clear the owner opinion.
void SetField(const SdfPath &path, const TfToken &fieldName, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:695
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
Represents a resolved asset path.
Definition: resolvedPath.h:39
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API void Clear()
Clears the layer of all content.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
static SDF_API std::string GetDisplayNameFromIdentifier(const std::string &identifier)
Returns the display name for the given identifier, using the same rules as GetDisplayName.
SDF_API const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
An enum that specifies the type of an object.
Definition: types.h:91
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
SDF_API void ClearColorManagementSystem()
Clears the 'colorManagementSystem' metadata authored in this layer.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Return the value for the given path and fieldName.
Definition: layer.h:671
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SdfLayer(const SdfLayer &)=delete
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
SDF_API void EraseFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath)
Remove the field at path and fieldName and keyPath, if one exists.
Contains hints about layer contents that may be used to accelerate certain composition operations.
Definition: layerHints.h:33
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
Provides a view onto an object's children.
Definition: childrenView.h:171
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
Maintains authoring state information for an associated layer.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
Returns true if the identifier is an anonymous layer unique identifier.
SDF_API SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
SDF_API void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
SDF_API void ApplyRootPrimOrder(std::vector< TfToken > *vec) const
Reorders the given list of prim names according to the reorder rootPrims statement for this layer.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
SDF_API std::string GetSessionOwner() const
Returns the layer's session owner.
Base class for file format implementations.
Definition: fileFormat.h:64
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API double GetEndTimeCode() const
Returns the layer's end timeCode.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
SDF_API bool Import(const std::string &layerPath)
Imports the content of the given layer path, replacing the content of the current layer.
static SDF_API bool SplitIdentifier(const std::string &identifier, std::string *layerPath, FileFormatArguments *arguments)
Splits the given layer identifier into its constituent layer path and arguments.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
SDF_API void SetColorManagementSystem(const TfToken &cms)
Sets the color management system used to interpret the color configuration asset-path authored this l...
SDF_API void SetPermissionToSave(bool allow)
Sets permission to save.
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
Load the given layer from disk as a new anonymous layer.
std::type_info const & GetFieldTypeid(const SdfPath &path, const TfToken &name) const
Return the type of the value for name on spec path.
Definition: layer.h:624
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
Interface for scene description data storage.
Definition: abstractData.h:73
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
Contains information about a resolved asset.
Definition: assetInfo.h:40
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.