Loading...
Searching...
No Matches
layer.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_LAYER_H
8#define PXR_USD_SDF_LAYER_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14#include "pxr/usd/sdf/data.h"
16#include "pxr/usd/sdf/identity.h"
17#include "pxr/usd/sdf/layerHints.h"
20#include "pxr/usd/sdf/path.h"
21#include "pxr/usd/sdf/proxyTypes.h"
22#include "pxr/usd/sdf/spec.h"
23#include "pxr/usd/sdf/types.h"
24#include "pxr/usd/ar/ar.h"
28#include "pxr/base/vt/value.h"
30
31#include <atomic>
32#include <functional>
33#include <memory>
34#include <optional>
35#include <set>
36#include <string>
37#include <vector>
38
39PXR_NAMESPACE_OPEN_SCOPE
40
43
44class SdfChangeList;
45struct Sdf_AssetInfo;
46
82 : public TfRefBase
83 , public TfWeakBase
84{
85public:
87 SDF_API
88 virtual ~SdfLayer();
89
91 SdfLayer(const SdfLayer&) = delete;
92 SdfLayer& operator=(const SdfLayer&) = delete;
93
97
100 SDF_API const SdfSchemaBase& GetSchema() const;
101
103 SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
104
107 typedef std::map<std::string, std::string> FileFormatArguments;
108
112
118 SDF_API
119 static SdfLayerRefPtr CreateNew(const std::string &identifier,
120 const FileFormatArguments &args =
122
129 SDF_API
130 static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
131 const std::string &identifier,
132 const FileFormatArguments &args =
134
143 SDF_API
144 static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
145 const std::string &identifier,
146 const FileFormatArguments &args =
148
155 SDF_API
156 static SdfLayerHandle Find(
157 const std::string &identifier,
159
170 SDF_API
171 static SdfLayerHandle FindRelativeToLayer(
172 const SdfLayerHandle &anchor,
173 const std::string &identifier,
175
182 SDF_API
184 const std::string &identifier,
186
197 SDF_API
199 const SdfLayerHandle &anchor,
200 const std::string &identifier,
202
216 SDF_API
218 const std::string &layerPath,
219 bool metadataOnly = false,
220 const std::string& tag = std::string());
221
223 SDF_API
224 SdfDataRefPtr GetMetadata() const;
225
229 SDF_API
231
233 SDF_API
234 static SdfLayerHandleSet GetLoadedLayers();
235
237 SDF_API
238 bool IsEmpty() const;
239
247 SDF_API
248 bool StreamsData() const;
249
255 SDF_API
256 bool IsDetached() const;
257
260 SDF_API
261 void TransferContent(const SdfLayerHandle& layer);
262
277 SDF_API
279 const std::string& tag = std::string(),
281
283 SDF_API
285 const std::string &tag, const SdfFileFormatConstPtr &format,
287
289 SDF_API
290 bool IsAnonymous() const;
291
294 SDF_API
295 static bool IsAnonymousLayerIdentifier(const std::string& identifier);
296
299 SDF_API
301 const std::string& identifier);
302
306
311 SDF_API
312 bool Save(bool force = false) const;
313
326 SDF_API
327 bool Export(const std::string& filename,
328 const std::string& comment = std::string(),
329 const FileFormatArguments& args = FileFormatArguments()) const;
330
335 SDF_API
336 bool ExportToString(std::string* result) const;
337
341 SDF_API
342 bool ImportFromString(const std::string &string);
343
351 SDF_API
352 void Clear();
353
375 SDF_API
376 bool Reload(bool force = false);
377
384 SDF_API
385 static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
386 bool force = false);
387
393 SDF_API
394 bool Import(const std::string &layerPath);
395
399
402 SDF_API
403 std::set<std::string> GetExternalReferences() const;
404
407 SDF_API
409 const std::string &oldAssetPath,
410 const std::string &newAssetPath=std::string());
411
419 SDF_API
420 std::set<std::string> GetCompositionAssetDependencies() const;
421
431 SDF_API
433 const std::string &oldAssetPath,
434 const std::string &newAssetPath=std::string());
435
444 SDF_API
445 std::set<std::string> GetExternalAssetDependencies() const;
446
466
469 SDF_API
470 static bool SplitIdentifier(
471 const std::string& identifier,
472 std::string* layerPath,
473 FileFormatArguments* arguments);
474
476 SDF_API
477 static std::string CreateIdentifier(
478 const std::string& layerPath,
479 const FileFormatArguments& arguments);
480
482 SDF_API
483 const std::string& GetIdentifier() const;
484
488 SDF_API
489 void SetIdentifier(const std::string& identifier);
490
495 SDF_API
497
501 SDF_API
502 std::string GetDisplayName() const;
503
506 SDF_API
508
511 SDF_API
512 const std::string& GetRealPath() const;
513
518 SDF_API
519 std::string GetFileExtension() const;
520
526 SDF_API
527 const std::string& GetVersion() const;
528
533 SDF_API
534 const std::string& GetRepositoryPath() const;
535
537 SDF_API
538 const std::string& GetAssetName() const;
539
542 SDF_API
543 const VtValue& GetAssetInfo() const;
544
560 SDF_API
561 std::string ComputeAbsolutePath(const std::string& assetPath) const;
562
564
575
578 SDF_API
579 SdfSpecType GetSpecType(const SdfPath& path) const;
580
582 SDF_API
583 bool HasSpec(const SdfPath& path) const;
584
586 SDF_API
587 std::vector<TfToken> ListFields(const SdfPath& path) const;
588
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;
597
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 }
608
609 SdfAbstractDataTypedValue<T> outValue(value);
610 const bool hasValue = HasField(
611 path, name, static_cast<SdfAbstractDataValue *>(&outValue));
612
613 if (std::is_same<T, SdfValueBlock>::value) {
614 return hasValue && outValue.isValueBlock;
615 }
616
617 return hasValue && (!outValue.isValueBlock);
618 }
619
622 std::type_info const &GetFieldTypeid(
623 const SdfPath &path, const TfToken &name) const {
624 return _data->GetTypeid(path, name);
625 }
626
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;
640
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 }
653
654 SdfAbstractDataTypedValue<T> outValue(value);
655 return HasFieldDictKey(path, name, keyPath,
656 static_cast<SdfAbstractDataValue *>(&outValue));
657 }
658
659
662 SDF_API
664 const TfToken& fieldName) const;
665
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 }
674
678 SDF_API
680 const TfToken& fieldName,
681 const TfToken& keyPath) const;
682
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);
690
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 }
705
708 SDF_API
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);
718
721 template <class T>
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 }
736
738 SDF_API
739 void EraseField(const SdfPath& path, const TfToken& fieldName);
740
744 SDF_API
746 const TfToken& fieldName,
747 const TfToken& keyPath);
748
751
755 typedef std::function<void(const SdfPath&)> TraversalFunction;
756
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);
761
763
766
770 SDF_API
772
774 SDF_API
775 void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
776
779 SDF_API
781
784 SDF_API
786
794 SDF_API
796
799 SDF_API
801
804 SDF_API
806
809 SDF_API
811
815 SDF_API
816 std::string GetComment() const;
817
819 SDF_API
820 void SetComment(const std::string &comment);
821
827 SDF_API
829
839 SDF_API
841
848 SDF_API
849 void SetDefaultPrim(const TfToken &name);
850
853 SDF_API
855
858 SDF_API
860
868 SDF_API
870
879 SDF_API
881
885 SDF_API
886 std::string GetDocumentation() const;
887
889 SDF_API
890 void SetDocumentation(const std::string &documentation);
891
899 SDF_API
900 double GetStartTimeCode() const;
901
903 SDF_API
904 void SetStartTimeCode(double startTimecode);
905
907 SDF_API
908 bool HasStartTimeCode() const;
909
911 SDF_API
913
920 SDF_API
921 double GetEndTimeCode() const;
922
924 SDF_API
925 void SetEndTimeCode(double endTimeCode);
926
928 SDF_API
929 bool HasEndTimeCode() const;
930
932 SDF_API
934
949 SDF_API
950 double GetTimeCodesPerSecond() const;
951
953 SDF_API
954 void SetTimeCodesPerSecond(double timeCodesPerSecond);
955
957 SDF_API
959
961 SDF_API
963
973 SDF_API
974 double GetFramesPerSecond() const;
975
977 SDF_API
978 void SetFramesPerSecond(double framesPerSecond);
979
981 SDF_API
982 bool HasFramesPerSecond() const;
983
985 SDF_API
987
989 SDF_API
990 int GetFramePrecision() const;
991
993 SDF_API
994 void SetFramePrecision(int framePrecision);
995
997 SDF_API
998 bool HasFramePrecision() const;
999
1001 SDF_API
1003
1005 SDF_API
1006 std::string GetOwner() const;
1007
1009 SDF_API
1010 void SetOwner(const std::string& owner);
1011
1013 SDF_API
1014 bool HasOwner() const;
1015
1017 SDF_API
1019
1022 SDF_API
1023 std::string GetSessionOwner() const;
1024
1027 SDF_API
1028 void SetSessionOwner(const std::string& owner);
1029
1031 SDF_API
1032 bool HasSessionOwner() const;
1033
1034 // Clear the session owner opinion.
1035 SDF_API
1036 void ClearSessionOwner();
1037
1039 SDF_API
1041
1043 SDF_API
1045
1051 SDF_API
1053
1055 SDF_API
1057
1059 SDF_API
1061
1063 SDF_API
1065
1068 SDF_API
1070
1072 SDF_API
1073 void SetExpressionVariables(const VtDictionary& expressionVars);
1074
1076 SDF_API
1078
1080 SDF_API
1082
1086
1087 // Type for root prims view.
1089
1091 SDF_API
1093
1098 SDF_API
1099 void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1100
1106 SDF_API
1107 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1108
1110 SDF_API
1111 void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1112
1115 SDF_API
1117
1130 SDF_API
1131 void RemovePrimIfInert(SdfPrimSpecHandle prim);
1132
1139 SDF_API
1140 void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1141
1147 SDF_API
1149
1154 SDF_API
1156
1165 SDF_API
1166 void SetRootPrimOrder(const std::vector<TfToken>& names);
1167
1170 SDF_API
1171 void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1172
1174 SDF_API
1176
1178 SDF_API
1180
1186 SDF_API
1187 void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1188
1192
1205 SDF_API
1207
1209 SDF_API
1210 void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1211
1213 SDF_API
1214 size_t GetNumSubLayerPaths() const;
1215
1219 SDF_API
1220 void InsertSubLayerPath(const std::string& path, int index = -1);
1221
1223 SDF_API
1224 void RemoveSubLayerPath(int index);
1225
1227 SDF_API
1228 SdfLayerOffsetVector GetSubLayerOffsets() const;
1229
1231 SDF_API
1233
1235 SDF_API
1236 void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1237
1241
1250 SDF_API
1252
1255 SDF_API
1256 void SetRelocates(const SdfRelocates& relocates);
1257
1262 SDF_API
1263 bool HasRelocates() const;
1264
1266 SDF_API
1268
1270
1291
1308 {
1309 public:
1313
1316 {
1317 _includeAll = true;
1318 _include.clear();
1319 return *this;
1320 }
1321
1324 SDF_API
1325 DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1326
1329 SDF_API
1330 DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1331
1332 bool IncludedAll() const { return _includeAll; }
1333 const std::vector<std::string>& GetIncluded() const { return _include; }
1334 const std::vector<std::string>& GetExcluded() const { return _exclude; }
1335
1343 SDF_API
1344 bool IsIncluded(const std::string& identifier) const;
1345
1346 private:
1347 friend class SdfLayer;
1348
1349 std::vector<std::string> _include;
1350 std::vector<std::string> _exclude;
1351 bool _includeAll = false;
1352 };
1353
1376 SDF_API
1378
1380 SDF_API
1382
1386 SDF_API
1387 static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1388
1390
1393
1395 SDF_API
1396 static std::set<std::string> GetMutedLayers();
1397
1399 SDF_API
1400 bool IsMuted() const;
1401
1403 SDF_API
1404 static bool IsMuted(const std::string &path);
1405
1408 SDF_API
1409 void SetMuted(bool muted);
1410
1412 SDF_API
1413 static void AddToMutedLayers(const std::string &mutedPath);
1414
1416 SDF_API
1417 static void RemoveFromMutedLayers(const std::string &mutedPath);
1418
1422
1432 SDF_API
1433 SdfPrimSpecHandle GetPseudoRoot() const;
1434
1441 SDF_API
1442 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1443
1449 SDF_API
1450 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1451
1457 SDF_API
1458 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1459
1465 SDF_API
1466 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1467
1473 SDF_API
1474 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1475
1479
1483 SDF_API
1484 bool PermissionToEdit() const;
1485
1488 SDF_API
1489 bool PermissionToSave() const;
1490
1492 SDF_API
1493 void SetPermissionToEdit(bool allow);
1494
1496 SDF_API
1497 void SetPermissionToSave(bool allow);
1498
1502
1526 SDF_API
1529 SdfNamespaceEditDetailVector* details = NULL) const;
1530
1534 SDF_API
1536
1540
1543 SDF_API
1544 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1545
1549 SDF_API
1550 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1551
1554 SDF_API
1555 bool IsDirty() const;
1556
1558
1561 SDF_API
1562 std::set<double> ListAllTimeSamples() const;
1563
1564 SDF_API
1565 std::set<double>
1566 ListTimeSamplesForPath(const SdfPath& path) const;
1567
1568 SDF_API
1569 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1570
1571 SDF_API
1572 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1573
1574 SDF_API
1575 bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1576 double time,
1577 double* tLower, double* tUpper) const;
1578
1585 SDF_API
1586 bool GetPreviousTimeSampleForPath(const SdfPath& path, double time,
1587 double* tPrevious) const;
1588
1589 SDF_API
1590 bool QueryTimeSample(const SdfPath& path, double time,
1591 VtValue *value=NULL) const;
1592
1593 SDF_API
1594 bool QueryTimeSample(const SdfPath& path, double time,
1595 SdfAbstractDataValue *value) const;
1596
1597 template <class T>
1598 bool QueryTimeSample(const SdfPath& path, double time,
1599 T* data) const
1600 {
1601 if (!data) {
1602 return QueryTimeSample(path, time);
1603 }
1604
1605 SdfAbstractDataTypedValue<T> outValue(data);
1606 const bool hasValue = QueryTimeSample(
1607 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1608
1609 if (std::is_same<T, SdfValueBlock>::value) {
1610 return hasValue && outValue.isValueBlock;
1611 }
1612
1613 return hasValue && (!outValue.isValueBlock);
1614 }
1615
1616 SDF_API
1617 void SetTimeSample(const SdfPath& path, double time,
1618 const VtValue & value);
1619
1620 SDF_API
1621 void SetTimeSample(const SdfPath& path, double time,
1622 const SdfAbstractDataConstValue& value);
1623
1624 template <class T>
1625 void SetTimeSample(const SdfPath& path, double time,
1626 const T& value)
1627 {
1628 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1629 const SdfAbstractDataConstValue& untypedInValue = inValue;
1630 return SetTimeSample(path, time, untypedInValue);
1631 }
1632
1633 SDF_API
1634 void EraseTimeSample(const SdfPath& path, double time);
1635
1637
1638 // Debugging
1639 // @{
1640
1641 SDF_API
1642 static void DumpLayerInfo();
1643
1644 // Write this layer's SdfData to a file in a simple generic format.
1645 SDF_API
1646 bool WriteDataFile(const std::string &filename);
1647
1648 // @}
1649
1657 SDF_API
1659 const SdfLayerHandle& layer,
1660 bool processPropertyFields = true) const;
1661
1662protected:
1663 // Private constructor -- use New(), FindOrCreate(), etc.
1664 // Precondition: _layerRegistryMutex must be locked.
1665 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1666 const std::string &identifier,
1667 const std::string &realPath = std::string(),
1668 const ArAssetInfo& assetInfo = ArAssetInfo(),
1670 bool validateAuthoring = false);
1671
1672private:
1673 // Create a new layer.
1674 // Precondition: _layerRegistryMutex must be locked.
1675 static SdfLayerRefPtr _CreateNew(
1676 SdfFileFormatConstPtr fileFormat,
1677 const std::string& identifier,
1678 const FileFormatArguments& args,
1679 bool saveLayer = true);
1680
1681 static SdfLayerRefPtr _CreateNewWithFormat(
1682 const SdfFileFormatConstPtr &fileFormat,
1683 const std::string& identifier,
1684 const std::string& realPath,
1685 const ArAssetInfo& assetInfo = ArAssetInfo(),
1687
1688 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1689 const SdfFileFormatConstPtr &fileFormat,
1690 const std::string& tag,
1691 const FileFormatArguments& args);
1692
1693 // Finish initializing this layer (which may have succeeded or not)
1694 // and publish the results to other threads by unlocking the mutex.
1695 // Sets _initializationWasSuccessful.
1696 void _FinishInitialization(bool success);
1697
1698 // Layers retrieved from the layer registry may still be in the
1699 // process of having their contents initialized. Other threads
1700 // retrieving layers from the registry must wait until initialization
1701 // is complete, using this method.
1702 // Returns _initializationWasSuccessful.
1703 //
1704 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1705 // ensure that it is not deleted out from under them, in
1706 // case initialization fails. (This method cannot acquire the
1707 // reference itself internally without being susceptible to a race.)
1708 bool _WaitForInitializationAndCheckIfSuccessful();
1709
1710 // Returns whether or not this layer should post change
1711 // notification. This simply returns (!_GetIsLoading())
1712 bool _ShouldNotify() const;
1713
1714 // This function keeps track of the last state of IsDirty() before
1715 // updating it. It returns false if the last saved dirty state is the
1716 // same than the current state. It returns true if the state differs and
1717 // will update the 'last dirty state' to the current state. So, after
1718 // returning true, it would return false for subsequent calls until the
1719 // IsDirty() state would change again...
1720 bool _UpdateLastDirtinessState() const;
1721
1722 // Returns a handle to the spec at the given path if it exists and matches
1723 // type T.
1724 template <class T>
1725 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1726
1727 // Returns true if a spec can be retrieved at the given path, false
1728 // otherwise. This function will return the canonicalized path to the
1729 // spec as well as the spec type.
1730 bool _CanGetSpecAtPath(const SdfPath& path,
1731 SdfPath* canonicalPath, SdfSpecType* specType) const;
1732
1736 void _InitializeFromIdentifier(
1737 const std::string &identifier,
1738 const std::string &realPath = std::string(),
1739 const std::string &fileVersion = std::string(),
1740 const ArAssetInfo& assetInfo = ArAssetInfo());
1741
1742 // Helper for computing the necessary information to lookup a layer
1743 // in the registry or open the layer.
1744 struct _FindOrOpenLayerInfo;
1745 static bool _ComputeInfoToFindOrOpenLayer(
1746 const std::string& identifier,
1748 _FindOrOpenLayerInfo* info,
1749 bool computeAssetInfo = false);
1750
1751 // Open a layer, adding an entry to the registry and releasing
1752 // the registry lock.
1753 // Precondition: _layerRegistryMutex must be locked.
1754 template <class Lock>
1755 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1756 Lock &lock,
1757 const _FindOrOpenLayerInfo& info,
1758 bool metadataOnly);
1759
1760 // Helper function for finding a layer with \p identifier and \p args.
1761 // \p lock must be unlocked initially and will be locked by this
1762 // function when needed. See docs for \p retryAsWriter argument on
1763 // _TryToFindLayer for details on the final state of the lock when
1764 // this function returns.
1765 template <class ScopedLock>
1766 static SdfLayerRefPtr
1767 _Find(const std::string &identifier,
1768 const FileFormatArguments &args,
1769 ScopedLock &lock, bool retryAsWriter);
1770
1771 // Helper function to try to find the layer with \p identifier and
1772 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1773 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1774 // released upon return. Otherwise the lock is released upon return if a
1775 // layer is found successfully. If no layer is found then the lock is
1776 // upgraded to a writer lock upon return. Note that this upgrade may not be
1777 // atomic, but this function ensures that if upon return there does not
1778 // exist a matching layer in the registry.
1779 template <class ScopedLock>
1780 static SdfLayerRefPtr
1781 _TryToFindLayer(const std::string &identifier,
1782 const ArResolvedPath &resolvedPath,
1783 ScopedLock &lock, bool retryAsWriter);
1784
1792 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1793 bool requiredFieldOnlyPropertiesAreInert = false) const;
1794
1798 bool _IsInertSubtree(const SdfPath &path) const;
1799
1805 void _RemoveIfInert(const SdfSpec& spec);
1806
1811 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1812
1815 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1816
1818 bool _ValidateAuthoring() const { return _validateAuthoring; }
1819
1821 std::string _GetMutedPath() const;
1822
1823 // If old and new asset path is given, rename all external prim
1824 // composition dependency referring to the old path.
1825 void _UpdatePrimCompositionDependencyPaths(
1826 const SdfPrimSpecHandle &parent,
1827 const std::string &oldLayerPath,
1828 const std::string &newLayerPath);
1829
1830 // Set the clean state to the current state.
1831 void _MarkCurrentStateAsClean() const;
1832
1833 // Return the field definition for \p fieldName if \p fieldName is a
1834 // required field for the spec type identified by \p path.
1835 inline SdfSchema::FieldDefinition const *
1836 _GetRequiredFieldDef(const SdfPath &path,
1837 const TfToken &fieldName,
1838 SdfSpecType specType = SdfSpecTypeUnknown) const;
1839
1840 // Return the field definition for \p fieldName if \p fieldName is a
1841 // required field for \p specType subject to \p schema.
1842 static inline SdfSchema::FieldDefinition const *
1843 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1844 const TfToken &fieldName,
1845 SdfSpecType specType);
1846
1847 // Helper to list all fields on \p data at \p path subject to \p schema.
1848 static std::vector<TfToken>
1849 _ListFields(SdfSchemaBase const &schema,
1850 SdfAbstractData const &data, const SdfPath& path);
1851
1852 // Helper for HasField for \p path in \p data subject to \p schema.
1853 static inline bool
1854 _HasField(const SdfSchemaBase &schema,
1855 const SdfAbstractData &data,
1856 const SdfPath& path,
1857 const TfToken& fieldName,
1858 VtValue *value);
1859
1860 // Helper to get a field value for \p path in \p data subject to \p schema.
1861 static inline VtValue
1862 _GetField(const SdfSchemaBase &schema,
1863 const SdfAbstractData &data,
1864 const SdfPath& path,
1865 const TfToken& fieldName);
1866
1867 // Set a value.
1868 template <class T>
1869 void _SetValue(const TfToken& key, T value);
1870
1871 // Get a value.
1872 template <class T>
1873 T _GetValue(const TfToken& key) const;
1874
1875 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1876 _ReloadResult _Reload(bool force);
1877
1878 // Reads contents of asset specified by \p identifier with resolved
1879 // path \p resolvedPath into this layer.
1880 bool _Read(const std::string& identifier,
1881 const ArResolvedPath& resolvedPath,
1882 bool metadataOnly);
1883
1884 // Saves this layer if it is dirty or the layer doesn't already exist
1885 // on disk. If \p force is true, the layer will be written out
1886 // regardless of those conditions.
1887 bool _Save(bool force) const;
1888
1889 // A helper method used by Save and Export.
1890 // This method allows Save to specify the existing file format and Export
1891 // to use the format provided by the file extension in newFileName. If no
1892 // file format can be discovered from the file name, the existing file
1893 // format associated with the layer will be used in both cases. This allows
1894 // users to export and save to any file name, regardless of extension.
1895 bool _WriteToFile(const std::string& newFileName,
1896 const std::string& comment,
1897 SdfFileFormatConstPtr fileFormat,
1898 const FileFormatArguments& args) const;
1899
1900 // Swap contents of _data and data. This operation does not register
1901 // inverses or emit change notification.
1902 void _SwapData(SdfAbstractDataRefPtr &data);
1903
1904 // Set _data to \p newData and send coarse DidReplaceLayerContent
1905 // invalidation notice.
1906 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1907
1908 // Helper function which will process incoming data to this layer in a
1909 // generic way.
1910 // If \p processPropertyFields is false, this method will not
1911 // consider property spec fields. In some cases, this can avoid expensive
1912 // operations which would pull large amounts of data.
1913 template<typename DeleteSpecFunc, typename CreateSpecFunc,
1914 typename GetFieldValuesFunc, typename SetFieldFunc, typename ErrorFunc>
1915 void _ProcessIncomingData(const SdfAbstractDataPtr &newData,
1916 const SdfSchemaBase *newDataSchema,
1917 bool processPropertyFields,
1918 const DeleteSpecFunc &deleteSpecFunc,
1919 const CreateSpecFunc &createSpecFunc,
1920 const GetFieldValuesFunc &getFieldValuesFunc,
1921 const SetFieldFunc &setFieldFunc,
1922 const ErrorFunc &errorFunc) const;
1923
1924 // Set _data to match data, calling other primitive setter methods to
1925 // provide fine-grained inverses and notification. If \p data might adhere
1926 // to a different schema than this layer's, pass a pointer to it as \p
1927 // newDataSchema. In this case, check to see if fields from \p data are
1928 // known to this layer's schema, and if not, omit them and issue a TfError
1929 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1930 // known fields.
1931 void _SetData(const SdfAbstractDataPtr &newData,
1932 const SdfSchemaBase *newDataSchema=nullptr);
1933
1934 // Returns const handle to _data.
1935 SdfAbstractDataConstPtr _GetData() const;
1936
1937 // Returns a new SdfAbstractData object for this layer.
1938 SdfAbstractDataRefPtr _CreateData() const;
1939
1940 // Inverse primitive for setting a single field. The previous value for the
1941 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1942 // VtValue it points to will be moved-from after the function completes. If
1943 // \p oldValue is nullptr, the old field value will be retrieved
1944 // automatically.
1945 template <class T>
1946 void _PrimSetField(const SdfPath& path,
1947 const TfToken& fieldName,
1948 const T& value,
1949 VtValue *oldValue = nullptr,
1950 bool useDelegate = true);
1951
1952 // Inverse primitive for setting a single key in a dict-valued field. The
1953 // previous dictionary value for the field (*not* the individual entry) may
1954 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1955 // it points to will be moved-from after the function completes. If \p
1956 // oldValue is nullptr, the old field value will be retrieved automatically.
1957 template <class T>
1958 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1959 const TfToken& fieldName,
1960 const TfToken& keyPath,
1961 const T& value,
1962 VtValue *oldValue = nullptr,
1963 bool useDelegate = true);
1964
1965 // Primitive for appending a child to the list of children.
1966 template <class T>
1967 void _PrimPushChild(const SdfPath& parentPath,
1968 const TfToken& fieldName,
1969 const T& value,
1970 bool useDelegate = true);
1971 template <class T>
1972 void _PrimPopChild(const SdfPath& parentPath,
1973 const TfToken& fieldName,
1974 bool useDelegate = true);
1975
1976 // Move all the fields at all paths at or below \a oldPath to be
1977 // at a corresponding location at or below \a newPath. This does
1978 // not update the children fields of the parents of these paths.
1979 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1980
1981 // Inverse primitive for moving a spec.
1982 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1983 bool useDelegate = true);
1984
1985 // Create a new spec of type \p specType at \p path.
1986 // Returns true if spec was successfully created, false otherwise.
1987 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1988
1989 // Delete all the fields at or below the specified path. This does
1990 // not update the children field of the parent of \a path.
1991 bool _DeleteSpec(const SdfPath &path);
1992
1993 // Inverse primitive for deleting a spec.
1994 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1995 bool useDelegate = true);
1996
1997 // Inverse primitive for deleting a spec.
1998 void _PrimDeleteSpec(const SdfPath &path, bool inert,
1999 bool useDelegate = true);
2000
2001 // Inverse primitive for setting time samples.
2002 template <class T>
2003 void _PrimSetTimeSample(const SdfPath& path, double time,
2004 const T& value,
2005 bool useDelegate = true);
2006
2007 // Helper method for Traverse. Visits the children of \a path using the
2008 // specified \a ChildPolicy.
2009 template <typename ChildPolicy>
2010 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
2011
2012private:
2013 SdfLayerHandle _self;
2014
2015 // File format and arguments for this layer.
2016 SdfFileFormatConstPtr _fileFormat;
2017 FileFormatArguments _fileFormatArgs;
2018
2019 // Cached reference to the _fileFormat's schema -- we need access to this to
2020 // be as fast as possible since we look at it on every SetField(), for
2021 // example.
2022 const SdfSchemaBase &_schema;
2023
2024 // Registry of Sdf Identities
2025 mutable Sdf_IdentityRegistry _idRegistry;
2026
2027 // The underlying SdfData which stores all the data in the layer.
2028 SdfAbstractDataRefPtr _data;
2029
2030 // The state delegate for this layer.
2031 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
2032
2033 // Dispatcher used in layer initialization, letting waiters participate in
2034 // loading instead of just busy-waiting.
2035 WorkDispatcher _initDispatcher;
2036
2037 // Atomic variable protecting layer initialization -- the interval between
2038 // adding a layer to the layer registry and finishing the process of
2039 // initializing its contents, at which point we can truly publish the layer
2040 // for consumption by concurrent threads. We add the layer to the registry
2041 // before initialization completes so that other threads can discover and
2042 // wait for it to finish initializing.
2043 std::atomic<bool> _initializationComplete;
2044
2045 // This is an optional<bool> that is only set once initialization
2046 // is complete, before _initializationComplete is set.
2047 std::optional<bool> _initializationWasSuccessful;
2048
2049 // remembers the last 'IsDirty' state.
2050 mutable bool _lastDirtyState;
2051
2052 // Asset information for this layer.
2053 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
2054
2055 // Modification timestamp of the backing file asset when last read.
2056 mutable VtValue _assetModificationTime;
2057
2058 // All external asset dependencies, with their modification timestamps, of
2059 // the layer when last read.
2060 mutable VtDictionary _externalAssetModificationTimes;
2061
2062 // Mutable revision number for cache invalidation.
2063 mutable size_t _mutedLayersRevisionCache;
2064
2065 // Cache of whether or not this layer is muted. Only valid if
2066 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2067 mutable bool _isMutedCache;
2068
2069 // Layer permission bits.
2070 bool _permissionToEdit;
2071 bool _permissionToSave;
2072
2073 // Whether layer edits are validated.
2074 bool _validateAuthoring;
2075
2076 // Layer hints as of the most recent save operation.
2077 mutable SdfLayerHints _hints;
2078
2079 // Allow access to _ValidateAuthoring() and _IsInert().
2080 friend class SdfSpec;
2081 friend class SdfPropertySpec;
2082 friend class SdfAttributeSpec;
2083
2084 friend class Sdf_ChangeManager;
2085
2086 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2087 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2088
2089 // Give the file format access to our data. Limit breaking encapsulation
2090 // to the base SdFileFormat class so we don't have to friend every
2091 // implementation here.
2092 friend class SdfFileFormat;
2093
2094 // Give layer state delegates access to our data as well as to
2095 // the various _Prim functions.
2096 friend class SdfLayerStateDelegateBase;
2097};
2098
2099PXR_NAMESPACE_CLOSE_SCOPE
2100
2101#endif // PXR_USD_SDF_LAYER_H
Contains information about a resolved asset.
Definition: assetInfo.h:25
Represents a resolved asset path.
Definition: resolvedPath.h:23
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:592
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:544
Interface for scene description data storage.
Definition: abstractData.h:57
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:482
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:417
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:79
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:42
A description of an arbitrarily complex namespace edit.
A list of scene description modifications, organized by the namespace paths where the changes occur.
Definition: changeList.h:36
Provides a view onto an object's children.
Definition: childrenView.h:205
Base class for file format implementations.
Definition: fileFormat.h:50
SdfHandle is a smart ptr that calls IsDormant() on the pointed-to object as an extra expiration check...
Object used to specify detached layers.
Definition: layer.h:1308
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1315
SDF_API DetachedLayerRules & Include(const std::vector< std::string > &patterns)
Include layers whose identifiers contain any of the strings in patterns in the detached layer set.
SDF_API DetachedLayerRules & Exclude(const std::vector< std::string > &patterns)
Exclude layers whose identifiers contain any of the strings in patterns from the detached layer set.
DetachedLayerRules()=default
A default constructed rules object Excludes all layers from the detached layer set.
SDF_API bool IsIncluded(const std::string &identifier) const
Returns true if identifier is included in the detached layer set, false otherwise.
Contains hints about layer contents that may be used to accelerate certain composition operations.
Definition: layerHints.h:17
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API bool Import(const std::string &layerPath)
Imports the content of the given layer path, replacing the content of the current 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
SDF_API TfToken GetColorManagementSystem() const
Returns the color management system used to interpret the color configuration asset-path authored in ...
SDF_API SdfRelocates GetRelocates() const
Get the list of relocates specified in this layer's metadata.
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
SDF_API double GetEndTimeCode() const
Returns the layer's end timeCode.
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
Returns a proxy for this layer's sublayers.
SDF_API std::set< std::string > GetCompositionAssetDependencies() const
Return paths of all assets this layer depends on due to composition fields.
SDF_API bool StreamsData() const
Returns true if this layer streams data from its serialized data store on demand, false otherwise.
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.
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
Adds a new root prim name in the root prim order.
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
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.
virtual SDF_API ~SdfLayer()
Destructor.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag, const SdfFileFormatConstPtr &format, const FileFormatArguments &args=FileFormatArguments())
Create an anonymous layer with a specific format.
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:107
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
Returns the list of prim names for this layer's reorder rootPrims statement.
SDF_API bool IsDirty() const
Returns true if the layer is dirty, i.e.
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
SDF_API bool ImportFromString(const std::string &string)
Reads this layer from the given string.
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
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.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
Check if a batch of namespace edits will succeed.
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema this layer adheres to.
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
static SDF_API bool IsMuted(const std::string &path)
Returns true if the specified layer path is muted.
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
SDF_API std::string GetOwner() const
Returns the layer's owner.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
SDF_API void SetPermissionToSave(bool allow)
Sets permission to save.
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 bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
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.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path 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 void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API void SetIdentifier(const std::string &identifier)
Sets the layer identifier.
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
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.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
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 void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
static SDF_API SdfPath ConvertDefaultPrimTokenToPath(const TfToken &defaultPrim)
Converts the given defaultPrim token into a prim path.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
Removes scene description that does not affect the scene in the layer namespace beginning with prim.
static SDF_API SdfLayerRefPtr CreateNew(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 SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
Sets a new vector of root prims.
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 SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API bool HasDefaultPrim()
Return true if the default prim metadata is set in this layer.
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer's pseudo-root prim.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
SDF_API const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
Removes prop if it has only required fields (i.e.
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 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 GetFramesPerSecond() const
Returns the layer's frames per second.
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
Returns the object at the given path.
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
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 bool HasColorManagementSystem() const
Returns true if colorManagementSystem metadata is set in this layer.
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.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for the given path and fieldName.
SDF_API bool IsDetached() const
Returns true if this layer is detached from its serialized data store, false otherwise.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
Returns the prim at the given path.
SDF_API void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API bool PermissionToEdit() const
Returns true if the caller is allowed to modify the layer and false otherwise.
SDF_API VtDictionary GetExpressionVariables() const
Returns the expression variables dictionary authored on this layer.
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.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
static SDF_API const DetachedLayerRules & GetDetachedLayerRules()
Returns the current rules for the detached layer set.
static SDF_API TfToken ConvertDefaultPrimPathToToken(const SdfPath &primPath)
Converts the path primPath into a token value that can be used to set the default prim metadata for t...
SDF_API SdfPath GetDefaultPrimAsPath() const
Return this layer's default prim metadata interpreted as an absolute prim path regardless of whether ...
SDF_API void UpdateAssetInfo()
Update layer asset information.
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
SDF_API void ClearRelocates()
Clears the layer relocates opinion in the layer's metadata.
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
SDF_API SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
SDF_API void SetRelocates(const SdfRelocates &relocates)
Set the entire list of namespace relocations specified on this layer to relocates.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
SDF_API void Clear()
Clears the layer of all content.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API void SetExpressionVariables(const VtDictionary &expressionVars)
Sets the expression variables dictionary for this layer.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
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 std::string GetComment() const
Returns the comment string for this layer.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
SDF_API bool HasExpressionVariables() const
Returns true if expression variables are authored on this layer.
SDF_API void ClearExpressionVariables()
Clears the expression variables dictionary authored on this layer.
SDF_API SdfChangeList CreateDiff(const SdfLayerHandle &layer, bool processPropertyFields=true) const
Returns a SdfChangeList containing the minimal edits that would be needed to transform this layer to ...
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 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
Adds a new root prim at the given index.
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
SDF_API bool Reload(bool force=false)
Reloads the layer from its persistent representation.
SDF_API void ClearColorManagementSystem()
Clears the 'colorManagementSystem' metadata authored in this layer.
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
Inserts new sublayer path at the given index.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
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 void SetMuted(bool muted)
Mutes the current layer if muted is true, and unmutes it otherwise.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer's authoring state.
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.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer's authoring state.
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API double GetStartTimeCode() const
Returns the layer's start timeCode.
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API std::string GetDisplayName() const
Returns the layer's display name.
SDF_API bool GetPreviousTimeSampleForPath(const SdfPath &path, double time, double *tPrevious) const
Returns the previous time sample authored just before the querying time.
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 void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
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 void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
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 bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
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
static SDF_API void SetDetachedLayerRules(const DetachedLayerRules &mask)
Sets the rules specifying detached layers.
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 void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API void RemoveInertSceneDescription()
Removes all scene description in this layer that does not affect the scene.
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.
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
SDF_API void TransferContent(const SdfLayerHandle &layer)
Copies the content of the given layer into this layer.
static SDF_API bool IsIncludedByDetachedLayerRules(const std::string &identifier)
Returns whether the given layer identifier is included in the current rules for the detached layer se...
SDF_API const std::string & GetVersion() const
Returns the asset system version of this layer.
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 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 void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API std::string GetSessionOwner() const
Returns the layer's session owner.
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.
std::function< void(const SdfPath &)> TraversalFunction
Callback function for Traverse.
Definition: layer.h:755
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
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 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
SDF_API void ClearOwner()
Clear the owner opinion.
SDF_API bool HasRelocates() const
Returns true if this layer's metadata has any relocates opinion, including that there should be no re...
Represents a time offset and scale between layers.
Definition: layerOffset.h:44
Maintains authoring state information for an associated layer.
Represents a single list of list editing operations.
Definition: listProxy.h:37
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:47
Class defining various attributes for a field.
Definition: schema.h:56
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:45
Base class for all Sdf spec classes.
Definition: spec.h:33
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A map with string keys and VtValue values.
Definition: dictionary.h:52
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:176
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:45
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
Result
Validity of an edit.
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:71
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
Definition: types.h:277