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
480 SDF_API
481 static std::pair<std::string, std::string> SplitIdentifier(
482 const std::string& identifier);
483
485 SDF_API
486 static std::string CreateIdentifier(
487 const std::string& layerPath,
488 const FileFormatArguments& arguments);
489
491 SDF_API
492 const std::string& GetIdentifier() const;
493
497 SDF_API
498 void SetIdentifier(const std::string& identifier);
499
504 SDF_API
506
510 SDF_API
511 std::string GetDisplayName() const;
512
515 SDF_API
517
520 SDF_API
521 const std::string& GetRealPath() const;
522
527 SDF_API
528 std::string GetFileExtension() const;
529
535 SDF_API
536 const std::string& GetVersion() const;
537
542 SDF_API
543 const std::string& GetRepositoryPath() const;
544
546 SDF_API
547 const std::string& GetAssetName() const;
548
551 SDF_API
552 const VtValue& GetAssetInfo() const;
553
569 SDF_API
570 std::string ComputeAbsolutePath(const std::string& assetPath) const;
571
573
584
587 SDF_API
588 SdfSpecType GetSpecType(const SdfPath& path) const;
589
591 SDF_API
592 bool HasSpec(const SdfPath& path) const;
593
595 SDF_API
596 std::vector<TfToken> ListFields(const SdfPath& path) const;
597
600 SDF_API
601 bool HasField(const SdfPath& path, const TfToken& fieldName,
602 VtValue *value=NULL) const;
603 SDF_API
604 bool HasField(const SdfPath& path, const TfToken& fieldName,
605 SdfAbstractDataValue *value) const;
606
610 template <class T>
611 bool HasField(const SdfPath& path, const TfToken &name,
612 T* value) const
613 {
614 if (!value) {
615 return HasField(path, name, static_cast<VtValue *>(NULL));
616 }
617
618 SdfAbstractDataTypedValue<T> outValue(value);
619 const bool hasValue = HasField(
620 path, name, static_cast<SdfAbstractDataValue *>(&outValue));
621
622 if (std::is_same<T, SdfValueBlock>::value) {
623 return hasValue && outValue.isValueBlock;
624 }
625
626 return hasValue && (!outValue.isValueBlock);
627 }
628
631 std::type_info const &GetFieldTypeid(
632 const SdfPath &path, const TfToken &name) const {
633 return _data->GetTypeid(path, name);
634 }
635
639 SDF_API
640 bool HasFieldDictKey(const SdfPath& path,
641 const TfToken &fieldName,
642 const TfToken &keyPath,
643 VtValue *value=NULL) const;
644 SDF_API
645 bool HasFieldDictKey(const SdfPath& path,
646 const TfToken &fieldName,
647 const TfToken &keyPath,
648 SdfAbstractDataValue *value) const;
649
654 template <class T>
655 bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
656 const TfToken &keyPath, T* value) const
657 {
658 if (!value) {
659 return HasFieldDictKey(path, name, keyPath,
660 static_cast<VtValue *>(NULL));
661 }
662
663 SdfAbstractDataTypedValue<T> outValue(value);
664 return HasFieldDictKey(path, name, keyPath,
665 static_cast<SdfAbstractDataValue *>(&outValue));
666 }
667
668
671 SDF_API
673 const TfToken& fieldName) const;
674
677 template <class T>
678 inline T GetFieldAs(const SdfPath& path,
679 const TfToken& fieldName, const T& defaultValue = T()) const
680 {
681 return _data->GetAs<T>(path, fieldName, defaultValue);
682 }
683
687 SDF_API
689 const TfToken& fieldName,
690 const TfToken& keyPath) const;
691
693 SDF_API
694 void SetField(const SdfPath& path, const TfToken& fieldName,
695 const VtValue& value);
696 SDF_API
697 void SetField(const SdfPath& path, const TfToken& fieldName,
698 const SdfAbstractDataConstValue& value);
699
701 template <class T>
702 void SetField(const SdfPath& path, const TfToken& fieldName,
703 const T& val)
704 {
705 // Ideally, this would make use of the SdfAbstractDataConstValue
706 // API to avoid unnecessarily copying the value into a VtValue.
707 // However, Sdf needs to create a VtValue for change processing.
708 // If the underlying SdAbstractData implementation also needs a
709 // VtValue, using the SdfAbstractDataConstValue API would cause
710 // another copy to be made. So, it's more efficient to just create
711 // the VtValue once here and push that along.
712 SetField(path, fieldName, VtValue(val));
713 }
714
717 SDF_API
719 const TfToken& fieldName,
720 const TfToken& keyPath,
721 const VtValue& value);
722 SDF_API
723 void SetFieldDictValueByKey(const SdfPath& path,
724 const TfToken& fieldName,
725 const TfToken& keyPath,
726 const SdfAbstractDataConstValue& value);
727
730 template <class T>
732 const TfToken& fieldName,
733 const TfToken& keyPath,
734 const T& val)
735 {
736 // Ideally, this would make use of the SdfAbstractDataConstValue
737 // API to avoid unnecessarily copying the value into a VtValue.
738 // However, Sdf needs to create a VtValue for change processing.
739 // If the underlying SdAbstractData implementation also needs
740 // VtValue, using the SdfAbstractDataConstValue API would cause
741 // another copy to be made. So, it's more efficient to just create
742 // the VtValue once here and push that along.
743 SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
744 }
745
747 SDF_API
748 void EraseField(const SdfPath& path, const TfToken& fieldName);
749
753 SDF_API
755 const TfToken& fieldName,
756 const TfToken& keyPath);
757
760
764 typedef std::function<void(const SdfPath&)> TraversalFunction;
765
766 // Traverse will perform a traversal of the scene description hierarchy
767 // rooted at \a path, calling \a func on each spec that it finds.
768 SDF_API
769 void Traverse(const SdfPath& path, const TraversalFunction& func);
770
772
775
779 SDF_API
781
783 SDF_API
784 void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
785
788 SDF_API
790
793 SDF_API
795
803 SDF_API
805
808 SDF_API
810
813 SDF_API
815
818 SDF_API
820
824 SDF_API
825 std::string GetComment() const;
826
828 SDF_API
829 void SetComment(const std::string &comment);
830
836 SDF_API
838
848 SDF_API
850
857 SDF_API
858 void SetDefaultPrim(const TfToken &name);
859
862 SDF_API
864
867 SDF_API
869
877 SDF_API
879
888 SDF_API
890
894 SDF_API
895 std::string GetDocumentation() const;
896
898 SDF_API
899 void SetDocumentation(const std::string &documentation);
900
908 SDF_API
909 double GetStartTimeCode() const;
910
912 SDF_API
913 void SetStartTimeCode(double startTimecode);
914
916 SDF_API
917 bool HasStartTimeCode() const;
918
920 SDF_API
922
929 SDF_API
930 double GetEndTimeCode() const;
931
933 SDF_API
934 void SetEndTimeCode(double endTimeCode);
935
937 SDF_API
938 bool HasEndTimeCode() const;
939
941 SDF_API
943
958 SDF_API
959 double GetTimeCodesPerSecond() const;
960
962 SDF_API
963 void SetTimeCodesPerSecond(double timeCodesPerSecond);
964
966 SDF_API
968
970 SDF_API
972
982 SDF_API
983 double GetFramesPerSecond() const;
984
986 SDF_API
987 void SetFramesPerSecond(double framesPerSecond);
988
990 SDF_API
991 bool HasFramesPerSecond() const;
992
994 SDF_API
996
998 SDF_API
999 int GetFramePrecision() const;
1000
1002 SDF_API
1003 void SetFramePrecision(int framePrecision);
1004
1006 SDF_API
1007 bool HasFramePrecision() const;
1008
1010 SDF_API
1012
1014 SDF_API
1015 std::string GetOwner() const;
1016
1018 SDF_API
1019 void SetOwner(const std::string& owner);
1020
1022 SDF_API
1023 bool HasOwner() const;
1024
1026 SDF_API
1028
1031 SDF_API
1032 std::string GetSessionOwner() const;
1033
1036 SDF_API
1037 void SetSessionOwner(const std::string& owner);
1038
1040 SDF_API
1041 bool HasSessionOwner() const;
1042
1043 // Clear the session owner opinion.
1044 SDF_API
1045 void ClearSessionOwner();
1046
1048 SDF_API
1050
1052 SDF_API
1054
1060 SDF_API
1062
1064 SDF_API
1066
1068 SDF_API
1070
1072 SDF_API
1074
1077 SDF_API
1079
1081 SDF_API
1082 void SetExpressionVariables(const VtDictionary& expressionVars);
1083
1085 SDF_API
1087
1089 SDF_API
1091
1095
1096 // Type for root prims view.
1098
1100 SDF_API
1102
1107 SDF_API
1108 void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1109
1115 SDF_API
1116 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1117
1119 SDF_API
1120 void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1121
1124 SDF_API
1126
1139 SDF_API
1140 void RemovePrimIfInert(SdfPrimSpecHandle prim);
1141
1148 SDF_API
1149 void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1150
1156 SDF_API
1158
1163 SDF_API
1165
1174 SDF_API
1175 void SetRootPrimOrder(const std::vector<TfToken>& names);
1176
1179 SDF_API
1180 void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1181
1183 SDF_API
1185
1187 SDF_API
1189
1195 SDF_API
1196 void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1197
1201
1214 SDF_API
1216
1218 SDF_API
1219 void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1220
1222 SDF_API
1223 size_t GetNumSubLayerPaths() const;
1224
1228 SDF_API
1229 void InsertSubLayerPath(const std::string& path, int index = -1);
1230
1232 SDF_API
1233 void RemoveSubLayerPath(int index);
1234
1236 SDF_API
1237 SdfLayerOffsetVector GetSubLayerOffsets() const;
1238
1240 SDF_API
1242
1244 SDF_API
1245 void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1246
1250
1259 SDF_API
1261
1264 SDF_API
1265 void SetRelocates(const SdfRelocates& relocates);
1266
1271 SDF_API
1272 bool HasRelocates() const;
1273
1275 SDF_API
1277
1279
1300
1317 {
1318 public:
1322
1325 {
1326 _includeAll = true;
1327 _include.clear();
1328 return *this;
1329 }
1330
1333 SDF_API
1334 DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1335
1338 SDF_API
1339 DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1340
1341 bool IncludedAll() const { return _includeAll; }
1342 const std::vector<std::string>& GetIncluded() const { return _include; }
1343 const std::vector<std::string>& GetExcluded() const { return _exclude; }
1344
1352 SDF_API
1353 bool IsIncluded(const std::string& identifier) const;
1354
1355 private:
1356 friend class SdfLayer;
1357
1358 std::vector<std::string> _include;
1359 std::vector<std::string> _exclude;
1360 bool _includeAll = false;
1361 };
1362
1385 SDF_API
1387
1389 SDF_API
1391
1395 SDF_API
1396 static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1397
1399
1402
1404 SDF_API
1405 static std::set<std::string> GetMutedLayers();
1406
1408 SDF_API
1409 bool IsMuted() const;
1410
1412 SDF_API
1413 static bool IsMuted(const std::string &path);
1414
1417 SDF_API
1418 void SetMuted(bool muted);
1419
1421 SDF_API
1422 static void AddToMutedLayers(const std::string &mutedPath);
1423
1425 SDF_API
1426 static void RemoveFromMutedLayers(const std::string &mutedPath);
1427
1431
1441 SDF_API
1442 SdfPrimSpecHandle GetPseudoRoot() const;
1443
1450 SDF_API
1451 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1452
1458 SDF_API
1459 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1460
1466 SDF_API
1467 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1468
1474 SDF_API
1475 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1476
1482 SDF_API
1483 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1484
1488
1492 SDF_API
1493 bool PermissionToEdit() const;
1494
1497 SDF_API
1498 bool PermissionToSave() const;
1499
1501 SDF_API
1502 void SetPermissionToEdit(bool allow);
1503
1505 SDF_API
1506 void SetPermissionToSave(bool allow);
1507
1511
1535 SDF_API
1538 SdfNamespaceEditDetailVector* details = NULL) const;
1539
1543 SDF_API
1545
1549
1552 SDF_API
1553 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1554
1558 SDF_API
1559 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1560
1563 SDF_API
1564 bool IsDirty() const;
1565
1567
1570 SDF_API
1571 std::set<double> ListAllTimeSamples() const;
1572
1573 SDF_API
1574 std::set<double>
1575 ListTimeSamplesForPath(const SdfPath& path) const;
1576
1577 SDF_API
1578 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1579
1580 SDF_API
1581 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1582
1583 SDF_API
1584 bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1585 double time,
1586 double* tLower, double* tUpper) const;
1587
1594 SDF_API
1595 bool GetPreviousTimeSampleForPath(const SdfPath& path, double time,
1596 double* tPrevious) const;
1597
1598 SDF_API
1599 bool QueryTimeSample(const SdfPath& path, double time,
1600 VtValue *value=NULL) const;
1601
1602 SDF_API
1603 bool QueryTimeSample(const SdfPath& path, double time,
1604 SdfAbstractDataValue *value) const;
1605
1606 template <class T>
1607 bool QueryTimeSample(const SdfPath& path, double time,
1608 T* data) const
1609 {
1610 if (!data) {
1611 return QueryTimeSample(path, time);
1612 }
1613
1614 SdfAbstractDataTypedValue<T> outValue(data);
1615 const bool hasValue = QueryTimeSample(
1616 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1617
1618 if (std::is_same<T, SdfValueBlock>::value) {
1619 return hasValue && outValue.isValueBlock;
1620 }
1621
1622 return hasValue && (!outValue.isValueBlock);
1623 }
1624
1627 SDF_API
1628 const std::type_info &
1629 QueryTimeSampleTypeid(const SdfPath &path, double time) const;
1630
1631 SDF_API
1632 void SetTimeSample(const SdfPath& path, double time,
1633 const VtValue & value);
1634
1635 SDF_API
1636 void SetTimeSample(const SdfPath& path, double time,
1637 const SdfAbstractDataConstValue& value);
1638
1639 template <class T>
1640 void SetTimeSample(const SdfPath& path, double time,
1641 const T& value)
1642 {
1643 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1644 const SdfAbstractDataConstValue& untypedInValue = inValue;
1645 return SetTimeSample(path, time, untypedInValue);
1646 }
1647
1648 SDF_API
1649 void EraseTimeSample(const SdfPath& path, double time);
1650
1652
1653 // Debugging
1654 // @{
1655
1656 SDF_API
1657 static void DumpLayerInfo();
1658
1659 // Write this layer's SdfData to a file in a simple generic format.
1660 SDF_API
1661 bool WriteDataFile(const std::string &filename);
1662
1663 // @}
1664
1672 SDF_API
1674 const SdfLayerHandle& layer,
1675 bool processPropertyFields = true) const;
1676
1677protected:
1678 // Private constructor -- use New(), FindOrCreate(), etc.
1679 // Precondition: _layerRegistryMutex must be locked.
1680 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1681 const std::string &identifier,
1682 const std::string &realPath = std::string(),
1683 const ArAssetInfo& assetInfo = ArAssetInfo(),
1685 bool validateAuthoring = false);
1686
1687private:
1688 // Create a new layer.
1689 // Precondition: _layerRegistryMutex must be locked.
1690 static SdfLayerRefPtr _CreateNew(
1691 SdfFileFormatConstPtr fileFormat,
1692 const std::string& identifier,
1693 const FileFormatArguments& args,
1694 bool saveLayer = true);
1695
1696 static SdfLayerRefPtr _CreateNewWithFormat(
1697 const SdfFileFormatConstPtr &fileFormat,
1698 const std::string& identifier,
1699 const std::string& realPath,
1700 const ArAssetInfo& assetInfo = ArAssetInfo(),
1702
1703 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1704 const SdfFileFormatConstPtr &fileFormat,
1705 const std::string& tag,
1706 const FileFormatArguments& args);
1707
1708 // Finish initializing this layer (which may have succeeded or not)
1709 // and publish the results to other threads by unlocking the mutex.
1710 // Sets _initializationWasSuccessful.
1711 void _FinishInitialization(bool success);
1712
1713 // Layers retrieved from the layer registry may still be in the
1714 // process of having their contents initialized. Other threads
1715 // retrieving layers from the registry must wait until initialization
1716 // is complete, using this method.
1717 // Returns _initializationWasSuccessful.
1718 //
1719 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1720 // ensure that it is not deleted out from under them, in
1721 // case initialization fails. (This method cannot acquire the
1722 // reference itself internally without being susceptible to a race.)
1723 bool _WaitForInitializationAndCheckIfSuccessful();
1724
1725 // Returns whether or not this layer should post change
1726 // notification. This simply returns (!_GetIsLoading())
1727 bool _ShouldNotify() const;
1728
1729 // This function keeps track of the last state of IsDirty() before
1730 // updating it. It returns false if the last saved dirty state is the
1731 // same than the current state. It returns true if the state differs and
1732 // will update the 'last dirty state' to the current state. So, after
1733 // returning true, it would return false for subsequent calls until the
1734 // IsDirty() state would change again...
1735 bool _UpdateLastDirtinessState() const;
1736
1737 // Returns a handle to the spec at the given path if it exists and matches
1738 // type T.
1739 template <class T>
1740 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1741
1742 // Returns true if a spec can be retrieved at the given path, false
1743 // otherwise. This function will return the canonicalized path to the
1744 // spec as well as the spec type.
1745 bool _CanGetSpecAtPath(const SdfPath& path,
1746 SdfPath* canonicalPath, SdfSpecType* specType) const;
1747
1751 void _InitializeFromIdentifier(
1752 const std::string &identifier,
1753 const std::string &realPath = std::string(),
1754 const std::string &fileVersion = std::string(),
1755 const ArAssetInfo& assetInfo = ArAssetInfo());
1756
1757 // Helper for computing the necessary information to lookup a layer
1758 // in the registry or open the layer.
1759 struct _FindOrOpenLayerInfo;
1760 static bool _ComputeInfoToFindOrOpenLayer(
1761 const std::string& identifier,
1763 _FindOrOpenLayerInfo* info,
1764 bool computeAssetInfo = false);
1765
1766 // Open a layer, adding an entry to the registry and releasing
1767 // the registry lock.
1768 // Precondition: _layerRegistryMutex must be locked.
1769 template <class Lock>
1770 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1771 Lock &lock,
1772 const _FindOrOpenLayerInfo& info,
1773 bool metadataOnly);
1774
1775 // Helper function for finding a layer with \p identifier and \p args.
1776 // \p lock must be unlocked initially and will be locked by this
1777 // function when needed. See docs for \p retryAsWriter argument on
1778 // _TryToFindLayer for details on the final state of the lock when
1779 // this function returns.
1780 template <class ScopedLock>
1781 static SdfLayerRefPtr
1782 _Find(const std::string &identifier,
1783 const FileFormatArguments &args,
1784 ScopedLock &lock, bool retryAsWriter);
1785
1786 // Helper function to try to find the layer with \p identifier and
1787 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1788 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1789 // released upon return. Otherwise the lock is released upon return if a
1790 // layer is found successfully. If no layer is found then the lock is
1791 // upgraded to a writer lock upon return. Note that this upgrade may not be
1792 // atomic, but this function ensures that if upon return there does not
1793 // exist a matching layer in the registry.
1794 template <class ScopedLock>
1795 static SdfLayerRefPtr
1796 _TryToFindLayer(const std::string &identifier,
1797 const ArResolvedPath &resolvedPath,
1798 ScopedLock &lock, bool retryAsWriter);
1799
1807 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1808 bool requiredFieldOnlyPropertiesAreInert = false) const;
1809
1813 bool _IsInertSubtree(const SdfPath &path) const;
1814
1820 void _RemoveIfInert(const SdfSpec& spec);
1821
1826 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1827
1830 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1831
1833 bool _ValidateAuthoring() const { return _validateAuthoring; }
1834
1836 std::string _GetMutedPath() const;
1837
1838 // If old and new asset path is given, rename all external prim
1839 // composition dependency referring to the old path.
1840 void _UpdatePrimCompositionDependencyPaths(
1841 const SdfPrimSpecHandle &parent,
1842 const std::string &oldLayerPath,
1843 const std::string &newLayerPath);
1844
1845 // Set the clean state to the current state.
1846 void _MarkCurrentStateAsClean() const;
1847
1848 // Return the field definition for \p fieldName if \p fieldName is a
1849 // required field for the spec type identified by \p path.
1850 inline SdfSchema::FieldDefinition const *
1851 _GetRequiredFieldDef(const SdfPath &path,
1852 const TfToken &fieldName,
1853 SdfSpecType specType = SdfSpecTypeUnknown) const;
1854
1855 // Return the field definition for \p fieldName if \p fieldName is a
1856 // required field for \p specType subject to \p schema.
1857 static inline SdfSchema::FieldDefinition const *
1858 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1859 const TfToken &fieldName,
1860 SdfSpecType specType);
1861
1862 // Helper to list all fields on \p data at \p path subject to \p schema.
1863 static std::vector<TfToken>
1864 _ListFields(SdfSchemaBase const &schema,
1865 SdfAbstractData const &data, const SdfPath& path);
1866
1867 // Helper for HasField for \p path in \p data subject to \p schema.
1868 static inline bool
1869 _HasField(const SdfSchemaBase &schema,
1870 const SdfAbstractData &data,
1871 const SdfPath& path,
1872 const TfToken& fieldName,
1873 VtValue *value);
1874
1875 // Helper to get a field value for \p path in \p data subject to \p schema.
1876 static inline VtValue
1877 _GetField(const SdfSchemaBase &schema,
1878 const SdfAbstractData &data,
1879 const SdfPath& path,
1880 const TfToken& fieldName);
1881
1882 // Set a value.
1883 template <class T>
1884 void _SetValue(const TfToken& key, T value);
1885
1886 // Get a value.
1887 template <class T>
1888 T _GetValue(const TfToken& key) const;
1889
1890 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1891 _ReloadResult _Reload(bool force);
1892
1893 // Reads contents of asset specified by \p identifier with resolved
1894 // path \p resolvedPath into this layer.
1895 bool _Read(const std::string& identifier,
1896 const ArResolvedPath& resolvedPath,
1897 bool metadataOnly);
1898
1899 // Saves this layer if it is dirty or the layer doesn't already exist
1900 // on disk. If \p force is true, the layer will be written out
1901 // regardless of those conditions.
1902 bool _Save(bool force) const;
1903
1904 // A helper method used by Save and Export.
1905 // This method allows Save to specify the existing file format and Export
1906 // to use the format provided by the file extension in newFileName. If no
1907 // file format can be discovered from the file name, the existing file
1908 // format associated with the layer will be used in both cases. This allows
1909 // users to export and save to any file name, regardless of extension.
1910 bool _WriteToFile(const std::string& newFileName,
1911 const std::string& comment,
1912 SdfFileFormatConstPtr fileFormat,
1913 const FileFormatArguments& args) const;
1914
1915 // Swap contents of _data and data. This operation does not register
1916 // inverses or emit change notification.
1917 void _SwapData(SdfAbstractDataRefPtr &data);
1918
1919 // Set _data to \p newData and send coarse DidReplaceLayerContent
1920 // invalidation notice.
1921 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1922
1923 // Helper function which will process incoming data to this layer in a
1924 // generic way.
1925 // If \p processPropertyFields is false, this method will not
1926 // consider property spec fields. In some cases, this can avoid expensive
1927 // operations which would pull large amounts of data.
1928 template<typename DeleteSpecFunc, typename CreateSpecFunc,
1929 typename GetFieldValuesFunc, typename SetFieldFunc, typename ErrorFunc>
1930 void _ProcessIncomingData(const SdfAbstractDataPtr &newData,
1931 const SdfSchemaBase *newDataSchema,
1932 bool processPropertyFields,
1933 const DeleteSpecFunc &deleteSpecFunc,
1934 const CreateSpecFunc &createSpecFunc,
1935 const GetFieldValuesFunc &getFieldValuesFunc,
1936 const SetFieldFunc &setFieldFunc,
1937 const ErrorFunc &errorFunc) const;
1938
1939 // Set _data to match data, calling other primitive setter methods to
1940 // provide fine-grained inverses and notification. If \p data might adhere
1941 // to a different schema than this layer's, pass a pointer to it as \p
1942 // newDataSchema. In this case, check to see if fields from \p data are
1943 // known to this layer's schema, and if not, omit them and issue a TfError
1944 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1945 // known fields.
1946 void _SetData(const SdfAbstractDataPtr &newData,
1947 const SdfSchemaBase *newDataSchema=nullptr);
1948
1949 // Returns const handle to _data.
1950 SdfAbstractDataConstPtr _GetData() const;
1951
1952 // Returns a new SdfAbstractData object for this layer.
1953 SdfAbstractDataRefPtr _CreateData() const;
1954
1955 // Inverse primitive for setting a single field. The previous value for the
1956 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1957 // VtValue it points to will be moved-from after the function completes. If
1958 // \p oldValue is nullptr, the old field value will be retrieved
1959 // automatically.
1960 template <class T>
1961 void _PrimSetField(const SdfPath& path,
1962 const TfToken& fieldName,
1963 const T& value,
1964 VtValue *oldValue = nullptr,
1965 bool useDelegate = true);
1966
1967 // Inverse primitive for setting a single key in a dict-valued field. The
1968 // previous dictionary value for the field (*not* the individual entry) may
1969 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1970 // it points to will be moved-from after the function completes. If \p
1971 // oldValue is nullptr, the old field value will be retrieved automatically.
1972 template <class T>
1973 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1974 const TfToken& fieldName,
1975 const TfToken& keyPath,
1976 const T& value,
1977 VtValue *oldValue = nullptr,
1978 bool useDelegate = true);
1979
1980 // Primitive for appending a child to the list of children.
1981 template <class T>
1982 void _PrimPushChild(const SdfPath& parentPath,
1983 const TfToken& fieldName,
1984 const T& value,
1985 bool useDelegate = true);
1986 template <class T>
1987 void _PrimPopChild(const SdfPath& parentPath,
1988 const TfToken& fieldName,
1989 bool useDelegate = true);
1990
1991 // Move all the fields at all paths at or below \a oldPath to be
1992 // at a corresponding location at or below \a newPath. This does
1993 // not update the children fields of the parents of these paths.
1994 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1995
1996 // Inverse primitive for moving a spec.
1997 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1998 bool useDelegate = true);
1999
2000 // Create a new spec of type \p specType at \p path.
2001 // Returns true if spec was successfully created, false otherwise.
2002 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
2003
2004 // Delete all the fields at or below the specified path. This does
2005 // not update the children field of the parent of \a path.
2006 bool _DeleteSpec(const SdfPath &path);
2007
2008 // Inverse primitive for deleting a spec.
2009 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
2010 bool useDelegate = true);
2011
2012 // Inverse primitive for deleting a spec.
2013 void _PrimDeleteSpec(const SdfPath &path, bool inert,
2014 bool useDelegate = true);
2015
2016 // Inverse primitive for setting time samples.
2017 template <class T>
2018 void _PrimSetTimeSample(const SdfPath& path, double time,
2019 const T& value,
2020 bool useDelegate = true);
2021
2022 // Helper method for Traverse. Visits the children of \a path using the
2023 // specified \a ChildPolicy.
2024 template <typename ChildPolicy>
2025 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
2026
2027private:
2028 SdfLayerHandle _self;
2029
2030 // File format and arguments for this layer.
2031 SdfFileFormatConstPtr _fileFormat;
2032 FileFormatArguments _fileFormatArgs;
2033
2034 // Cached reference to the _fileFormat's schema -- we need access to this to
2035 // be as fast as possible since we look at it on every SetField(), for
2036 // example.
2037 const SdfSchemaBase &_schema;
2038
2039 // Registry of Sdf Identities
2040 mutable Sdf_IdentityRegistry _idRegistry;
2041
2042 // The underlying SdfData which stores all the data in the layer.
2043 SdfAbstractDataRefPtr _data;
2044
2045 // The state delegate for this layer.
2046 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
2047
2048 // Dispatcher used in layer initialization, letting waiters participate in
2049 // loading instead of just busy-waiting.
2050 WorkDispatcher _initDispatcher;
2051
2052 // Atomic variable protecting layer initialization -- the interval between
2053 // adding a layer to the layer registry and finishing the process of
2054 // initializing its contents, at which point we can truly publish the layer
2055 // for consumption by concurrent threads. We add the layer to the registry
2056 // before initialization completes so that other threads can discover and
2057 // wait for it to finish initializing.
2058 std::atomic<bool> _initializationComplete;
2059
2060 // This is an optional<bool> that is only set once initialization
2061 // is complete, before _initializationComplete is set.
2062 std::optional<bool> _initializationWasSuccessful;
2063
2064 // remembers the last 'IsDirty' state.
2065 mutable bool _lastDirtyState;
2066
2067 // Asset information for this layer.
2068 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
2069
2070 // Modification timestamp of the backing file asset when last read.
2071 mutable VtValue _assetModificationTime;
2072
2073 // All external asset dependencies, with their modification timestamps, of
2074 // the layer when last read.
2075 mutable VtDictionary _externalAssetModificationTimes;
2076
2077 // Mutable revision number for cache invalidation.
2078 mutable size_t _mutedLayersRevisionCache;
2079
2080 // Cache of whether or not this layer is muted. Only valid if
2081 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2082 mutable bool _isMutedCache;
2083
2084 // Layer permission bits.
2085 bool _permissionToEdit;
2086 bool _permissionToSave;
2087
2088 // Whether layer edits are validated.
2089 bool _validateAuthoring;
2090
2091 // Layer hints as of the most recent save operation.
2092 mutable SdfLayerHints _hints;
2093
2094 // Allow access to _ValidateAuthoring() and _IsInert().
2095 friend class SdfSpec;
2096 friend class SdfPropertySpec;
2097 friend class SdfAttributeSpec;
2098
2099 friend class Sdf_ChangeManager;
2100
2101 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2102 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2103
2104 // Give the file format access to our data. Limit breaking encapsulation
2105 // to the base SdFileFormat class so we don't have to friend every
2106 // implementation here.
2107 friend class SdfFileFormat;
2108
2109 // Give layer state delegates access to our data as well as to
2110 // the various _Prim functions.
2111 friend class SdfLayerStateDelegateBase;
2112};
2113
2114PXR_NAMESPACE_CLOSE_SCOPE
2115
2116#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:1317
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1324
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:611
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:731
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:631
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:678
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:702
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.
static SDF_API std::pair< std::string, std::string > SplitIdentifier(const std::string &identifier)
Splits the given layer identifier and returns its constituent layer path and arguments as a pair of s...
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:655
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:764
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