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
44struct Sdf_AssetInfo;
45
81 : public TfRefBase
82 , public TfWeakBase
83{
84public:
86 SDF_API
87 virtual ~SdfLayer();
88
90 SdfLayer(const SdfLayer&) = delete;
91 SdfLayer& operator=(const SdfLayer&) = delete;
92
96
99 SDF_API const SdfSchemaBase& GetSchema() const;
100
102 SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
103
106 typedef std::map<std::string, std::string> FileFormatArguments;
107
111
117 SDF_API
118 static SdfLayerRefPtr CreateNew(const std::string &identifier,
119 const FileFormatArguments &args =
121
128 SDF_API
129 static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
130 const std::string &identifier,
131 const FileFormatArguments &args =
133
142 SDF_API
143 static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
144 const std::string &identifier,
145 const FileFormatArguments &args =
147
154 SDF_API
155 static SdfLayerHandle Find(
156 const std::string &identifier,
158
169 SDF_API
170 static SdfLayerHandle FindRelativeToLayer(
171 const SdfLayerHandle &anchor,
172 const std::string &identifier,
174
181 SDF_API
183 const std::string &identifier,
185
196 SDF_API
198 const SdfLayerHandle &anchor,
199 const std::string &identifier,
201
215 SDF_API
217 const std::string &layerPath,
218 bool metadataOnly = false,
219 const std::string& tag = std::string());
220
222 SDF_API
223 SdfDataRefPtr GetMetadata() const;
224
228 SDF_API
230
232 SDF_API
233 static SdfLayerHandleSet GetLoadedLayers();
234
236 SDF_API
237 bool IsEmpty() const;
238
246 SDF_API
247 bool StreamsData() const;
248
254 SDF_API
255 bool IsDetached() const;
256
259 SDF_API
260 void TransferContent(const SdfLayerHandle& layer);
261
276 SDF_API
278 const std::string& tag = std::string(),
280
282 SDF_API
284 const std::string &tag, const SdfFileFormatConstPtr &format,
286
288 SDF_API
289 bool IsAnonymous() const;
290
293 SDF_API
294 static bool IsAnonymousLayerIdentifier(const std::string& identifier);
295
298 SDF_API
300 const std::string& identifier);
301
305
310 SDF_API
311 bool Save(bool force = false) const;
312
325 SDF_API
326 bool Export(const std::string& filename,
327 const std::string& comment = std::string(),
328 const FileFormatArguments& args = FileFormatArguments()) const;
329
334 SDF_API
335 bool ExportToString(std::string* result) const;
336
340 SDF_API
341 bool ImportFromString(const std::string &string);
342
350 SDF_API
351 void Clear();
352
374 SDF_API
375 bool Reload(bool force = false);
376
383 SDF_API
384 static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
385 bool force = false);
386
392 SDF_API
393 bool Import(const std::string &layerPath);
394
398
401 SDF_API
402 std::set<std::string> GetExternalReferences() const;
403
406 SDF_API
408 const std::string &oldAssetPath,
409 const std::string &newAssetPath=std::string());
410
418 SDF_API
419 std::set<std::string> GetCompositionAssetDependencies() const;
420
430 SDF_API
432 const std::string &oldAssetPath,
433 const std::string &newAssetPath=std::string());
434
443 SDF_API
444 std::set<std::string> GetExternalAssetDependencies() const;
445
465
468 SDF_API
469 static bool SplitIdentifier(
470 const std::string& identifier,
471 std::string* layerPath,
472 FileFormatArguments* arguments);
473
475 SDF_API
476 static std::string CreateIdentifier(
477 const std::string& layerPath,
478 const FileFormatArguments& arguments);
479
481 SDF_API
482 const std::string& GetIdentifier() const;
483
487 SDF_API
488 void SetIdentifier(const std::string& identifier);
489
494 SDF_API
496
500 SDF_API
501 std::string GetDisplayName() const;
502
505 SDF_API
507
510 SDF_API
511 const std::string& GetRealPath() const;
512
517 SDF_API
518 std::string GetFileExtension() const;
519
525 SDF_API
526 const std::string& GetVersion() const;
527
532 SDF_API
533 const std::string& GetRepositoryPath() const;
534
536 SDF_API
537 const std::string& GetAssetName() const;
538
541 SDF_API
542 const VtValue& GetAssetInfo() const;
543
559 SDF_API
560 std::string ComputeAbsolutePath(const std::string& assetPath) const;
561
563
574
577 SDF_API
578 SdfSpecType GetSpecType(const SdfPath& path) const;
579
581 SDF_API
582 bool HasSpec(const SdfPath& path) const;
583
585 SDF_API
586 std::vector<TfToken> ListFields(const SdfPath& path) const;
587
590 SDF_API
591 bool HasField(const SdfPath& path, const TfToken& fieldName,
592 VtValue *value=NULL) const;
593 SDF_API
594 bool HasField(const SdfPath& path, const TfToken& fieldName,
595 SdfAbstractDataValue *value) const;
596
600 template <class T>
601 bool HasField(const SdfPath& path, const TfToken &name,
602 T* value) const
603 {
604 if (!value) {
605 return HasField(path, name, static_cast<VtValue *>(NULL));
606 }
607
608 SdfAbstractDataTypedValue<T> outValue(value);
609 const bool hasValue = HasField(
610 path, name, static_cast<SdfAbstractDataValue *>(&outValue));
611
612 if (std::is_same<T, SdfValueBlock>::value) {
613 return hasValue && outValue.isValueBlock;
614 }
615
616 return hasValue && (!outValue.isValueBlock);
617 }
618
621 std::type_info const &GetFieldTypeid(
622 const SdfPath &path, const TfToken &name) const {
623 return _data->GetTypeid(path, name);
624 }
625
629 SDF_API
630 bool HasFieldDictKey(const SdfPath& path,
631 const TfToken &fieldName,
632 const TfToken &keyPath,
633 VtValue *value=NULL) const;
634 SDF_API
635 bool HasFieldDictKey(const SdfPath& path,
636 const TfToken &fieldName,
637 const TfToken &keyPath,
638 SdfAbstractDataValue *value) const;
639
644 template <class T>
645 bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
646 const TfToken &keyPath, T* value) const
647 {
648 if (!value) {
649 return HasFieldDictKey(path, name, keyPath,
650 static_cast<VtValue *>(NULL));
651 }
652
653 SdfAbstractDataTypedValue<T> outValue(value);
654 return HasFieldDictKey(path, name, keyPath,
655 static_cast<SdfAbstractDataValue *>(&outValue));
656 }
657
658
661 SDF_API
663 const TfToken& fieldName) const;
664
667 template <class T>
668 inline T GetFieldAs(const SdfPath& path,
669 const TfToken& fieldName, const T& defaultValue = T()) const
670 {
671 return _data->GetAs<T>(path, fieldName, defaultValue);
672 }
673
677 SDF_API
679 const TfToken& fieldName,
680 const TfToken& keyPath) const;
681
683 SDF_API
684 void SetField(const SdfPath& path, const TfToken& fieldName,
685 const VtValue& value);
686 SDF_API
687 void SetField(const SdfPath& path, const TfToken& fieldName,
688 const SdfAbstractDataConstValue& value);
689
691 template <class T>
692 void SetField(const SdfPath& path, const TfToken& fieldName,
693 const T& val)
694 {
695 // Ideally, this would make use of the SdfAbstractDataConstValue
696 // API to avoid unnecessarily copying the value into a VtValue.
697 // However, Sdf needs to create a VtValue for change processing.
698 // If the underlying SdAbstractData implementation also needs a
699 // VtValue, using the SdfAbstractDataConstValue API would cause
700 // another copy to be made. So, it's more efficient to just create
701 // the VtValue once here and push that along.
702 SetField(path, fieldName, VtValue(val));
703 }
704
707 SDF_API
709 const TfToken& fieldName,
710 const TfToken& keyPath,
711 const VtValue& value);
712 SDF_API
713 void SetFieldDictValueByKey(const SdfPath& path,
714 const TfToken& fieldName,
715 const TfToken& keyPath,
716 const SdfAbstractDataConstValue& value);
717
720 template <class T>
722 const TfToken& fieldName,
723 const TfToken& keyPath,
724 const T& val)
725 {
726 // Ideally, this would make use of the SdfAbstractDataConstValue
727 // API to avoid unnecessarily copying the value into a VtValue.
728 // However, Sdf needs to create a VtValue for change processing.
729 // If the underlying SdAbstractData implementation also needs
730 // VtValue, using the SdfAbstractDataConstValue API would cause
731 // another copy to be made. So, it's more efficient to just create
732 // the VtValue once here and push that along.
733 SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
734 }
735
737 SDF_API
738 void EraseField(const SdfPath& path, const TfToken& fieldName);
739
743 SDF_API
745 const TfToken& fieldName,
746 const TfToken& keyPath);
747
750
754 typedef std::function<void(const SdfPath&)> TraversalFunction;
755
756 // Traverse will perform a traversal of the scene description hierarchy
757 // rooted at \a path, calling \a func on each spec that it finds.
758 SDF_API
759 void Traverse(const SdfPath& path, const TraversalFunction& func);
760
762
765
769 SDF_API
771
773 SDF_API
774 void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
775
778 SDF_API
780
783 SDF_API
785
793 SDF_API
795
798 SDF_API
800
803 SDF_API
805
808 SDF_API
810
814 SDF_API
815 std::string GetComment() const;
816
818 SDF_API
819 void SetComment(const std::string &comment);
820
826 SDF_API
828
838 SDF_API
840
847 SDF_API
848 void SetDefaultPrim(const TfToken &name);
849
852 SDF_API
854
857 SDF_API
859
863 SDF_API
864 std::string GetDocumentation() const;
865
867 SDF_API
868 void SetDocumentation(const std::string &documentation);
869
877 SDF_API
878 double GetStartTimeCode() const;
879
881 SDF_API
882 void SetStartTimeCode(double startTimecode);
883
885 SDF_API
886 bool HasStartTimeCode() const;
887
889 SDF_API
891
898 SDF_API
899 double GetEndTimeCode() const;
900
902 SDF_API
903 void SetEndTimeCode(double endTimeCode);
904
906 SDF_API
907 bool HasEndTimeCode() const;
908
910 SDF_API
912
927 SDF_API
928 double GetTimeCodesPerSecond() const;
929
931 SDF_API
932 void SetTimeCodesPerSecond(double timeCodesPerSecond);
933
935 SDF_API
937
939 SDF_API
941
951 SDF_API
952 double GetFramesPerSecond() const;
953
955 SDF_API
956 void SetFramesPerSecond(double framesPerSecond);
957
959 SDF_API
960 bool HasFramesPerSecond() const;
961
963 SDF_API
965
967 SDF_API
968 int GetFramePrecision() const;
969
971 SDF_API
972 void SetFramePrecision(int framePrecision);
973
975 SDF_API
976 bool HasFramePrecision() const;
977
979 SDF_API
981
983 SDF_API
984 std::string GetOwner() const;
985
987 SDF_API
988 void SetOwner(const std::string& owner);
989
991 SDF_API
992 bool HasOwner() const;
993
995 SDF_API
997
1000 SDF_API
1001 std::string GetSessionOwner() const;
1002
1005 SDF_API
1006 void SetSessionOwner(const std::string& owner);
1007
1009 SDF_API
1010 bool HasSessionOwner() const;
1011
1012 // Clear the session owner opinion.
1013 SDF_API
1014 void ClearSessionOwner();
1015
1017 SDF_API
1019
1021 SDF_API
1023
1029 SDF_API
1031
1033 SDF_API
1035
1037 SDF_API
1039
1041 SDF_API
1043
1046 SDF_API
1048
1050 SDF_API
1051 void SetExpressionVariables(const VtDictionary& expressionVars);
1052
1054 SDF_API
1056
1058 SDF_API
1060
1064
1065 // Type for root prims view.
1067
1069 SDF_API
1071
1076 SDF_API
1077 void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1078
1084 SDF_API
1085 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1086
1088 SDF_API
1089 void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1090
1093 SDF_API
1095
1108 SDF_API
1109 void RemovePrimIfInert(SdfPrimSpecHandle prim);
1110
1117 SDF_API
1118 void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1119
1125 SDF_API
1127
1132 SDF_API
1134
1143 SDF_API
1144 void SetRootPrimOrder(const std::vector<TfToken>& names);
1145
1148 SDF_API
1149 void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1150
1152 SDF_API
1154
1156 SDF_API
1158
1164 SDF_API
1165 void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1166
1170
1183 SDF_API
1185
1187 SDF_API
1188 void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1189
1191 SDF_API
1192 size_t GetNumSubLayerPaths() const;
1193
1197 SDF_API
1198 void InsertSubLayerPath(const std::string& path, int index = -1);
1199
1201 SDF_API
1202 void RemoveSubLayerPath(int index);
1203
1205 SDF_API
1206 SdfLayerOffsetVector GetSubLayerOffsets() const;
1207
1209 SDF_API
1211
1213 SDF_API
1214 void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1215
1219
1228 SDF_API
1230
1233 SDF_API
1234 void SetRelocates(const SdfRelocates& relocates);
1235
1240 SDF_API
1241 bool HasRelocates() const;
1242
1244 SDF_API
1246
1248
1269
1286 {
1287 public:
1291
1294 {
1295 _includeAll = true;
1296 _include.clear();
1297 return *this;
1298 }
1299
1302 SDF_API
1303 DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1304
1307 SDF_API
1308 DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1309
1310 bool IncludedAll() const { return _includeAll; }
1311 const std::vector<std::string>& GetIncluded() const { return _include; }
1312 const std::vector<std::string>& GetExcluded() const { return _exclude; }
1313
1321 SDF_API
1322 bool IsIncluded(const std::string& identifier) const;
1323
1324 private:
1325 friend class SdfLayer;
1326
1327 std::vector<std::string> _include;
1328 std::vector<std::string> _exclude;
1329 bool _includeAll = false;
1330 };
1331
1354 SDF_API
1356
1358 SDF_API
1360
1364 SDF_API
1365 static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1366
1368
1371
1373 SDF_API
1374 static std::set<std::string> GetMutedLayers();
1375
1377 SDF_API
1378 bool IsMuted() const;
1379
1381 SDF_API
1382 static bool IsMuted(const std::string &path);
1383
1386 SDF_API
1387 void SetMuted(bool muted);
1388
1390 SDF_API
1391 static void AddToMutedLayers(const std::string &mutedPath);
1392
1394 SDF_API
1395 static void RemoveFromMutedLayers(const std::string &mutedPath);
1396
1400
1409 SDF_API
1410 SdfPrimSpecHandle GetPseudoRoot() const;
1411
1418 SDF_API
1419 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1420
1426 SDF_API
1427 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1428
1434 SDF_API
1435 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1436
1442 SDF_API
1443 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1444
1450 SDF_API
1451 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1452
1456
1460 SDF_API
1461 bool PermissionToEdit() const;
1462
1465 SDF_API
1466 bool PermissionToSave() const;
1467
1469 SDF_API
1470 void SetPermissionToEdit(bool allow);
1471
1473 SDF_API
1474 void SetPermissionToSave(bool allow);
1475
1479
1503 SDF_API
1506 SdfNamespaceEditDetailVector* details = NULL) const;
1507
1511 SDF_API
1513
1517
1520 SDF_API
1521 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1522
1526 SDF_API
1527 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1528
1531 SDF_API
1532 bool IsDirty() const;
1533
1535
1538 SDF_API
1539 std::set<double> ListAllTimeSamples() const;
1540
1541 SDF_API
1542 std::set<double>
1543 ListTimeSamplesForPath(const SdfPath& path) const;
1544
1545 SDF_API
1546 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1547
1548 SDF_API
1549 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1550
1551 SDF_API
1552 bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1553 double time,
1554 double* tLower, double* tUpper);
1555
1556 SDF_API
1557 bool QueryTimeSample(const SdfPath& path, double time,
1558 VtValue *value=NULL) const;
1559 SDF_API
1560 bool QueryTimeSample(const SdfPath& path, double time,
1561 SdfAbstractDataValue *value) const;
1562
1563 template <class T>
1564 bool QueryTimeSample(const SdfPath& path, double time,
1565 T* data) const
1566 {
1567 if (!data) {
1568 return QueryTimeSample(path, time);
1569 }
1570
1571 SdfAbstractDataTypedValue<T> outValue(data);
1572 const bool hasValue = QueryTimeSample(
1573 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1574
1575 if (std::is_same<T, SdfValueBlock>::value) {
1576 return hasValue && outValue.isValueBlock;
1577 }
1578
1579 return hasValue && (!outValue.isValueBlock);
1580 }
1581
1582 SDF_API
1583 void SetTimeSample(const SdfPath& path, double time,
1584 const VtValue & value);
1585 SDF_API
1586 void SetTimeSample(const SdfPath& path, double time,
1587 const SdfAbstractDataConstValue& value);
1588
1589 template <class T>
1590 void SetTimeSample(const SdfPath& path, double time,
1591 const T& value)
1592 {
1593 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1594 const SdfAbstractDataConstValue& untypedInValue = inValue;
1595 return SetTimeSample(path, time, untypedInValue);
1596 }
1597
1598 SDF_API
1599 void EraseTimeSample(const SdfPath& path, double time);
1600
1602
1603 // Debugging
1604 // @{
1605
1606 SDF_API
1607 static void DumpLayerInfo();
1608
1609 // Write this layer's SdfData to a file in a simple generic format.
1610 SDF_API
1611 bool WriteDataFile(const std::string &filename);
1612
1613 // @}
1614
1615protected:
1616 // Private constructor -- use New(), FindOrCreate(), etc.
1617 // Precondition: _layerRegistryMutex must be locked.
1618 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1619 const std::string &identifier,
1620 const std::string &realPath = std::string(),
1621 const ArAssetInfo& assetInfo = ArAssetInfo(),
1623 bool validateAuthoring = false);
1624
1625private:
1626 // Create a new layer.
1627 // Precondition: _layerRegistryMutex must be locked.
1628 static SdfLayerRefPtr _CreateNew(
1629 SdfFileFormatConstPtr fileFormat,
1630 const std::string& identifier,
1631 const FileFormatArguments& args,
1632 bool saveLayer = true);
1633
1634 static SdfLayerRefPtr _CreateNewWithFormat(
1635 const SdfFileFormatConstPtr &fileFormat,
1636 const std::string& identifier,
1637 const std::string& realPath,
1638 const ArAssetInfo& assetInfo = ArAssetInfo(),
1640
1641 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1642 const SdfFileFormatConstPtr &fileFormat,
1643 const std::string& tag,
1644 const FileFormatArguments& args);
1645
1646 // Finish initializing this layer (which may have succeeded or not)
1647 // and publish the results to other threads by unlocking the mutex.
1648 // Sets _initializationWasSuccessful.
1649 void _FinishInitialization(bool success);
1650
1651 // Layers retrieved from the layer registry may still be in the
1652 // process of having their contents initialized. Other threads
1653 // retrieving layers from the registry must wait until initialization
1654 // is complete, using this method.
1655 // Returns _initializationWasSuccessful.
1656 //
1657 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1658 // ensure that it is not deleted out from under them, in
1659 // case initialization fails. (This method cannot acquire the
1660 // reference itself internally without being susceptible to a race.)
1661 bool _WaitForInitializationAndCheckIfSuccessful();
1662
1663 // Returns whether or not this layer should post change
1664 // notification. This simply returns (!_GetIsLoading())
1665 bool _ShouldNotify() const;
1666
1667 // This function keeps track of the last state of IsDirty() before
1668 // updating it. It returns false if the last saved dirty state is the
1669 // same than the current state. It returns true if the state differs and
1670 // will update the 'last dirty state' to the current state. So, after
1671 // returning true, it would return false for subsequent calls until the
1672 // IsDirty() state would change again...
1673 bool _UpdateLastDirtinessState() const;
1674
1675 // Returns a handle to the spec at the given path if it exists and matches
1676 // type T.
1677 template <class T>
1678 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1679
1680 // Returns true if a spec can be retrieved at the given path, false
1681 // otherwise. This function will return the canonicalized path to the
1682 // spec as well as the spec type.
1683 bool _CanGetSpecAtPath(const SdfPath& path,
1684 SdfPath* canonicalPath, SdfSpecType* specType) const;
1685
1689 void _InitializeFromIdentifier(
1690 const std::string &identifier,
1691 const std::string &realPath = std::string(),
1692 const std::string &fileVersion = std::string(),
1693 const ArAssetInfo& assetInfo = ArAssetInfo());
1694
1695 // Helper for computing the necessary information to lookup a layer
1696 // in the registry or open the layer.
1697 struct _FindOrOpenLayerInfo;
1698 static bool _ComputeInfoToFindOrOpenLayer(
1699 const std::string& identifier,
1701 _FindOrOpenLayerInfo* info,
1702 bool computeAssetInfo = false);
1703
1704 // Open a layer, adding an entry to the registry and releasing
1705 // the registry lock.
1706 // Precondition: _layerRegistryMutex must be locked.
1707 template <class Lock>
1708 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1709 Lock &lock,
1710 const _FindOrOpenLayerInfo& info,
1711 bool metadataOnly);
1712
1713 // Helper function for finding a layer with \p identifier and \p args.
1714 // \p lock must be unlocked initially and will be locked by this
1715 // function when needed. See docs for \p retryAsWriter argument on
1716 // _TryToFindLayer for details on the final state of the lock when
1717 // this function returns.
1718 template <class ScopedLock>
1719 static SdfLayerRefPtr
1720 _Find(const std::string &identifier,
1721 const FileFormatArguments &args,
1722 ScopedLock &lock, bool retryAsWriter);
1723
1724 // Helper function to try to find the layer with \p identifier and
1725 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1726 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1727 // released upon return. Otherwise the lock is released upon return if a
1728 // layer is found successfully. If no layer is found then the lock is
1729 // upgraded to a writer lock upon return. Note that this upgrade may not be
1730 // atomic, but this function ensures that if upon return there does not
1731 // exist a matching layer in the registry.
1732 template <class ScopedLock>
1733 static SdfLayerRefPtr
1734 _TryToFindLayer(const std::string &identifier,
1735 const ArResolvedPath &resolvedPath,
1736 ScopedLock &lock, bool retryAsWriter);
1737
1745 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1746 bool requiredFieldOnlyPropertiesAreInert = false) const;
1747
1751 bool _IsInertSubtree(const SdfPath &path) const;
1752
1758 void _RemoveIfInert(const SdfSpec& spec);
1759
1764 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1765
1768 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1769
1771 bool _ValidateAuthoring() const { return _validateAuthoring; }
1772
1774 std::string _GetMutedPath() const;
1775
1776 // If old and new asset path is given, rename all external prim
1777 // composition dependency referring to the old path.
1778 void _UpdatePrimCompositionDependencyPaths(
1779 const SdfPrimSpecHandle &parent,
1780 const std::string &oldLayerPath,
1781 const std::string &newLayerPath);
1782
1783 // Set the clean state to the current state.
1784 void _MarkCurrentStateAsClean() const;
1785
1786 // Return the field definition for \p fieldName if \p fieldName is a
1787 // required field for the spec type identified by \p path.
1788 inline SdfSchema::FieldDefinition const *
1789 _GetRequiredFieldDef(const SdfPath &path,
1790 const TfToken &fieldName,
1791 SdfSpecType specType = SdfSpecTypeUnknown) const;
1792
1793 // Return the field definition for \p fieldName if \p fieldName is a
1794 // required field for \p specType subject to \p schema.
1795 static inline SdfSchema::FieldDefinition const *
1796 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1797 const TfToken &fieldName,
1798 SdfSpecType specType);
1799
1800 // Helper to list all fields on \p data at \p path subject to \p schema.
1801 static std::vector<TfToken>
1802 _ListFields(SdfSchemaBase const &schema,
1803 SdfAbstractData const &data, const SdfPath& path);
1804
1805 // Helper for HasField for \p path in \p data subject to \p schema.
1806 static inline bool
1807 _HasField(const SdfSchemaBase &schema,
1808 const SdfAbstractData &data,
1809 const SdfPath& path,
1810 const TfToken& fieldName,
1811 VtValue *value);
1812
1813 // Helper to get a field value for \p path in \p data subject to \p schema.
1814 static inline VtValue
1815 _GetField(const SdfSchemaBase &schema,
1816 const SdfAbstractData &data,
1817 const SdfPath& path,
1818 const TfToken& fieldName);
1819
1820 // Set a value.
1821 template <class T>
1822 void _SetValue(const TfToken& key, T value);
1823
1824 // Get a value.
1825 template <class T>
1826 T _GetValue(const TfToken& key) const;
1827
1828 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1829 _ReloadResult _Reload(bool force);
1830
1831 // Reads contents of asset specified by \p identifier with resolved
1832 // path \p resolvedPath into this layer.
1833 bool _Read(const std::string& identifier,
1834 const ArResolvedPath& resolvedPath,
1835 bool metadataOnly);
1836
1837 // Saves this layer if it is dirty or the layer doesn't already exist
1838 // on disk. If \p force is true, the layer will be written out
1839 // regardless of those conditions.
1840 bool _Save(bool force) const;
1841
1842 // A helper method used by Save and Export.
1843 // This method allows Save to specify the existing file format and Export
1844 // to use the format provided by the file extension in newFileName. If no
1845 // file format can be discovered from the file name, the existing file
1846 // format associated with the layer will be used in both cases. This allows
1847 // users to export and save to any file name, regardless of extension.
1848 bool _WriteToFile(const std::string& newFileName,
1849 const std::string& comment,
1850 SdfFileFormatConstPtr fileFormat,
1851 const FileFormatArguments& args) const;
1852
1853 // Swap contents of _data and data. This operation does not register
1854 // inverses or emit change notification.
1855 void _SwapData(SdfAbstractDataRefPtr &data);
1856
1857 // Set _data to \p newData and send coarse DidReplaceLayerContent
1858 // invalidation notice.
1859 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1860
1861 // Set _data to match data, calling other primitive setter methods to
1862 // provide fine-grained inverses and notification. If \p data might adhere
1863 // to a different schema than this layer's, pass a pointer to it as \p
1864 // newDataSchema. In this case, check to see if fields from \p data are
1865 // known to this layer's schema, and if not, omit them and issue a TfError
1866 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1867 // known fields.
1868 void _SetData(const SdfAbstractDataPtr &newData,
1869 const SdfSchemaBase *newDataSchema=nullptr);
1870
1871 // Returns const handle to _data.
1872 SdfAbstractDataConstPtr _GetData() const;
1873
1874 // Returns a new SdfAbstractData object for this layer.
1875 SdfAbstractDataRefPtr _CreateData() const;
1876
1877 // Inverse primitive for setting a single field. The previous value for the
1878 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1879 // VtValue it points to will be moved-from after the function completes. If
1880 // \p oldValue is nullptr, the old field value will be retrieved
1881 // automatically.
1882 template <class T>
1883 void _PrimSetField(const SdfPath& path,
1884 const TfToken& fieldName,
1885 const T& value,
1886 VtValue *oldValue = nullptr,
1887 bool useDelegate = true);
1888
1889 // Inverse primitive for setting a single key in a dict-valued field. The
1890 // previous dictionary value for the field (*not* the individual entry) may
1891 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1892 // it points to will be moved-from after the function completes. If \p
1893 // oldValue is nullptr, the old field value will be retrieved automatically.
1894 template <class T>
1895 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1896 const TfToken& fieldName,
1897 const TfToken& keyPath,
1898 const T& value,
1899 VtValue *oldValue = nullptr,
1900 bool useDelegate = true);
1901
1902 // Primitive for appending a child to the list of children.
1903 template <class T>
1904 void _PrimPushChild(const SdfPath& parentPath,
1905 const TfToken& fieldName,
1906 const T& value,
1907 bool useDelegate = true);
1908 template <class T>
1909 void _PrimPopChild(const SdfPath& parentPath,
1910 const TfToken& fieldName,
1911 bool useDelegate = true);
1912
1913 // Move all the fields at all paths at or below \a oldPath to be
1914 // at a corresponding location at or below \a newPath. This does
1915 // not update the children fields of the parents of these paths.
1916 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1917
1918 // Inverse primitive for moving a spec.
1919 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1920 bool useDelegate = true);
1921
1922 // Create a new spec of type \p specType at \p path.
1923 // Returns true if spec was successfully created, false otherwise.
1924 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1925
1926 // Delete all the fields at or below the specified path. This does
1927 // not update the children field of the parent of \a path.
1928 bool _DeleteSpec(const SdfPath &path);
1929
1930 // Inverse primitive for deleting a spec.
1931 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1932 bool useDelegate = true);
1933
1934 // Inverse primitive for deleting a spec.
1935 void _PrimDeleteSpec(const SdfPath &path, bool inert,
1936 bool useDelegate = true);
1937
1938 // Inverse primitive for setting time samples.
1939 template <class T>
1940 void _PrimSetTimeSample(const SdfPath& path, double time,
1941 const T& value,
1942 bool useDelegate = true);
1943
1944 // Helper method for Traverse. Visits the children of \a path using the
1945 // specified \a ChildPolicy.
1946 template <typename ChildPolicy>
1947 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1948
1949private:
1950 SdfLayerHandle _self;
1951
1952 // File format and arguments for this layer.
1953 SdfFileFormatConstPtr _fileFormat;
1954 FileFormatArguments _fileFormatArgs;
1955
1956 // Cached reference to the _fileFormat's schema -- we need access to this to
1957 // be as fast as possible since we look at it on every SetField(), for
1958 // example.
1959 const SdfSchemaBase &_schema;
1960
1961 // Registry of Sdf Identities
1962 mutable Sdf_IdentityRegistry _idRegistry;
1963
1964 // The underlying SdfData which stores all the data in the layer.
1965 SdfAbstractDataRefPtr _data;
1966
1967 // The state delegate for this layer.
1968 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1969
1970 // Dispatcher used in layer initialization, letting waiters participate in
1971 // loading instead of just busy-waiting.
1972 WorkDispatcher _initDispatcher;
1973
1974 // Atomic variable protecting layer initialization -- the interval between
1975 // adding a layer to the layer registry and finishing the process of
1976 // initializing its contents, at which point we can truly publish the layer
1977 // for consumption by concurrent threads. We add the layer to the registry
1978 // before initialization completes so that other threads can discover and
1979 // wait for it to finish initializing.
1980 std::atomic<bool> _initializationComplete;
1981
1982 // This is an optional<bool> that is only set once initialization
1983 // is complete, before _initializationComplete is set.
1984 std::optional<bool> _initializationWasSuccessful;
1985
1986 // remembers the last 'IsDirty' state.
1987 mutable bool _lastDirtyState;
1988
1989 // Asset information for this layer.
1990 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1991
1992 // Modification timestamp of the backing file asset when last read.
1993 mutable VtValue _assetModificationTime;
1994
1995 // All external asset dependencies, with their modification timestamps, of
1996 // the layer when last read.
1997 mutable VtDictionary _externalAssetModificationTimes;
1998
1999 // Mutable revision number for cache invalidation.
2000 mutable size_t _mutedLayersRevisionCache;
2001
2002 // Cache of whether or not this layer is muted. Only valid if
2003 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2004 mutable bool _isMutedCache;
2005
2006 // Layer permission bits.
2007 bool _permissionToEdit;
2008 bool _permissionToSave;
2009
2010 // Whether layer edits are validated.
2011 bool _validateAuthoring;
2012
2013 // Layer hints as of the most recent save operation.
2014 mutable SdfLayerHints _hints;
2015
2016 // Allow access to _ValidateAuthoring() and _IsInert().
2017 friend class SdfSpec;
2018 friend class SdfPropertySpec;
2019 friend class SdfAttributeSpec;
2020
2021 friend class Sdf_ChangeManager;
2022
2023 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2024 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2025
2026 // Give the file format access to our data. Limit breaking encapsulation
2027 // to the base SdFileFormat class so we don't have to friend every
2028 // implementation here.
2029 friend class SdfFileFormat;
2030
2031 // Give layer state delegates access to our data as well as to
2032 // the various _Prim functions.
2033 friend class SdfLayerStateDelegateBase;
2034};
2035
2036PXR_NAMESPACE_CLOSE_SCOPE
2037
2038#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:545
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:503
Interface for scene description data storage.
Definition: abstractData.h:57
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:450
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:399
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:40
A description of an arbitrarily complex namespace edit.
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:1286
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1293
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:83
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:601
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:106
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:721
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.
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:621
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.
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.
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:668
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:692
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.
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:645
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:754
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:43
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:147
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:66
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