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
1431 SDF_API
1432 SdfPrimSpecHandle GetPseudoRoot() const;
1433
1440 SDF_API
1441 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1442
1448 SDF_API
1449 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1450
1456 SDF_API
1457 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1458
1464 SDF_API
1465 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1466
1472 SDF_API
1473 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1474
1478
1482 SDF_API
1483 bool PermissionToEdit() const;
1484
1487 SDF_API
1488 bool PermissionToSave() const;
1489
1491 SDF_API
1492 void SetPermissionToEdit(bool allow);
1493
1495 SDF_API
1496 void SetPermissionToSave(bool allow);
1497
1501
1525 SDF_API
1528 SdfNamespaceEditDetailVector* details = NULL) const;
1529
1533 SDF_API
1535
1539
1542 SDF_API
1543 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1544
1548 SDF_API
1549 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1550
1553 SDF_API
1554 bool IsDirty() const;
1555
1557
1560 SDF_API
1561 std::set<double> ListAllTimeSamples() const;
1562
1563 SDF_API
1564 std::set<double>
1565 ListTimeSamplesForPath(const SdfPath& path) const;
1566
1567 SDF_API
1568 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1569
1570 SDF_API
1571 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1572
1573 SDF_API
1574 bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1575 double time,
1576 double* tLower, double* tUpper) const;
1577
1584 SDF_API
1585 bool GetPreviousTimeSampleForPath(const SdfPath& path, double time,
1586 double* tPrevious) const;
1587
1588 SDF_API
1589 bool QueryTimeSample(const SdfPath& path, double time,
1590 VtValue *value=NULL) const;
1591
1592 SDF_API
1593 bool QueryTimeSample(const SdfPath& path, double time,
1594 SdfAbstractDataValue *value) const;
1595
1596 template <class T>
1597 bool QueryTimeSample(const SdfPath& path, double time,
1598 T* data) const
1599 {
1600 if (!data) {
1601 return QueryTimeSample(path, time);
1602 }
1603
1604 SdfAbstractDataTypedValue<T> outValue(data);
1605 const bool hasValue = QueryTimeSample(
1606 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1607
1608 if (std::is_same<T, SdfValueBlock>::value) {
1609 return hasValue && outValue.isValueBlock;
1610 }
1611
1612 return hasValue && (!outValue.isValueBlock);
1613 }
1614
1615 SDF_API
1616 void SetTimeSample(const SdfPath& path, double time,
1617 const VtValue & value);
1618
1619 SDF_API
1620 void SetTimeSample(const SdfPath& path, double time,
1621 const SdfAbstractDataConstValue& value);
1622
1623 template <class T>
1624 void SetTimeSample(const SdfPath& path, double time,
1625 const T& value)
1626 {
1627 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1628 const SdfAbstractDataConstValue& untypedInValue = inValue;
1629 return SetTimeSample(path, time, untypedInValue);
1630 }
1631
1632 SDF_API
1633 void EraseTimeSample(const SdfPath& path, double time);
1634
1636
1637 // Debugging
1638 // @{
1639
1640 SDF_API
1641 static void DumpLayerInfo();
1642
1643 // Write this layer's SdfData to a file in a simple generic format.
1644 SDF_API
1645 bool WriteDataFile(const std::string &filename);
1646
1647 // @}
1648
1656 SDF_API
1658 const SdfLayerHandle& layer,
1659 bool processPropertyFields = true) const;
1660
1661protected:
1662 // Private constructor -- use New(), FindOrCreate(), etc.
1663 // Precondition: _layerRegistryMutex must be locked.
1664 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1665 const std::string &identifier,
1666 const std::string &realPath = std::string(),
1667 const ArAssetInfo& assetInfo = ArAssetInfo(),
1669 bool validateAuthoring = false);
1670
1671private:
1672 // Create a new layer.
1673 // Precondition: _layerRegistryMutex must be locked.
1674 static SdfLayerRefPtr _CreateNew(
1675 SdfFileFormatConstPtr fileFormat,
1676 const std::string& identifier,
1677 const FileFormatArguments& args,
1678 bool saveLayer = true);
1679
1680 static SdfLayerRefPtr _CreateNewWithFormat(
1681 const SdfFileFormatConstPtr &fileFormat,
1682 const std::string& identifier,
1683 const std::string& realPath,
1684 const ArAssetInfo& assetInfo = ArAssetInfo(),
1686
1687 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1688 const SdfFileFormatConstPtr &fileFormat,
1689 const std::string& tag,
1690 const FileFormatArguments& args);
1691
1692 // Finish initializing this layer (which may have succeeded or not)
1693 // and publish the results to other threads by unlocking the mutex.
1694 // Sets _initializationWasSuccessful.
1695 void _FinishInitialization(bool success);
1696
1697 // Layers retrieved from the layer registry may still be in the
1698 // process of having their contents initialized. Other threads
1699 // retrieving layers from the registry must wait until initialization
1700 // is complete, using this method.
1701 // Returns _initializationWasSuccessful.
1702 //
1703 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1704 // ensure that it is not deleted out from under them, in
1705 // case initialization fails. (This method cannot acquire the
1706 // reference itself internally without being susceptible to a race.)
1707 bool _WaitForInitializationAndCheckIfSuccessful();
1708
1709 // Returns whether or not this layer should post change
1710 // notification. This simply returns (!_GetIsLoading())
1711 bool _ShouldNotify() const;
1712
1713 // This function keeps track of the last state of IsDirty() before
1714 // updating it. It returns false if the last saved dirty state is the
1715 // same than the current state. It returns true if the state differs and
1716 // will update the 'last dirty state' to the current state. So, after
1717 // returning true, it would return false for subsequent calls until the
1718 // IsDirty() state would change again...
1719 bool _UpdateLastDirtinessState() const;
1720
1721 // Returns a handle to the spec at the given path if it exists and matches
1722 // type T.
1723 template <class T>
1724 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1725
1726 // Returns true if a spec can be retrieved at the given path, false
1727 // otherwise. This function will return the canonicalized path to the
1728 // spec as well as the spec type.
1729 bool _CanGetSpecAtPath(const SdfPath& path,
1730 SdfPath* canonicalPath, SdfSpecType* specType) const;
1731
1735 void _InitializeFromIdentifier(
1736 const std::string &identifier,
1737 const std::string &realPath = std::string(),
1738 const std::string &fileVersion = std::string(),
1739 const ArAssetInfo& assetInfo = ArAssetInfo());
1740
1741 // Helper for computing the necessary information to lookup a layer
1742 // in the registry or open the layer.
1743 struct _FindOrOpenLayerInfo;
1744 static bool _ComputeInfoToFindOrOpenLayer(
1745 const std::string& identifier,
1747 _FindOrOpenLayerInfo* info,
1748 bool computeAssetInfo = false);
1749
1750 // Open a layer, adding an entry to the registry and releasing
1751 // the registry lock.
1752 // Precondition: _layerRegistryMutex must be locked.
1753 template <class Lock>
1754 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1755 Lock &lock,
1756 const _FindOrOpenLayerInfo& info,
1757 bool metadataOnly);
1758
1759 // Helper function for finding a layer with \p identifier and \p args.
1760 // \p lock must be unlocked initially and will be locked by this
1761 // function when needed. See docs for \p retryAsWriter argument on
1762 // _TryToFindLayer for details on the final state of the lock when
1763 // this function returns.
1764 template <class ScopedLock>
1765 static SdfLayerRefPtr
1766 _Find(const std::string &identifier,
1767 const FileFormatArguments &args,
1768 ScopedLock &lock, bool retryAsWriter);
1769
1770 // Helper function to try to find the layer with \p identifier and
1771 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1772 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1773 // released upon return. Otherwise the lock is released upon return if a
1774 // layer is found successfully. If no layer is found then the lock is
1775 // upgraded to a writer lock upon return. Note that this upgrade may not be
1776 // atomic, but this function ensures that if upon return there does not
1777 // exist a matching layer in the registry.
1778 template <class ScopedLock>
1779 static SdfLayerRefPtr
1780 _TryToFindLayer(const std::string &identifier,
1781 const ArResolvedPath &resolvedPath,
1782 ScopedLock &lock, bool retryAsWriter);
1783
1791 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1792 bool requiredFieldOnlyPropertiesAreInert = false) const;
1793
1797 bool _IsInertSubtree(const SdfPath &path) const;
1798
1804 void _RemoveIfInert(const SdfSpec& spec);
1805
1810 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1811
1814 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1815
1817 bool _ValidateAuthoring() const { return _validateAuthoring; }
1818
1820 std::string _GetMutedPath() const;
1821
1822 // If old and new asset path is given, rename all external prim
1823 // composition dependency referring to the old path.
1824 void _UpdatePrimCompositionDependencyPaths(
1825 const SdfPrimSpecHandle &parent,
1826 const std::string &oldLayerPath,
1827 const std::string &newLayerPath);
1828
1829 // Set the clean state to the current state.
1830 void _MarkCurrentStateAsClean() const;
1831
1832 // Return the field definition for \p fieldName if \p fieldName is a
1833 // required field for the spec type identified by \p path.
1834 inline SdfSchema::FieldDefinition const *
1835 _GetRequiredFieldDef(const SdfPath &path,
1836 const TfToken &fieldName,
1837 SdfSpecType specType = SdfSpecTypeUnknown) const;
1838
1839 // Return the field definition for \p fieldName if \p fieldName is a
1840 // required field for \p specType subject to \p schema.
1841 static inline SdfSchema::FieldDefinition const *
1842 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1843 const TfToken &fieldName,
1844 SdfSpecType specType);
1845
1846 // Helper to list all fields on \p data at \p path subject to \p schema.
1847 static std::vector<TfToken>
1848 _ListFields(SdfSchemaBase const &schema,
1849 SdfAbstractData const &data, const SdfPath& path);
1850
1851 // Helper for HasField for \p path in \p data subject to \p schema.
1852 static inline bool
1853 _HasField(const SdfSchemaBase &schema,
1854 const SdfAbstractData &data,
1855 const SdfPath& path,
1856 const TfToken& fieldName,
1857 VtValue *value);
1858
1859 // Helper to get a field value for \p path in \p data subject to \p schema.
1860 static inline VtValue
1861 _GetField(const SdfSchemaBase &schema,
1862 const SdfAbstractData &data,
1863 const SdfPath& path,
1864 const TfToken& fieldName);
1865
1866 // Set a value.
1867 template <class T>
1868 void _SetValue(const TfToken& key, T value);
1869
1870 // Get a value.
1871 template <class T>
1872 T _GetValue(const TfToken& key) const;
1873
1874 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1875 _ReloadResult _Reload(bool force);
1876
1877 // Reads contents of asset specified by \p identifier with resolved
1878 // path \p resolvedPath into this layer.
1879 bool _Read(const std::string& identifier,
1880 const ArResolvedPath& resolvedPath,
1881 bool metadataOnly);
1882
1883 // Saves this layer if it is dirty or the layer doesn't already exist
1884 // on disk. If \p force is true, the layer will be written out
1885 // regardless of those conditions.
1886 bool _Save(bool force) const;
1887
1888 // A helper method used by Save and Export.
1889 // This method allows Save to specify the existing file format and Export
1890 // to use the format provided by the file extension in newFileName. If no
1891 // file format can be discovered from the file name, the existing file
1892 // format associated with the layer will be used in both cases. This allows
1893 // users to export and save to any file name, regardless of extension.
1894 bool _WriteToFile(const std::string& newFileName,
1895 const std::string& comment,
1896 SdfFileFormatConstPtr fileFormat,
1897 const FileFormatArguments& args) const;
1898
1899 // Swap contents of _data and data. This operation does not register
1900 // inverses or emit change notification.
1901 void _SwapData(SdfAbstractDataRefPtr &data);
1902
1903 // Set _data to \p newData and send coarse DidReplaceLayerContent
1904 // invalidation notice.
1905 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1906
1907 // Helper function which will process incoming data to this layer in a
1908 // generic way.
1909 // If \p processPropertyFields is false, this method will not
1910 // consider property spec fields. In some cases, this can avoid expensive
1911 // operations which would pull large amounts of data.
1912 template<typename DeleteSpecFunc, typename CreateSpecFunc,
1913 typename GetFieldValuesFunc, typename SetFieldFunc, typename ErrorFunc>
1914 void _ProcessIncomingData(const SdfAbstractDataPtr &newData,
1915 const SdfSchemaBase *newDataSchema,
1916 bool processPropertyFields,
1917 const DeleteSpecFunc &deleteSpecFunc,
1918 const CreateSpecFunc &createSpecFunc,
1919 const GetFieldValuesFunc &getFieldValuesFunc,
1920 const SetFieldFunc &setFieldFunc,
1921 const ErrorFunc &errorFunc) const;
1922
1923 // Set _data to match data, calling other primitive setter methods to
1924 // provide fine-grained inverses and notification. If \p data might adhere
1925 // to a different schema than this layer's, pass a pointer to it as \p
1926 // newDataSchema. In this case, check to see if fields from \p data are
1927 // known to this layer's schema, and if not, omit them and issue a TfError
1928 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1929 // known fields.
1930 void _SetData(const SdfAbstractDataPtr &newData,
1931 const SdfSchemaBase *newDataSchema=nullptr);
1932
1933 // Returns const handle to _data.
1934 SdfAbstractDataConstPtr _GetData() const;
1935
1936 // Returns a new SdfAbstractData object for this layer.
1937 SdfAbstractDataRefPtr _CreateData() const;
1938
1939 // Inverse primitive for setting a single field. The previous value for the
1940 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1941 // VtValue it points to will be moved-from after the function completes. If
1942 // \p oldValue is nullptr, the old field value will be retrieved
1943 // automatically.
1944 template <class T>
1945 void _PrimSetField(const SdfPath& path,
1946 const TfToken& fieldName,
1947 const T& value,
1948 VtValue *oldValue = nullptr,
1949 bool useDelegate = true);
1950
1951 // Inverse primitive for setting a single key in a dict-valued field. The
1952 // previous dictionary value for the field (*not* the individual entry) may
1953 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1954 // it points to will be moved-from after the function completes. If \p
1955 // oldValue is nullptr, the old field value will be retrieved automatically.
1956 template <class T>
1957 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1958 const TfToken& fieldName,
1959 const TfToken& keyPath,
1960 const T& value,
1961 VtValue *oldValue = nullptr,
1962 bool useDelegate = true);
1963
1964 // Primitive for appending a child to the list of children.
1965 template <class T>
1966 void _PrimPushChild(const SdfPath& parentPath,
1967 const TfToken& fieldName,
1968 const T& value,
1969 bool useDelegate = true);
1970 template <class T>
1971 void _PrimPopChild(const SdfPath& parentPath,
1972 const TfToken& fieldName,
1973 bool useDelegate = true);
1974
1975 // Move all the fields at all paths at or below \a oldPath to be
1976 // at a corresponding location at or below \a newPath. This does
1977 // not update the children fields of the parents of these paths.
1978 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1979
1980 // Inverse primitive for moving a spec.
1981 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1982 bool useDelegate = true);
1983
1984 // Create a new spec of type \p specType at \p path.
1985 // Returns true if spec was successfully created, false otherwise.
1986 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1987
1988 // Delete all the fields at or below the specified path. This does
1989 // not update the children field of the parent of \a path.
1990 bool _DeleteSpec(const SdfPath &path);
1991
1992 // Inverse primitive for deleting a spec.
1993 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1994 bool useDelegate = true);
1995
1996 // Inverse primitive for deleting a spec.
1997 void _PrimDeleteSpec(const SdfPath &path, bool inert,
1998 bool useDelegate = true);
1999
2000 // Inverse primitive for setting time samples.
2001 template <class T>
2002 void _PrimSetTimeSample(const SdfPath& path, double time,
2003 const T& value,
2004 bool useDelegate = true);
2005
2006 // Helper method for Traverse. Visits the children of \a path using the
2007 // specified \a ChildPolicy.
2008 template <typename ChildPolicy>
2009 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
2010
2011private:
2012 SdfLayerHandle _self;
2013
2014 // File format and arguments for this layer.
2015 SdfFileFormatConstPtr _fileFormat;
2016 FileFormatArguments _fileFormatArgs;
2017
2018 // Cached reference to the _fileFormat's schema -- we need access to this to
2019 // be as fast as possible since we look at it on every SetField(), for
2020 // example.
2021 const SdfSchemaBase &_schema;
2022
2023 // Registry of Sdf Identities
2024 mutable Sdf_IdentityRegistry _idRegistry;
2025
2026 // The underlying SdfData which stores all the data in the layer.
2027 SdfAbstractDataRefPtr _data;
2028
2029 // The state delegate for this layer.
2030 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
2031
2032 // Dispatcher used in layer initialization, letting waiters participate in
2033 // loading instead of just busy-waiting.
2034 WorkDispatcher _initDispatcher;
2035
2036 // Atomic variable protecting layer initialization -- the interval between
2037 // adding a layer to the layer registry and finishing the process of
2038 // initializing its contents, at which point we can truly publish the layer
2039 // for consumption by concurrent threads. We add the layer to the registry
2040 // before initialization completes so that other threads can discover and
2041 // wait for it to finish initializing.
2042 std::atomic<bool> _initializationComplete;
2043
2044 // This is an optional<bool> that is only set once initialization
2045 // is complete, before _initializationComplete is set.
2046 std::optional<bool> _initializationWasSuccessful;
2047
2048 // remembers the last 'IsDirty' state.
2049 mutable bool _lastDirtyState;
2050
2051 // Asset information for this layer.
2052 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
2053
2054 // Modification timestamp of the backing file asset when last read.
2055 mutable VtValue _assetModificationTime;
2056
2057 // All external asset dependencies, with their modification timestamps, of
2058 // the layer when last read.
2059 mutable VtDictionary _externalAssetModificationTimes;
2060
2061 // Mutable revision number for cache invalidation.
2062 mutable size_t _mutedLayersRevisionCache;
2063
2064 // Cache of whether or not this layer is muted. Only valid if
2065 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2066 mutable bool _isMutedCache;
2067
2068 // Layer permission bits.
2069 bool _permissionToEdit;
2070 bool _permissionToSave;
2071
2072 // Whether layer edits are validated.
2073 bool _validateAuthoring;
2074
2075 // Layer hints as of the most recent save operation.
2076 mutable SdfLayerHints _hints;
2077
2078 // Allow access to _ValidateAuthoring() and _IsInert().
2079 friend class SdfSpec;
2080 friend class SdfPropertySpec;
2081 friend class SdfAttributeSpec;
2082
2083 friend class Sdf_ChangeManager;
2084
2085 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2086 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2087
2088 // Give the file format access to our data. Limit breaking encapsulation
2089 // to the base SdFileFormat class so we don't have to friend every
2090 // implementation here.
2091 friend class SdfFileFormat;
2092
2093 // Give layer state delegates access to our data as well as to
2094 // the various _Prim functions.
2095 friend class SdfLayerStateDelegateBase;
2096};
2097
2098PXR_NAMESPACE_CLOSE_SCOPE
2099
2100#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:78
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:274
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:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152
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:68
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
Definition: types.h:274