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