All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
864 SDF_API
865 std::string GetDocumentation() const;
866
868 SDF_API
869 void SetDocumentation(const std::string &documentation);
870
878 SDF_API
879 double GetStartTimeCode() const;
880
882 SDF_API
883 void SetStartTimeCode(double startTimecode);
884
886 SDF_API
887 bool HasStartTimeCode() const;
888
890 SDF_API
892
899 SDF_API
900 double GetEndTimeCode() const;
901
903 SDF_API
904 void SetEndTimeCode(double endTimeCode);
905
907 SDF_API
908 bool HasEndTimeCode() const;
909
911 SDF_API
913
928 SDF_API
929 double GetTimeCodesPerSecond() const;
930
932 SDF_API
933 void SetTimeCodesPerSecond(double timeCodesPerSecond);
934
936 SDF_API
938
940 SDF_API
942
952 SDF_API
953 double GetFramesPerSecond() const;
954
956 SDF_API
957 void SetFramesPerSecond(double framesPerSecond);
958
960 SDF_API
961 bool HasFramesPerSecond() const;
962
964 SDF_API
966
968 SDF_API
969 int GetFramePrecision() const;
970
972 SDF_API
973 void SetFramePrecision(int framePrecision);
974
976 SDF_API
977 bool HasFramePrecision() const;
978
980 SDF_API
982
984 SDF_API
985 std::string GetOwner() const;
986
988 SDF_API
989 void SetOwner(const std::string& owner);
990
992 SDF_API
993 bool HasOwner() const;
994
996 SDF_API
998
1001 SDF_API
1002 std::string GetSessionOwner() const;
1003
1006 SDF_API
1007 void SetSessionOwner(const std::string& owner);
1008
1010 SDF_API
1011 bool HasSessionOwner() const;
1012
1013 // Clear the session owner opinion.
1014 SDF_API
1015 void ClearSessionOwner();
1016
1018 SDF_API
1020
1022 SDF_API
1024
1030 SDF_API
1032
1034 SDF_API
1036
1038 SDF_API
1040
1042 SDF_API
1044
1047 SDF_API
1049
1051 SDF_API
1052 void SetExpressionVariables(const VtDictionary& expressionVars);
1053
1055 SDF_API
1057
1059 SDF_API
1061
1065
1066 // Type for root prims view.
1068
1070 SDF_API
1072
1077 SDF_API
1078 void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1079
1085 SDF_API
1086 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1087
1089 SDF_API
1090 void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1091
1094 SDF_API
1096
1109 SDF_API
1110 void RemovePrimIfInert(SdfPrimSpecHandle prim);
1111
1118 SDF_API
1119 void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1120
1126 SDF_API
1128
1133 SDF_API
1135
1144 SDF_API
1145 void SetRootPrimOrder(const std::vector<TfToken>& names);
1146
1149 SDF_API
1150 void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1151
1153 SDF_API
1155
1157 SDF_API
1159
1165 SDF_API
1166 void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1167
1171
1184 SDF_API
1186
1188 SDF_API
1189 void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1190
1192 SDF_API
1193 size_t GetNumSubLayerPaths() const;
1194
1198 SDF_API
1199 void InsertSubLayerPath(const std::string& path, int index = -1);
1200
1202 SDF_API
1203 void RemoveSubLayerPath(int index);
1204
1206 SDF_API
1207 SdfLayerOffsetVector GetSubLayerOffsets() const;
1208
1210 SDF_API
1212
1214 SDF_API
1215 void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1216
1220
1229 SDF_API
1231
1234 SDF_API
1235 void SetRelocates(const SdfRelocates& relocates);
1236
1241 SDF_API
1242 bool HasRelocates() const;
1243
1245 SDF_API
1247
1249
1270
1287 {
1288 public:
1292
1295 {
1296 _includeAll = true;
1297 _include.clear();
1298 return *this;
1299 }
1300
1303 SDF_API
1304 DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1305
1308 SDF_API
1309 DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1310
1311 bool IncludedAll() const { return _includeAll; }
1312 const std::vector<std::string>& GetIncluded() const { return _include; }
1313 const std::vector<std::string>& GetExcluded() const { return _exclude; }
1314
1322 SDF_API
1323 bool IsIncluded(const std::string& identifier) const;
1324
1325 private:
1326 friend class SdfLayer;
1327
1328 std::vector<std::string> _include;
1329 std::vector<std::string> _exclude;
1330 bool _includeAll = false;
1331 };
1332
1355 SDF_API
1357
1359 SDF_API
1361
1365 SDF_API
1366 static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1367
1369
1372
1374 SDF_API
1375 static std::set<std::string> GetMutedLayers();
1376
1378 SDF_API
1379 bool IsMuted() const;
1380
1382 SDF_API
1383 static bool IsMuted(const std::string &path);
1384
1387 SDF_API
1388 void SetMuted(bool muted);
1389
1391 SDF_API
1392 static void AddToMutedLayers(const std::string &mutedPath);
1393
1395 SDF_API
1396 static void RemoveFromMutedLayers(const std::string &mutedPath);
1397
1401
1410 SDF_API
1411 SdfPrimSpecHandle GetPseudoRoot() const;
1412
1419 SDF_API
1420 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1421
1427 SDF_API
1428 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1429
1435 SDF_API
1436 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1437
1443 SDF_API
1444 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1445
1451 SDF_API
1452 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1453
1457
1461 SDF_API
1462 bool PermissionToEdit() const;
1463
1466 SDF_API
1467 bool PermissionToSave() const;
1468
1470 SDF_API
1471 void SetPermissionToEdit(bool allow);
1472
1474 SDF_API
1475 void SetPermissionToSave(bool allow);
1476
1480
1504 SDF_API
1507 SdfNamespaceEditDetailVector* details = NULL) const;
1508
1512 SDF_API
1514
1518
1521 SDF_API
1522 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1523
1527 SDF_API
1528 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1529
1532 SDF_API
1533 bool IsDirty() const;
1534
1536
1539 SDF_API
1540 std::set<double> ListAllTimeSamples() const;
1541
1544 SDF_API
1545 std::set<double>
1547
1548 SDF_API
1549 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1550
1553 SDF_API
1554 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1555
1558 SDF_API
1560 double time,
1561 double* tLower, double* tUpper);
1562
1565 SDF_API
1566 bool QueryTimeSample(const SdfPath& path, double time,
1567 VtValue *value=NULL) const;
1568
1571 SDF_API
1572 bool QueryTimeSample(const SdfPath& path, double time,
1573 SdfAbstractDataValue *value) const;
1574
1577 template <class T>
1578 bool QueryTimeSample(const SdfPath& path, double time,
1579 T* data) const
1580 {
1581 if (!data) {
1582 return QueryTimeSample(path, time);
1583 }
1584
1585 SdfAbstractDataTypedValue<T> outValue(data);
1586 const bool hasValue = QueryTimeSample(
1587 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1588
1589 if (std::is_same<T, SdfValueBlock>::value) {
1590 return hasValue && outValue.isValueBlock;
1591 }
1592
1593 return hasValue && (!outValue.isValueBlock);
1594 }
1595
1598 SDF_API
1599 void SetTimeSample(const SdfPath& path, double time,
1600 const VtValue & value);
1601
1604 SDF_API
1605 void SetTimeSample(const SdfPath& path, double time,
1606 const SdfAbstractDataConstValue& value);
1607
1610 template <class T>
1611 void SetTimeSample(const SdfPath& path, double time,
1612 const T& value)
1613 {
1614 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1615 const SdfAbstractDataConstValue& untypedInValue = inValue;
1616 return SetTimeSample(path, time, untypedInValue);
1617 }
1618
1621 SDF_API
1622 void EraseTimeSample(const SdfPath& path, double time);
1623
1625
1626 // Debugging
1627 // @{
1628
1629 SDF_API
1630 static void DumpLayerInfo();
1631
1632 // Write this layer's SdfData to a file in a simple generic format.
1633 SDF_API
1634 bool WriteDataFile(const std::string &filename);
1635
1636 // @}
1637
1645 SDF_API
1647 const SdfLayerHandle& layer,
1648 bool processPropertyFields = true) const;
1649
1650protected:
1651 // Private constructor -- use New(), FindOrCreate(), etc.
1652 // Precondition: _layerRegistryMutex must be locked.
1653 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1654 const std::string &identifier,
1655 const std::string &realPath = std::string(),
1656 const ArAssetInfo& assetInfo = ArAssetInfo(),
1658 bool validateAuthoring = false);
1659
1660private:
1661 // Create a new layer.
1662 // Precondition: _layerRegistryMutex must be locked.
1663 static SdfLayerRefPtr _CreateNew(
1664 SdfFileFormatConstPtr fileFormat,
1665 const std::string& identifier,
1666 const FileFormatArguments& args,
1667 bool saveLayer = true);
1668
1669 static SdfLayerRefPtr _CreateNewWithFormat(
1670 const SdfFileFormatConstPtr &fileFormat,
1671 const std::string& identifier,
1672 const std::string& realPath,
1673 const ArAssetInfo& assetInfo = ArAssetInfo(),
1675
1676 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1677 const SdfFileFormatConstPtr &fileFormat,
1678 const std::string& tag,
1679 const FileFormatArguments& args);
1680
1681 // Finish initializing this layer (which may have succeeded or not)
1682 // and publish the results to other threads by unlocking the mutex.
1683 // Sets _initializationWasSuccessful.
1684 void _FinishInitialization(bool success);
1685
1686 // Layers retrieved from the layer registry may still be in the
1687 // process of having their contents initialized. Other threads
1688 // retrieving layers from the registry must wait until initialization
1689 // is complete, using this method.
1690 // Returns _initializationWasSuccessful.
1691 //
1692 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1693 // ensure that it is not deleted out from under them, in
1694 // case initialization fails. (This method cannot acquire the
1695 // reference itself internally without being susceptible to a race.)
1696 bool _WaitForInitializationAndCheckIfSuccessful();
1697
1698 // Returns whether or not this layer should post change
1699 // notification. This simply returns (!_GetIsLoading())
1700 bool _ShouldNotify() const;
1701
1702 // This function keeps track of the last state of IsDirty() before
1703 // updating it. It returns false if the last saved dirty state is the
1704 // same than the current state. It returns true if the state differs and
1705 // will update the 'last dirty state' to the current state. So, after
1706 // returning true, it would return false for subsequent calls until the
1707 // IsDirty() state would change again...
1708 bool _UpdateLastDirtinessState() const;
1709
1710 // Returns a handle to the spec at the given path if it exists and matches
1711 // type T.
1712 template <class T>
1713 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1714
1715 // Returns true if a spec can be retrieved at the given path, false
1716 // otherwise. This function will return the canonicalized path to the
1717 // spec as well as the spec type.
1718 bool _CanGetSpecAtPath(const SdfPath& path,
1719 SdfPath* canonicalPath, SdfSpecType* specType) const;
1720
1724 void _InitializeFromIdentifier(
1725 const std::string &identifier,
1726 const std::string &realPath = std::string(),
1727 const std::string &fileVersion = std::string(),
1728 const ArAssetInfo& assetInfo = ArAssetInfo());
1729
1730 // Helper for computing the necessary information to lookup a layer
1731 // in the registry or open the layer.
1732 struct _FindOrOpenLayerInfo;
1733 static bool _ComputeInfoToFindOrOpenLayer(
1734 const std::string& identifier,
1736 _FindOrOpenLayerInfo* info,
1737 bool computeAssetInfo = false);
1738
1739 // Open a layer, adding an entry to the registry and releasing
1740 // the registry lock.
1741 // Precondition: _layerRegistryMutex must be locked.
1742 template <class Lock>
1743 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1744 Lock &lock,
1745 const _FindOrOpenLayerInfo& info,
1746 bool metadataOnly);
1747
1748 // Helper function for finding a layer with \p identifier and \p args.
1749 // \p lock must be unlocked initially and will be locked by this
1750 // function when needed. See docs for \p retryAsWriter argument on
1751 // _TryToFindLayer for details on the final state of the lock when
1752 // this function returns.
1753 template <class ScopedLock>
1754 static SdfLayerRefPtr
1755 _Find(const std::string &identifier,
1756 const FileFormatArguments &args,
1757 ScopedLock &lock, bool retryAsWriter);
1758
1759 // Helper function to try to find the layer with \p identifier and
1760 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1761 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1762 // released upon return. Otherwise the lock is released upon return if a
1763 // layer is found successfully. If no layer is found then the lock is
1764 // upgraded to a writer lock upon return. Note that this upgrade may not be
1765 // atomic, but this function ensures that if upon return there does not
1766 // exist a matching layer in the registry.
1767 template <class ScopedLock>
1768 static SdfLayerRefPtr
1769 _TryToFindLayer(const std::string &identifier,
1770 const ArResolvedPath &resolvedPath,
1771 ScopedLock &lock, bool retryAsWriter);
1772
1780 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1781 bool requiredFieldOnlyPropertiesAreInert = false) const;
1782
1786 bool _IsInertSubtree(const SdfPath &path) const;
1787
1793 void _RemoveIfInert(const SdfSpec& spec);
1794
1799 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1800
1803 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1804
1806 bool _ValidateAuthoring() const { return _validateAuthoring; }
1807
1809 std::string _GetMutedPath() const;
1810
1811 // If old and new asset path is given, rename all external prim
1812 // composition dependency referring to the old path.
1813 void _UpdatePrimCompositionDependencyPaths(
1814 const SdfPrimSpecHandle &parent,
1815 const std::string &oldLayerPath,
1816 const std::string &newLayerPath);
1817
1818 // Set the clean state to the current state.
1819 void _MarkCurrentStateAsClean() const;
1820
1821 // Return the field definition for \p fieldName if \p fieldName is a
1822 // required field for the spec type identified by \p path.
1823 inline SdfSchema::FieldDefinition const *
1824 _GetRequiredFieldDef(const SdfPath &path,
1825 const TfToken &fieldName,
1826 SdfSpecType specType = SdfSpecTypeUnknown) const;
1827
1828 // Return the field definition for \p fieldName if \p fieldName is a
1829 // required field for \p specType subject to \p schema.
1830 static inline SdfSchema::FieldDefinition const *
1831 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1832 const TfToken &fieldName,
1833 SdfSpecType specType);
1834
1835 // Helper to list all fields on \p data at \p path subject to \p schema.
1836 static std::vector<TfToken>
1837 _ListFields(SdfSchemaBase const &schema,
1838 SdfAbstractData const &data, const SdfPath& path);
1839
1840 // Helper for HasField for \p path in \p data subject to \p schema.
1841 static inline bool
1842 _HasField(const SdfSchemaBase &schema,
1843 const SdfAbstractData &data,
1844 const SdfPath& path,
1845 const TfToken& fieldName,
1846 VtValue *value);
1847
1848 // Helper to get a field value for \p path in \p data subject to \p schema.
1849 static inline VtValue
1850 _GetField(const SdfSchemaBase &schema,
1851 const SdfAbstractData &data,
1852 const SdfPath& path,
1853 const TfToken& fieldName);
1854
1855 // Set a value.
1856 template <class T>
1857 void _SetValue(const TfToken& key, T value);
1858
1859 // Get a value.
1860 template <class T>
1861 T _GetValue(const TfToken& key) const;
1862
1863 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1864 _ReloadResult _Reload(bool force);
1865
1866 // Reads contents of asset specified by \p identifier with resolved
1867 // path \p resolvedPath into this layer.
1868 bool _Read(const std::string& identifier,
1869 const ArResolvedPath& resolvedPath,
1870 bool metadataOnly);
1871
1872 // Saves this layer if it is dirty or the layer doesn't already exist
1873 // on disk. If \p force is true, the layer will be written out
1874 // regardless of those conditions.
1875 bool _Save(bool force) const;
1876
1877 // A helper method used by Save and Export.
1878 // This method allows Save to specify the existing file format and Export
1879 // to use the format provided by the file extension in newFileName. If no
1880 // file format can be discovered from the file name, the existing file
1881 // format associated with the layer will be used in both cases. This allows
1882 // users to export and save to any file name, regardless of extension.
1883 bool _WriteToFile(const std::string& newFileName,
1884 const std::string& comment,
1885 SdfFileFormatConstPtr fileFormat,
1886 const FileFormatArguments& args) const;
1887
1888 // Swap contents of _data and data. This operation does not register
1889 // inverses or emit change notification.
1890 void _SwapData(SdfAbstractDataRefPtr &data);
1891
1892 // Set _data to \p newData and send coarse DidReplaceLayerContent
1893 // invalidation notice.
1894 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1895
1896 // Helper function which will process incoming data to this layer in a
1897 // generic way.
1898 // If \p processPropertyFields is false, this method will not
1899 // consider property spec fields. In some cases, this can avoid expensive
1900 // operations which would pull large amounts of data.
1901 template<typename DeleteSpecFunc, typename CreateSpecFunc,
1902 typename SetFieldFunc, typename ErrorFunc>
1903 void _ProcessIncomingData(const SdfAbstractDataPtr &newData,
1904 const SdfSchemaBase *newDataSchema,
1905 bool processPropertyFields,
1906 const DeleteSpecFunc &deleteSpecFunc,
1907 const CreateSpecFunc &createSpecFunc,
1908 const SetFieldFunc &setFieldFunc,
1909 const ErrorFunc &errorFunc) const;
1910
1911 // Set _data to match data, calling other primitive setter methods to
1912 // provide fine-grained inverses and notification. If \p data might adhere
1913 // to a different schema than this layer's, pass a pointer to it as \p
1914 // newDataSchema. In this case, check to see if fields from \p data are
1915 // known to this layer's schema, and if not, omit them and issue a TfError
1916 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1917 // known fields.
1918 void _SetData(const SdfAbstractDataPtr &newData,
1919 const SdfSchemaBase *newDataSchema=nullptr);
1920
1921 // Returns const handle to _data.
1922 SdfAbstractDataConstPtr _GetData() const;
1923
1924 // Returns a new SdfAbstractData object for this layer.
1925 SdfAbstractDataRefPtr _CreateData() const;
1926
1927 // Inverse primitive for setting a single field. The previous value for the
1928 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1929 // VtValue it points to will be moved-from after the function completes. If
1930 // \p oldValue is nullptr, the old field value will be retrieved
1931 // automatically.
1932 template <class T>
1933 void _PrimSetField(const SdfPath& path,
1934 const TfToken& fieldName,
1935 const T& value,
1936 VtValue *oldValue = nullptr,
1937 bool useDelegate = true);
1938
1939 // Inverse primitive for setting a single key in a dict-valued field. The
1940 // previous dictionary value for the field (*not* the individual entry) may
1941 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1942 // it points to will be moved-from after the function completes. If \p
1943 // oldValue is nullptr, the old field value will be retrieved automatically.
1944 template <class T>
1945 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1946 const TfToken& fieldName,
1947 const TfToken& keyPath,
1948 const T& value,
1949 VtValue *oldValue = nullptr,
1950 bool useDelegate = true);
1951
1952 // Primitive for appending a child to the list of children.
1953 template <class T>
1954 void _PrimPushChild(const SdfPath& parentPath,
1955 const TfToken& fieldName,
1956 const T& value,
1957 bool useDelegate = true);
1958 template <class T>
1959 void _PrimPopChild(const SdfPath& parentPath,
1960 const TfToken& fieldName,
1961 bool useDelegate = true);
1962
1963 // Move all the fields at all paths at or below \a oldPath to be
1964 // at a corresponding location at or below \a newPath. This does
1965 // not update the children fields of the parents of these paths.
1966 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1967
1968 // Inverse primitive for moving a spec.
1969 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1970 bool useDelegate = true);
1971
1972 // Create a new spec of type \p specType at \p path.
1973 // Returns true if spec was successfully created, false otherwise.
1974 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1975
1976 // Delete all the fields at or below the specified path. This does
1977 // not update the children field of the parent of \a path.
1978 bool _DeleteSpec(const SdfPath &path);
1979
1980 // Inverse primitive for deleting a spec.
1981 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1982 bool useDelegate = true);
1983
1984 // Inverse primitive for deleting a spec.
1985 void _PrimDeleteSpec(const SdfPath &path, bool inert,
1986 bool useDelegate = true);
1987
1988 // Inverse primitive for setting time samples.
1989 template <class T>
1990 void _PrimSetTimeSample(const SdfPath& path, double time,
1991 const T& value,
1992 bool useDelegate = true);
1993
1994 // Helper method for Traverse. Visits the children of \a path using the
1995 // specified \a ChildPolicy.
1996 template <typename ChildPolicy>
1997 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1998
1999private:
2000 SdfLayerHandle _self;
2001
2002 // File format and arguments for this layer.
2003 SdfFileFormatConstPtr _fileFormat;
2004 FileFormatArguments _fileFormatArgs;
2005
2006 // Cached reference to the _fileFormat's schema -- we need access to this to
2007 // be as fast as possible since we look at it on every SetField(), for
2008 // example.
2009 const SdfSchemaBase &_schema;
2010
2011 // Registry of Sdf Identities
2012 mutable Sdf_IdentityRegistry _idRegistry;
2013
2014 // The underlying SdfData which stores all the data in the layer.
2015 SdfAbstractDataRefPtr _data;
2016
2017 // The state delegate for this layer.
2018 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
2019
2020 // Dispatcher used in layer initialization, letting waiters participate in
2021 // loading instead of just busy-waiting.
2022 WorkDispatcher _initDispatcher;
2023
2024 // Atomic variable protecting layer initialization -- the interval between
2025 // adding a layer to the layer registry and finishing the process of
2026 // initializing its contents, at which point we can truly publish the layer
2027 // for consumption by concurrent threads. We add the layer to the registry
2028 // before initialization completes so that other threads can discover and
2029 // wait for it to finish initializing.
2030 std::atomic<bool> _initializationComplete;
2031
2032 // This is an optional<bool> that is only set once initialization
2033 // is complete, before _initializationComplete is set.
2034 std::optional<bool> _initializationWasSuccessful;
2035
2036 // remembers the last 'IsDirty' state.
2037 mutable bool _lastDirtyState;
2038
2039 // Asset information for this layer.
2040 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
2041
2042 // Modification timestamp of the backing file asset when last read.
2043 mutable VtValue _assetModificationTime;
2044
2045 // All external asset dependencies, with their modification timestamps, of
2046 // the layer when last read.
2047 mutable VtDictionary _externalAssetModificationTimes;
2048
2049 // Mutable revision number for cache invalidation.
2050 mutable size_t _mutedLayersRevisionCache;
2051
2052 // Cache of whether or not this layer is muted. Only valid if
2053 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2054 mutable bool _isMutedCache;
2055
2056 // Layer permission bits.
2057 bool _permissionToEdit;
2058 bool _permissionToSave;
2059
2060 // Whether layer edits are validated.
2061 bool _validateAuthoring;
2062
2063 // Layer hints as of the most recent save operation.
2064 mutable SdfLayerHints _hints;
2065
2066 // Allow access to _ValidateAuthoring() and _IsInert().
2067 friend class SdfSpec;
2068 friend class SdfPropertySpec;
2069 friend class SdfAttributeSpec;
2070
2071 friend class Sdf_ChangeManager;
2072
2073 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2074 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2075
2076 // Give the file format access to our data. Limit breaking encapsulation
2077 // to the base SdFileFormat class so we don't have to friend every
2078 // implementation here.
2079 friend class SdfFileFormat;
2080
2081 // Give layer state delegates access to our data as well as to
2082 // the various _Prim functions.
2083 friend class SdfLayerStateDelegateBase;
2084};
2085
2086PXR_NAMESPACE_CLOSE_SCOPE
2087
2088#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:554
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:512
Interface for scene description data storage.
Definition: abstractData.h:57
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:458
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:399
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:40
A description of an arbitrarily complex namespace edit.
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:1287
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1294
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 SetTimeSample(const SdfPath &path, double time, const VtValue &value)
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
SDF_API void EraseTimeSample(const SdfPath &path, double time)
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 GetNumTimeSamplesForPath(const SdfPath &path) const
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.
void SetTimeSample(const SdfPath &path, double time, const T &value)
Definition: layer.h:1611
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.
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 void SetTimeSample(const SdfPath &path, double time, const SdfAbstractDataConstValue &value)
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
SDF_API void ClearRelocates()
Clears the layer relocates opinion in the layer's metadata.
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
SDF_API SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
SDF_API void SetRelocates(const SdfRelocates &relocates)
Set the entire list of namespace relocations specified on this layer to relocates.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
SDF_API void Clear()
Clears the layer of all content.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API void SetExpressionVariables(const VtDictionary &expressionVars)
Sets the expression variables dictionary for this layer.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
SDF_API std::string GetComment() const
Returns the comment string for this layer.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
SDF_API bool HasExpressionVariables() const
Returns true if expression variables are authored on this layer.
SDF_API void ClearExpressionVariables()
Clears the expression variables dictionary authored on this layer.
SDF_API SdfChangeList CreateDiff(const SdfLayerHandle &layer, bool processPropertyFields=true) const
Returns a SdfChangeList containing the minimal edits that would be needed to transform this layer to ...
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Return the value for the given path and fieldName.
Definition: layer.h:669
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
Adds a new root prim at the given index.
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
SDF_API bool Reload(bool force=false)
Reloads the layer from its persistent representation.
SDF_API void ClearColorManagementSystem()
Clears the 'colorManagementSystem' metadata authored in this layer.
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
Inserts new sublayer path at the given index.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API bool GetBracketingTimeSamplesForPath(const SdfPath &path, double time, double *tLower, double *tUpper)
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.
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 std::set< double > ListTimeSamplesForPath(const SdfPath &path) const
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...
bool QueryTimeSample(const SdfPath &path, double time, T *data) const
Definition: layer.h:1578
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API bool QueryTimeSample(const SdfPath &path, double time, SdfAbstractDataValue *value) const
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
SDF_API bool QueryTimeSample(const SdfPath &path, double time, VtValue *value=NULL) const
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier for a given file format class.
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
SDF_API void ClearOwner()
Clear the owner opinion.
SDF_API bool HasRelocates() const
Returns true if this layer's metadata has any relocates opinion, including that there should be no re...
Represents a time offset and scale between layers.
Definition: layerOffset.h:44
Maintains authoring state information for an associated layer.
Represents a single list of list editing operations.
Definition: listProxy.h:37
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:43
Class defining various attributes for a field.
Definition: schema.h:56
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:45
Base class for all Sdf spec classes.
Definition: spec.h:33
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:66
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:45
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
Result
Validity of an edit.
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:68
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
Definition: types.h:274