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"
48 #include <boost/optional.hpp>
50 #include <atomic>
51 #include <functional>
52 #include <memory>
53 #include <set>
54 #include <string>
55 #include <vector>
62 struct Sdf_AssetInfo;
94 class SdfLayer
95  : public TfRefBase
96  , public TfWeakBase
97 {
98 public:
100  SDF_API
101  virtual ~SdfLayer();
104  SdfLayer(const SdfLayer&) = delete;
105  SdfLayer& operator=(const SdfLayer&) = delete;
113  SDF_API const SdfSchemaBase& GetSchema() const;
116  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
120  typedef std::map<std::string, std::string> FileFormatArguments;
124  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
131  SDF_API
132  static SdfLayerRefPtr CreateNew(const std::string &identifier,
133  const FileFormatArguments &args =
142  SDF_API
143  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
144  const std::string &identifier,
145  const FileFormatArguments &args =
156  SDF_API
157  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
158  const std::string &identifier,
159  const FileFormatArguments &args =
168  SDF_API
169  static SdfLayerHandle Find(
170  const std::string &identifier,
171  const FileFormatArguments &args = FileFormatArguments());
183  SDF_API
184  static SdfLayerHandle FindRelativeToLayer(
185  const SdfLayerHandle &anchor,
186  const std::string &identifier,
187  const FileFormatArguments &args = FileFormatArguments());
195  SDF_API
196  static SdfLayerRefPtr FindOrOpen(
197  const std::string &identifier,
198  const FileFormatArguments &args = FileFormatArguments());
210  SDF_API
212  const SdfLayerHandle &anchor,
213  const std::string &identifier,
214  const FileFormatArguments &args = FileFormatArguments());
229  SDF_API
231  const std::string &layerPath,
232  bool metadataOnly = false,
233  const std::string& tag = std::string());
236  SDF_API
237  SdfDataRefPtr GetMetadata() const;
242  SDF_API
243  SdfLayerHints GetHints() const;
246  SDF_API
247  static SdfLayerHandleSet GetLoadedLayers();
250  SDF_API
251  bool IsEmpty() const;
255  SDF_API
256  void TransferContent(const SdfLayerHandle& layer);
272  SDF_API
274  const std::string& tag = std::string(),
275  const FileFormatArguments& args = FileFormatArguments());
278  SDF_API
280  const std::string &tag, const SdfFileFormatConstPtr &format,
281  const FileFormatArguments& args = FileFormatArguments());
284  SDF_API
285  bool IsAnonymous() const;
289  SDF_API
290  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
294  SDF_API
295  static std::string GetDisplayNameFromIdentifier(
296  const std::string& identifier);
306  SDF_API
307  bool Save(bool force = false) const;
321  SDF_API
322  bool Export(const std::string& filename,
323  const std::string& comment = std::string(),
324  const FileFormatArguments& args = FileFormatArguments()) const;
330  SDF_API
331  bool ExportToString(std::string* result) const;
336  SDF_API
337  bool ImportFromString(const std::string &string);
346  SDF_API
347  void Clear();
370  SDF_API
371  bool Reload(bool force = false);
379  SDF_API
380  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
381  bool force = false);
388  SDF_API
389  bool Import(const std::string &layerPath);
397  SDF_API
398  std::set<std::string> GetExternalReferences() const;
402  SDF_API
404  const std::string &oldAssetPath,
405  const std::string &newAssetPath=std::string());
414  SDF_API
415  std::set<std::string> GetCompositionAssetDependencies() const;
426  SDF_API
428  const std::string &oldAssetPath,
429  const std::string &newAssetPath=std::string());
439  SDF_API
440  std::set<std::string> GetExternalAssetDependencies() const;
464  SDF_API
465  static bool SplitIdentifier(
466  const std::string& identifier,
467  std::string* layerPath,
468  FileFormatArguments* arguments);
471  SDF_API
472  static std::string CreateIdentifier(
473  const std::string& layerPath,
474  const FileFormatArguments& arguments);
477  SDF_API
478  const std::string& GetIdentifier() const;
483  SDF_API
484  void SetIdentifier(const std::string& identifier);
490 #if AR_VERSION == 1
491  SDF_API
492  void UpdateAssetInfo(const std::string& fileVersion = std::string());
493 #else
494  SDF_API
495  void UpdateAssetInfo();
496 #endif
501  SDF_API
502  std::string GetDisplayName() const;
506  SDF_API
507  const ArResolvedPath& GetResolvedPath() const;
511  SDF_API
512  const std::string& GetRealPath() const;
518  SDF_API
519  std::string GetFileExtension() const;
526  SDF_API
527  const std::string& GetVersion() const;
533  SDF_API
534  const std::string& GetRepositoryPath() const;
537  SDF_API
538  const std::string& GetAssetName() const;
542  SDF_API
543  const VtValue& GetAssetInfo() const;
560  SDF_API
561  std::string ComputeAbsolutePath(const std::string& assetPath) const;
578  SDF_API
579  SdfSpecType GetSpecType(const SdfPath& path) const;
582  SDF_API
583  bool HasSpec(const SdfPath& path) const;
586  SDF_API
587  std::vector<TfToken> ListFields(const SdfPath& path) const;
591  SDF_API
592  bool HasField(const SdfPath& path, const TfToken& fieldName,
593  VtValue *value=NULL) const;
594  SDF_API
595  bool HasField(const SdfPath& path, const TfToken& fieldName,
596  SdfAbstractDataValue *value) const;
601  template <class T>
602  bool HasField(const SdfPath& path, const TfToken &name,
603  T* value) const
604  {
605  if (!value) {
606  return HasField(path, name, static_cast<VtValue *>(NULL));
607  }
609  SdfAbstractDataTypedValue<T> outValue(value);
610  const bool hasValue = HasField(
611  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
613  if (std::is_same<T, SdfValueBlock>::value) {
614  return hasValue && outValue.isValueBlock;
615  }
617  return hasValue && (!outValue.isValueBlock);
618  }
622  std::type_info const &GetFieldTypeid(
623  const SdfPath &path, const TfToken &name) const {
624  return _data->GetTypeid(path, name);
625  }
630  SDF_API
631  bool HasFieldDictKey(const SdfPath& path,
632  const TfToken &fieldName,
633  const TfToken &keyPath,
634  VtValue *value=NULL) const;
635  SDF_API
636  bool HasFieldDictKey(const SdfPath& path,
637  const TfToken &fieldName,
638  const TfToken &keyPath,
639  SdfAbstractDataValue *value) const;
645  template <class T>
646  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
647  const TfToken &keyPath, T* value) const
648  {
649  if (!value) {
650  return HasFieldDictKey(path, name, keyPath,
651  static_cast<VtValue *>(NULL));
652  }
654  SdfAbstractDataTypedValue<T> outValue(value);
655  return HasFieldDictKey(path, name, keyPath,
656  static_cast<SdfAbstractDataValue *>(&outValue));
657  }
662  SDF_API
663  VtValue GetField(const SdfPath& path,
664  const TfToken& fieldName) const;
668  template <class T>
669  inline T GetFieldAs(const SdfPath& path,
670  const TfToken& fieldName, const T& defaultValue = T()) const
671  {
672  return _data->GetAs<T>(path, fieldName, defaultValue);
673  }
678  SDF_API
680  const TfToken& fieldName,
681  const TfToken& keyPath) const;
684  SDF_API
685  void SetField(const SdfPath& path, const TfToken& fieldName,
686  const VtValue& value);
687  SDF_API
688  void SetField(const SdfPath& path, const TfToken& fieldName,
689  const SdfAbstractDataConstValue& value);
692  template <class T>
693  void SetField(const SdfPath& path, const TfToken& fieldName,
694  const T& val)
695  {
696  // Ideally, this would make use of the SdfAbstractDataConstValue
697  // API to avoid unnecessarily copying the value into a VtValue.
698  // However, Sdf needs to create a VtValue for change processing.
699  // If the underlying SdAbstractData implementation also needs a
700  // VtValue, using the SdfAbstractDataConstValue API would cause
701  // another copy to be made. So, it's more efficient to just create
702  // the VtValue once here and push that along.
703  SetField(path, fieldName, VtValue(val));
704  }
708  SDF_API
709  void SetFieldDictValueByKey(const SdfPath& path,
710  const TfToken& fieldName,
711  const TfToken& keyPath,
712  const VtValue& value);
713  SDF_API
714  void SetFieldDictValueByKey(const SdfPath& path,
715  const TfToken& fieldName,
716  const TfToken& keyPath,
717  const SdfAbstractDataConstValue& value);
721  template <class T>
722  void SetFieldDictValueByKey(const SdfPath& path,
723  const TfToken& fieldName,
724  const TfToken& keyPath,
725  const T& val)
726  {
727  // Ideally, this would make use of the SdfAbstractDataConstValue
728  // API to avoid unnecessarily copying the value into a VtValue.
729  // However, Sdf needs to create a VtValue for change processing.
730  // If the underlying SdAbstractData implementation also needs
731  // VtValue, using the SdfAbstractDataConstValue API would cause
732  // another copy to be made. So, it's more efficient to just create
733  // the VtValue once here and push that along.
734  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
735  }
738  SDF_API
739  void EraseField(const SdfPath& path, const TfToken& fieldName);
744  SDF_API
745  void EraseFieldDictValueByKey(const SdfPath& path,
746  const TfToken& fieldName,
747  const TfToken& keyPath);
755  typedef std::function<void(const SdfPath&)> TraversalFunction;
757  // Traverse will perform a traversal of the scene description hierarchy
758  // rooted at \a path, calling \a func on each spec that it finds.
759  SDF_API
760  void Traverse(const SdfPath& path, const TraversalFunction& func);
770  SDF_API
774  SDF_API
775  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
779  SDF_API
780  bool HasColorConfiguration() const;
784  SDF_API
794  SDF_API
799  SDF_API
800  void SetColorManagementSystem(const TfToken &cms);
804  SDF_API
805  bool HasColorManagementSystem() const;
809  SDF_API
815  SDF_API
816  std::string GetComment() const;
819  SDF_API
820  void SetComment(const std::string &comment);
827  SDF_API
828  TfToken GetDefaultPrim() const;
835  SDF_API
836  void SetDefaultPrim(const TfToken &name);
840  SDF_API
841  void ClearDefaultPrim();
845  SDF_API
846  bool HasDefaultPrim();
851  SDF_API
852  std::string GetDocumentation() const;
855  SDF_API
856  void SetDocumentation(const std::string &documentation);
865  SDF_API
866  double GetStartTimeCode() const;
869  SDF_API
870  void SetStartTimeCode(double startTimecode);
873  SDF_API
874  bool HasStartTimeCode() const;
877  SDF_API
878  void ClearStartTimeCode();
886  SDF_API
887  double GetEndTimeCode() const;
890  SDF_API
891  void SetEndTimeCode(double endTimeCode);
894  SDF_API
895  bool HasEndTimeCode() const;
898  SDF_API
899  void ClearEndTimeCode();
916  SDF_API
917  double GetTimeCodesPerSecond() const;
920  SDF_API
921  void SetTimeCodesPerSecond(double timeCodesPerSecond);
924  SDF_API
925  bool HasTimeCodesPerSecond() const;
928  SDF_API
940  SDF_API
941  double GetFramesPerSecond() const;
944  SDF_API
945  void SetFramesPerSecond(double framesPerSecond);
948  SDF_API
949  bool HasFramesPerSecond() const;
952  SDF_API
953  void ClearFramesPerSecond();
956  SDF_API
957  int GetFramePrecision() const;
960  SDF_API
961  void SetFramePrecision(int framePrecision);
964  SDF_API
965  bool HasFramePrecision() const;
968  SDF_API
969  void ClearFramePrecision();
972  SDF_API
973  std::string GetOwner() const;
976  SDF_API
977  void SetOwner(const std::string& owner);
980  SDF_API
981  bool HasOwner() const;
984  SDF_API
985  void ClearOwner();
989  SDF_API
990  std::string GetSessionOwner() const;
994  SDF_API
995  void SetSessionOwner(const std::string& owner);
998  SDF_API
999  bool HasSessionOwner() const;
1001  // Clear the session owner opinion.
1002  SDF_API
1003  void ClearSessionOwner();
1006  SDF_API
1007  bool GetHasOwnedSubLayers() const;
1010  SDF_API
1011  void SetHasOwnedSubLayers(bool);
1018  SDF_API
1022  SDF_API
1023  void SetCustomLayerData(const VtDictionary& value);
1026  SDF_API
1027  bool HasCustomLayerData() const;
1030  SDF_API
1031  void ClearCustomLayerData();
1037  // Type for root prims view.
1041  SDF_API
1042  RootPrimsView GetRootPrims() const;
1048  SDF_API
1049  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1056  SDF_API
1057  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1060  SDF_API
1061  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1065  SDF_API
1066  void ScheduleRemoveIfInert(const SdfSpec& spec);
1080  SDF_API
1081  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1089  SDF_API
1090  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1097  SDF_API
1104  SDF_API
1115  SDF_API
1116  void SetRootPrimOrder(const std::vector<TfToken>& names);
1120  SDF_API
1121  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1124  SDF_API
1125  void RemoveFromRootPrimOrder(const TfToken & name);
1128  SDF_API
1129  void RemoveFromRootPrimOrderByIndex(int index);
1136  SDF_API
1137  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1155  SDF_API
1159  SDF_API
1160  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1163  SDF_API
1164  size_t GetNumSubLayerPaths() const;
1169  SDF_API
1170  void InsertSubLayerPath(const std::string& path, int index = -1);
1173  SDF_API
1174  void RemoveSubLayerPath(int index);
1177  SDF_API
1178  SdfLayerOffsetVector GetSubLayerOffsets() const;
1181  SDF_API
1182  SdfLayerOffset GetSubLayerOffset(int index) const;
1185  SDF_API
1186  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1193  SDF_API
1194  static std::set<std::string> GetMutedLayers();
1197  SDF_API
1198  bool IsMuted() const;
1201  SDF_API
1202  static bool IsMuted(const std::string &path);
1206  SDF_API
1207  void SetMuted(bool muted);
1210  SDF_API
1211  static void AddToMutedLayers(const std::string &mutedPath);
1214  SDF_API
1215  static void RemoveFromMutedLayers(const std::string &mutedPath);
1229  SDF_API
1230  SdfPrimSpecHandle GetPseudoRoot() const;
1238  SDF_API
1239  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1246  SDF_API
1247  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1254  SDF_API
1255  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1262  SDF_API
1263  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1270  SDF_API
1271  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1280  SDF_API
1281  bool PermissionToEdit() const;
1285  SDF_API
1286  bool PermissionToSave() const;
1289  SDF_API
1290  void SetPermissionToEdit(bool allow);
1293  SDF_API
1294  void SetPermissionToSave(bool allow);
1323  SDF_API
1326  SdfNamespaceEditDetailVector* details = NULL) const;
1331  SDF_API
1332  bool Apply(const SdfBatchNamespaceEdit&);
1340  SDF_API
1341  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1346  SDF_API
1347  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1351  SDF_API
1352  bool IsDirty() const;
1358  SDF_API
1359  std::set<double> ListAllTimeSamples() const;
1361  SDF_API
1362  std::set<double>
1363  ListTimeSamplesForPath(const SdfPath& path) const;
1365  SDF_API
1366  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1368  SDF_API
1369  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1371  SDF_API
1372  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1373  double time,
1374  double* tLower, double* tUpper);
1376  SDF_API
1377  bool QueryTimeSample(const SdfPath& path, double time,
1378  VtValue *value=NULL) const;
1379  SDF_API
1380  bool QueryTimeSample(const SdfPath& path, double time,
1381  SdfAbstractDataValue *value) const;
1383  template <class T>
1384  bool QueryTimeSample(const SdfPath& path, double time,
1385  T* data) const
1386  {
1387  if (!data) {
1388  return QueryTimeSample(path, time);
1389  }
1391  SdfAbstractDataTypedValue<T> outValue(data);
1392  const bool hasValue = QueryTimeSample(
1393  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1395  if (std::is_same<T, SdfValueBlock>::value) {
1396  return hasValue && outValue.isValueBlock;
1397  }
1399  return hasValue && (!outValue.isValueBlock);
1400  }
1402  SDF_API
1403  void SetTimeSample(const SdfPath& path, double time,
1404  const VtValue & value);
1405  SDF_API
1406  void SetTimeSample(const SdfPath& path, double time,
1407  const SdfAbstractDataConstValue& value);
1409  template <class T>
1410  void SetTimeSample(const SdfPath& path, double time,
1411  const T& value)
1412  {
1413  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1414  const SdfAbstractDataConstValue& untypedInValue = inValue;
1415  return SetTimeSample(path, time, untypedInValue);
1416  }
1418  SDF_API
1419  void EraseTimeSample(const SdfPath& path, double time);
1423  // Debugging
1424  // @{
1426  SDF_API
1427  static void DumpLayerInfo();
1429  // Write this layer's SdfData to a file in a simple generic format.
1430  SDF_API
1431  bool WriteDataFile(const std::string &filename);
1433  // @}
1435 protected:
1436  // Private constructor -- use New(), FindOrCreate(), etc.
1437  // Precondition: _layerRegistryMutex must be locked.
1438  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1439  const std::string &identifier,
1440  const std::string &realPath = std::string(),
1441  const ArAssetInfo& assetInfo = ArAssetInfo(),
1442  const FileFormatArguments &args = FileFormatArguments(),
1443  bool validateAuthoring = false);
1445 private:
1446  // Create a new layer.
1447  // Precondition: _layerRegistryMutex must be locked.
1448  static SdfLayerRefPtr _CreateNew(
1449  SdfFileFormatConstPtr fileFormat,
1450  const std::string& identifier,
1451  const FileFormatArguments& args);
1453  static SdfLayerRefPtr _CreateNewWithFormat(
1454  const SdfFileFormatConstPtr &fileFormat,
1455  const std::string& identifier,
1456  const std::string& realPath,
1457  const ArAssetInfo& assetInfo = ArAssetInfo(),
1458  const FileFormatArguments& args = FileFormatArguments());
1460  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1461  const SdfFileFormatConstPtr &fileFormat,
1462  const std::string& tag,
1463  const FileFormatArguments& args);
1465  // Finish initializing this layer (which may have succeeded or not)
1466  // and publish the results to other threads by unlocking the mutex.
1467  // Sets _initializationWasSuccessful.
1468  void _FinishInitialization(bool success);
1470  // Layers retrieved from the layer registry may still be in the
1471  // process of having their contents initialized. Other threads
1472  // retrieving layers from the registry must wait until initialization
1473  // is complete, using this method.
1474  // Returns _initializationWasSuccessful.
1475  //
1476  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1477  // ensure that it is not deleted out from under them, in
1478  // case initialization fails. (This method cannot acquire the
1479  // reference itself internally without being susceptible to a race.)
1480  bool _WaitForInitializationAndCheckIfSuccessful();
1482  // Returns whether or not this menv layer should post change
1483  // notification. This simply returns (!_GetIsLoading())
1484  bool _ShouldNotify() const;
1486  // This function keeps track of the last state of IsDirty() before
1487  // updating it. It returns false if the last saved dirty state is the
1488  // same than the current state. It returns true if the state differs and
1489  // will update the 'last dirty state' to the current state. So, after
1490  // returning true, it would return false for subsequent calls until the
1491  // IsDirty() state would change again...
1492  bool _UpdateLastDirtinessState() const;
1494  // Returns a handle to the spec at the given path if it exists and matches
1495  // type T.
1496  template <class T>
1497  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1499  // Returns true if a spec can be retrieved at the given path, false
1500  // otherwise. This function will return the canonicalized path to the
1501  // spec as well as the spec type.
1502  bool _CanGetSpecAtPath(const SdfPath& path,
1503  SdfPath* canonicalPath, SdfSpecType* specType) const;
1508  void _InitializeFromIdentifier(
1509  const std::string &identifier,
1510  const std::string &realPath = std::string(),
1511  const std::string &fileVersion = std::string(),
1512  const ArAssetInfo& assetInfo = ArAssetInfo());
1514  // Helper for computing the necessary information to lookup a layer
1515  // in the registry or open the layer.
1516  struct _FindOrOpenLayerInfo;
1517  static bool _ComputeInfoToFindOrOpenLayer(
1518  const std::string& identifier,
1519  const SdfLayer::FileFormatArguments& args,
1520  _FindOrOpenLayerInfo* info,
1521  bool computeAssetInfo = false);
1523  // Open a layer, adding an entry to the registry and releasing
1524  // the registry lock.
1525  // Precondition: _layerRegistryMutex must be locked.
1526  template <class Lock>
1527  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1528  Lock &lock,
1529  const _FindOrOpenLayerInfo& info,
1530  bool metadataOnly);
1532  // Helper function for finding a layer with \p identifier and \p args.
1533  // \p lock must be unlocked initially and will be locked by this
1534  // function when needed. See docs for \p retryAsWriter argument on
1535  // _TryToFindLayer for details on the final state of the lock when
1536  // this function returns.
1537  template <class ScopedLock>
1538  static SdfLayerRefPtr
1539  _Find(const std::string &identifier,
1540  const FileFormatArguments &args,
1541  ScopedLock &lock, bool retryAsWriter);
1543  // Helper function to try to find the layer with \p identifier and
1544  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1545  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1546  // released upon return. Otherwise the lock is released upon return if a
1547  // layer is found successfully. If no layer is found then the lock is
1548  // upgraded to a writer lock upon return. Note that this upgrade may not be
1549  // atomic, but this function ensures that if upon return there does not
1550  // exist a matching layer in the registry.
1551  template <class ScopedLock>
1552  static SdfLayerRefPtr
1553  _TryToFindLayer(const std::string &identifier,
1554  const std::string &resolvedPath,
1555  ScopedLock &lock, bool retryAsWriter);
1564  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1565  bool requiredFieldOnlyPropertiesAreInert = false) const;
1575  bool _IsInertSubtree(const SdfPath &path,
1576  std::vector<SdfPath>* inertSpecs = nullptr);
1583  void _RemoveIfInert(const SdfSpec& spec);
1589  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1593  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1596  bool _ValidateAuthoring() const { return _validateAuthoring; }
1599  std::string _GetMutedPath() const;
1601  // If old and new asset path is given, rename all external prim
1602  // composition dependency referring to the old path.
1603  void _UpdatePrimCompositionDependencyPaths(
1604  const SdfPrimSpecHandle &parent,
1605  const std::string &oldLayerPath,
1606  const std::string &newLayerPath);
1608  // Set the clean state to the current state.
1609  void _MarkCurrentStateAsClean() const;
1611  // Return the field definition for \p fieldName if \p fieldName is a
1612  // required field for the spec type identified by \p path.
1613  inline SdfSchema::FieldDefinition const *
1614  _GetRequiredFieldDef(const SdfPath &path,
1615  const TfToken &fieldName,
1616  SdfSpecType specType = SdfSpecTypeUnknown) const;
1618  // Return the field definition for \p fieldName if \p fieldName is a
1619  // required field for \p specType subject to \p schema.
1620  static inline SdfSchema::FieldDefinition const *
1621  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1622  const TfToken &fieldName,
1623  SdfSpecType specType);
1625  // Helper to list all fields on \p data at \p path subject to \p schema.
1626  static std::vector<TfToken>
1627  _ListFields(SdfSchemaBase const &schema,
1628  SdfAbstractData const &data, const SdfPath& path);
1630  // Helper for HasField for \p path in \p data subject to \p schema.
1631  static inline bool
1632  _HasField(const SdfSchemaBase &schema,
1633  const SdfAbstractData &data,
1634  const SdfPath& path,
1635  const TfToken& fieldName,
1636  VtValue *value);
1638  // Helper to get a field value for \p path in \p data subject to \p schema.
1639  static inline VtValue
1640  _GetField(const SdfSchemaBase &schema,
1641  const SdfAbstractData &data,
1642  const SdfPath& path,
1643  const TfToken& fieldName);
1645  // Set a value.
1646  template <class T>
1647  void _SetValue(const TfToken& key, T value);
1649  // Get a value.
1650  template <class T>
1651  T _GetValue(const TfToken& key) const;
1653  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1654  _ReloadResult _Reload(bool force);
1656  // Reads contents of asset specified by \p identifier with resolved
1657  // path \p resolvedPath into this layer.
1658  bool _Read(const std::string& identifier,
1659  const std::string& resolvedPath,
1660  bool metadataOnly);
1662  // Saves this layer if it is dirty or the layer doesn't already exist
1663  // on disk. If \p force is true, the layer will be written out
1664  // regardless of those conditions.
1665  bool _Save(bool force) const;
1667  // A helper method used by Save and Export.
1668  // This method allows Save to specify the existing file format and Export
1669  // to use the format provided by the file extension in newFileName. If no
1670  // file format can be discovered from the file name, the existing file
1671  // format associated with the layer will be used in both cases. This allows
1672  // users to export and save to any file name, regardless of extension.
1673  bool _WriteToFile(const std::string& newFileName,
1674  const std::string& comment,
1675  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1676  const FileFormatArguments& args = FileFormatArguments())
1677  const;
1679  // Swap contents of _data and data. This operation does not register
1680  // inverses or emit change notification.
1681  void _SwapData(SdfAbstractDataRefPtr &data);
1683  // Set _data to match data, calling other primitive setter methods to
1684  // provide fine-grained inverses and notification. If \p data might adhere
1685  // to a different schema than this layer's, pass a pointer to it as \p
1686  // newDataSchema. In this case, check to see if fields from \p data are
1687  // known to this layer's schema, and if not, omit them and issue a TfError
1688  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1689  // known fields.
1690  void _SetData(const SdfAbstractDataPtr &newData,
1691  const SdfSchemaBase *newDataSchema=nullptr);
1693  // Returns const handle to _data.
1694  SdfAbstractDataConstPtr _GetData() const;
1696  // Inverse primitive for setting a single field.
1697  template <class T>
1698  void _PrimSetField(const SdfPath& path,
1699  const TfToken& fieldName,
1700  const T& value,
1701  const VtValue *oldValue = NULL,
1702  bool useDelegate = true);
1704  // Inverse primitive for setting a single key in a dict-valued field.
1705  template <class T>
1706  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1707  const TfToken& fieldName,
1708  const TfToken& keyPath,
1709  const T& value,
1710  const VtValue *oldValue = NULL,
1711  bool useDelegate = true);
1713  // Primitive for appending a child to the list of children.
1714  template <class T>
1715  void _PrimPushChild(const SdfPath& parentPath,
1716  const TfToken& fieldName,
1717  const T& value,
1718  bool useDelegate = true);
1719  template <class T>
1720  void _PrimPopChild(const SdfPath& parentPath,
1721  const TfToken& fieldName,
1722  bool useDelegate = true);
1724  // Move all the fields at all paths at or below \a oldPath to be
1725  // at a corresponding location at or below \a newPath. This does
1726  // not update the children fields of the parents of these paths.
1727  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1729  // Inverse primitive for moving a spec.
1730  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1731  bool useDelegate = true);
1733  // Create a new spec of type \p specType at \p path.
1734  // Returns true if spec was successfully created, false otherwise.
1735  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1737  // Delete all the fields at or below the specified path. This does
1738  // not update the children field of the parent of \a path.
1739  bool _DeleteSpec(const SdfPath &path);
1741  // Inverse primitive for deleting a spec.
1742  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1743  bool useDelegate = true);
1745  // Inverse primitive for deleting a spec.
1746  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1747  bool useDelegate = true);
1749  // Inverse primitive for setting time samples.
1750  template <class T>
1751  void _PrimSetTimeSample(const SdfPath& path, double time,
1752  const T& value,
1753  bool useDelegate = true);
1755  // Helper method for Traverse. Visits the children of \a path using the
1756  // specified \a ChildPolicy.
1757  template <typename ChildPolicy>
1758  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1760 private:
1761  SdfLayerHandle _self;
1763  // File format and arguments for this layer.
1764  SdfFileFormatConstPtr _fileFormat;
1765  FileFormatArguments _fileFormatArgs;
1767  // Cached reference to the _fileFormat's schema -- we need access to this to
1768  // be as fast as possible since we look at it on every SetField(), for
1769  // example.
1770  const SdfSchemaBase &_schema;
1772  // Registry of Sdf Identities
1773  mutable Sdf_IdentityRegistry _idRegistry;
1775  // The underlying SdfData which stores all the data in the layer.
1776  SdfAbstractDataRefPtr _data;
1778  // The state delegate for this layer.
1779  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1781  // Dispatcher used in layer initialization, letting waiters participate in
1782  // loading instead of just busy-waiting.
1783  WorkDispatcher _initDispatcher;
1785  // Atomic variable protecting layer initialization -- the interval between
1786  // adding a layer to the layer registry and finishing the process of
1787  // initializing its contents, at which point we can truly publish the layer
1788  // for consumption by concurrent threads. We add the layer to the registry
1789  // before initialization completes so that other threads can discover and
1790  // wait for it to finish initializing.
1791  std::atomic<bool> _initializationComplete;
1793  // This is an optional<bool> that is only set once initialization
1794  // is complete, before _initializationComplete is set.
1795  boost::optional<bool> _initializationWasSuccessful;
1797  // remembers the last 'IsDirty' state.
1798  mutable bool _lastDirtyState;
1800  // Asset information for this layer.
1801  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1803  // Modification timestamp of the backing file asset when last read.
1804  mutable VtValue _assetModificationTime;
1806  // All external asset dependencies, with their modification timestamps, of
1807  // the layer when last read.
1808  mutable VtDictionary _externalAssetModificationTimes;
1810  // Mutable revision number for cache invalidation.
1811  mutable size_t _mutedLayersRevisionCache;
1813  // Cache of whether or not this layer is muted. Only valid if
1814  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1815  mutable bool _isMutedCache;
1817  // Layer permission bits.
1818  bool _permissionToEdit;
1819  bool _permissionToSave;
1821  // Whether layer edits are validated.
1822  bool _validateAuthoring;
1824  // Layer hints as of the most recent save operation.
1825  mutable SdfLayerHints _hints;
1827  // Allow access to _ValidateAuthoring() and _IsInert().
1828  friend class SdfSpec;
1829  friend class SdfPropertySpec;
1830  friend class SdfAttributeSpec;
1832  friend class Sdf_ChangeManager;
1834  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1835  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1837  // Give the file format access to our data. Limit breaking encapsulation
1838  // to the base SdFileFormat class so we don't have to friend every
1839  // implementation here.
1840  friend class SdfFileFormat;
1842  // Give layer state delegates access to our data as well as to
1843  // the various _Prim functions.
1844  friend class SdfLayerStateDelegateBase;
1845 };
1849 #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 scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:94
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
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:75
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:498
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:540
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:755
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:602
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:445
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:120
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:722
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:290
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:646
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:693
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:669
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:166
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:622
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.