Loading...
Searching...
No Matches
layer.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_USD_SDF_LAYER_H
25#define PXR_USD_SDF_LAYER_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/sdf/api.h"
31#include "pxr/usd/sdf/data.h"
33#include "pxr/usd/sdf/identity.h"
34#include "pxr/usd/sdf/layerHints.h"
37#include "pxr/usd/sdf/path.h"
38#include "pxr/usd/sdf/proxyTypes.h"
39#include "pxr/usd/sdf/spec.h"
40#include "pxr/usd/sdf/types.h"
41#include "pxr/usd/ar/ar.h"
45#include "pxr/base/vt/value.h"
47
48#include <atomic>
49#include <functional>
50#include <memory>
51#include <optional>
52#include <set>
53#include <string>
54#include <vector>
55
56PXR_NAMESPACE_OPEN_SCOPE
57
60
61struct Sdf_AssetInfo;
62
98 : public TfRefBase
99 , public TfWeakBase
100{
101public:
103 SDF_API
104 virtual ~SdfLayer();
105
107 SdfLayer(const SdfLayer&) = delete;
108 SdfLayer& operator=(const SdfLayer&) = delete;
109
113
116 SDF_API const SdfSchemaBase& GetSchema() const;
117
119 SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
120
123 typedef std::map<std::string, std::string> FileFormatArguments;
124
128
134 SDF_API
135 static SdfLayerRefPtr CreateNew(const std::string &identifier,
136 const FileFormatArguments &args =
138
145 SDF_API
146 static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
147 const std::string &identifier,
148 const FileFormatArguments &args =
150
159 SDF_API
160 static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
161 const std::string &identifier,
162 const FileFormatArguments &args =
164
171 SDF_API
172 static SdfLayerHandle Find(
173 const std::string &identifier,
175
186 SDF_API
187 static SdfLayerHandle FindRelativeToLayer(
188 const SdfLayerHandle &anchor,
189 const std::string &identifier,
191
198 SDF_API
200 const std::string &identifier,
202
213 SDF_API
215 const SdfLayerHandle &anchor,
216 const std::string &identifier,
218
232 SDF_API
234 const std::string &layerPath,
235 bool metadataOnly = false,
236 const std::string& tag = std::string());
237
239 SDF_API
240 SdfDataRefPtr GetMetadata() const;
241
245 SDF_API
247
249 SDF_API
250 static SdfLayerHandleSet GetLoadedLayers();
251
253 SDF_API
254 bool IsEmpty() const;
255
263 SDF_API
264 bool StreamsData() const;
265
271 SDF_API
272 bool IsDetached() const;
273
276 SDF_API
277 void TransferContent(const SdfLayerHandle& layer);
278
293 SDF_API
295 const std::string& tag = std::string(),
297
299 SDF_API
301 const std::string &tag, const SdfFileFormatConstPtr &format,
303
305 SDF_API
306 bool IsAnonymous() const;
307
310 SDF_API
311 static bool IsAnonymousLayerIdentifier(const std::string& identifier);
312
315 SDF_API
317 const std::string& identifier);
318
322
327 SDF_API
328 bool Save(bool force = false) const;
329
342 SDF_API
343 bool Export(const std::string& filename,
344 const std::string& comment = std::string(),
345 const FileFormatArguments& args = FileFormatArguments()) const;
346
351 SDF_API
352 bool ExportToString(std::string* result) const;
353
357 SDF_API
358 bool ImportFromString(const std::string &string);
359
367 SDF_API
368 void Clear();
369
391 SDF_API
392 bool Reload(bool force = false);
393
400 SDF_API
401 static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
402 bool force = false);
403
409 SDF_API
410 bool Import(const std::string &layerPath);
411
415
418 SDF_API
419 std::set<std::string> GetExternalReferences() const;
420
423 SDF_API
425 const std::string &oldAssetPath,
426 const std::string &newAssetPath=std::string());
427
435 SDF_API
436 std::set<std::string> GetCompositionAssetDependencies() const;
437
447 SDF_API
449 const std::string &oldAssetPath,
450 const std::string &newAssetPath=std::string());
451
460 SDF_API
461 std::set<std::string> GetExternalAssetDependencies() const;
462
482
485 SDF_API
486 static bool SplitIdentifier(
487 const std::string& identifier,
488 std::string* layerPath,
489 FileFormatArguments* arguments);
490
492 SDF_API
493 static std::string CreateIdentifier(
494 const std::string& layerPath,
495 const FileFormatArguments& arguments);
496
498 SDF_API
499 const std::string& GetIdentifier() const;
500
504 SDF_API
505 void SetIdentifier(const std::string& identifier);
506
511 SDF_API
513
517 SDF_API
518 std::string GetDisplayName() const;
519
522 SDF_API
524
527 SDF_API
528 const std::string& GetRealPath() const;
529
534 SDF_API
535 std::string GetFileExtension() const;
536
542 SDF_API
543 const std::string& GetVersion() const;
544
549 SDF_API
550 const std::string& GetRepositoryPath() const;
551
553 SDF_API
554 const std::string& GetAssetName() const;
555
558 SDF_API
559 const VtValue& GetAssetInfo() const;
560
576 SDF_API
577 std::string ComputeAbsolutePath(const std::string& assetPath) const;
578
580
591
594 SDF_API
595 SdfSpecType GetSpecType(const SdfPath& path) const;
596
598 SDF_API
599 bool HasSpec(const SdfPath& path) const;
600
602 SDF_API
603 std::vector<TfToken> ListFields(const SdfPath& path) const;
604
607 SDF_API
608 bool HasField(const SdfPath& path, const TfToken& fieldName,
609 VtValue *value=NULL) const;
610 SDF_API
611 bool HasField(const SdfPath& path, const TfToken& fieldName,
612 SdfAbstractDataValue *value) const;
613
617 template <class T>
618 bool HasField(const SdfPath& path, const TfToken &name,
619 T* value) const
620 {
621 if (!value) {
622 return HasField(path, name, static_cast<VtValue *>(NULL));
623 }
624
625 SdfAbstractDataTypedValue<T> outValue(value);
626 const bool hasValue = HasField(
627 path, name, static_cast<SdfAbstractDataValue *>(&outValue));
628
629 if (std::is_same<T, SdfValueBlock>::value) {
630 return hasValue && outValue.isValueBlock;
631 }
632
633 return hasValue && (!outValue.isValueBlock);
634 }
635
638 std::type_info const &GetFieldTypeid(
639 const SdfPath &path, const TfToken &name) const {
640 return _data->GetTypeid(path, name);
641 }
642
646 SDF_API
647 bool HasFieldDictKey(const SdfPath& path,
648 const TfToken &fieldName,
649 const TfToken &keyPath,
650 VtValue *value=NULL) const;
651 SDF_API
652 bool HasFieldDictKey(const SdfPath& path,
653 const TfToken &fieldName,
654 const TfToken &keyPath,
655 SdfAbstractDataValue *value) const;
656
661 template <class T>
662 bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
663 const TfToken &keyPath, T* value) const
664 {
665 if (!value) {
666 return HasFieldDictKey(path, name, keyPath,
667 static_cast<VtValue *>(NULL));
668 }
669
670 SdfAbstractDataTypedValue<T> outValue(value);
671 return HasFieldDictKey(path, name, keyPath,
672 static_cast<SdfAbstractDataValue *>(&outValue));
673 }
674
675
678 SDF_API
680 const TfToken& fieldName) const;
681
684 template <class T>
685 inline T GetFieldAs(const SdfPath& path,
686 const TfToken& fieldName, const T& defaultValue = T()) const
687 {
688 return _data->GetAs<T>(path, fieldName, defaultValue);
689 }
690
694 SDF_API
696 const TfToken& fieldName,
697 const TfToken& keyPath) const;
698
700 SDF_API
701 void SetField(const SdfPath& path, const TfToken& fieldName,
702 const VtValue& value);
703 SDF_API
704 void SetField(const SdfPath& path, const TfToken& fieldName,
705 const SdfAbstractDataConstValue& value);
706
708 template <class T>
709 void SetField(const SdfPath& path, const TfToken& fieldName,
710 const T& val)
711 {
712 // Ideally, this would make use of the SdfAbstractDataConstValue
713 // API to avoid unnecessarily copying the value into a VtValue.
714 // However, Sdf needs to create a VtValue for change processing.
715 // If the underlying SdAbstractData implementation also needs a
716 // VtValue, using the SdfAbstractDataConstValue API would cause
717 // another copy to be made. So, it's more efficient to just create
718 // the VtValue once here and push that along.
719 SetField(path, fieldName, VtValue(val));
720 }
721
724 SDF_API
726 const TfToken& fieldName,
727 const TfToken& keyPath,
728 const VtValue& value);
729 SDF_API
730 void SetFieldDictValueByKey(const SdfPath& path,
731 const TfToken& fieldName,
732 const TfToken& keyPath,
733 const SdfAbstractDataConstValue& value);
734
737 template <class T>
739 const TfToken& fieldName,
740 const TfToken& keyPath,
741 const T& val)
742 {
743 // Ideally, this would make use of the SdfAbstractDataConstValue
744 // API to avoid unnecessarily copying the value into a VtValue.
745 // However, Sdf needs to create a VtValue for change processing.
746 // If the underlying SdAbstractData implementation also needs
747 // VtValue, using the SdfAbstractDataConstValue API would cause
748 // another copy to be made. So, it's more efficient to just create
749 // the VtValue once here and push that along.
750 SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
751 }
752
754 SDF_API
755 void EraseField(const SdfPath& path, const TfToken& fieldName);
756
760 SDF_API
762 const TfToken& fieldName,
763 const TfToken& keyPath);
764
767
771 typedef std::function<void(const SdfPath&)> TraversalFunction;
772
773 // Traverse will perform a traversal of the scene description hierarchy
774 // rooted at \a path, calling \a func on each spec that it finds.
775 SDF_API
776 void Traverse(const SdfPath& path, const TraversalFunction& func);
777
779
782
786 SDF_API
788
790 SDF_API
791 void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
792
795 SDF_API
797
800 SDF_API
802
810 SDF_API
812
815 SDF_API
817
820 SDF_API
822
825 SDF_API
827
831 SDF_API
832 std::string GetComment() const;
833
835 SDF_API
836 void SetComment(const std::string &comment);
837
843 SDF_API
845
851 SDF_API
852 void SetDefaultPrim(const TfToken &name);
853
856 SDF_API
858
861 SDF_API
863
867 SDF_API
868 std::string GetDocumentation() const;
869
871 SDF_API
872 void SetDocumentation(const std::string &documentation);
873
881 SDF_API
882 double GetStartTimeCode() const;
883
885 SDF_API
886 void SetStartTimeCode(double startTimecode);
887
889 SDF_API
890 bool HasStartTimeCode() const;
891
893 SDF_API
895
902 SDF_API
903 double GetEndTimeCode() const;
904
906 SDF_API
907 void SetEndTimeCode(double endTimeCode);
908
910 SDF_API
911 bool HasEndTimeCode() const;
912
914 SDF_API
916
931 SDF_API
932 double GetTimeCodesPerSecond() const;
933
935 SDF_API
936 void SetTimeCodesPerSecond(double timeCodesPerSecond);
937
939 SDF_API
941
943 SDF_API
945
955 SDF_API
956 double GetFramesPerSecond() const;
957
959 SDF_API
960 void SetFramesPerSecond(double framesPerSecond);
961
963 SDF_API
964 bool HasFramesPerSecond() const;
965
967 SDF_API
969
971 SDF_API
972 int GetFramePrecision() const;
973
975 SDF_API
976 void SetFramePrecision(int framePrecision);
977
979 SDF_API
980 bool HasFramePrecision() const;
981
983 SDF_API
985
987 SDF_API
988 std::string GetOwner() const;
989
991 SDF_API
992 void SetOwner(const std::string& owner);
993
995 SDF_API
996 bool HasOwner() const;
997
999 SDF_API
1001
1004 SDF_API
1005 std::string GetSessionOwner() const;
1006
1009 SDF_API
1010 void SetSessionOwner(const std::string& owner);
1011
1013 SDF_API
1014 bool HasSessionOwner() const;
1015
1016 // Clear the session owner opinion.
1017 SDF_API
1018 void ClearSessionOwner();
1019
1021 SDF_API
1023
1025 SDF_API
1027
1033 SDF_API
1035
1037 SDF_API
1039
1041 SDF_API
1043
1045 SDF_API
1047
1050 SDF_API
1052
1054 SDF_API
1055 void SetExpressionVariables(const VtDictionary& expressionVars);
1056
1058 SDF_API
1060
1062 SDF_API
1064
1068
1069 // Type for root prims view.
1071
1073 SDF_API
1075
1080 SDF_API
1081 void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1082
1088 SDF_API
1089 bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1090
1092 SDF_API
1093 void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1094
1097 SDF_API
1099
1112 SDF_API
1113 void RemovePrimIfInert(SdfPrimSpecHandle prim);
1114
1121 SDF_API
1122 void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1123
1129 SDF_API
1131
1136 SDF_API
1138
1147 SDF_API
1148 void SetRootPrimOrder(const std::vector<TfToken>& names);
1149
1152 SDF_API
1153 void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1154
1156 SDF_API
1158
1160 SDF_API
1162
1168 SDF_API
1169 void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1170
1174
1187 SDF_API
1189
1191 SDF_API
1192 void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1193
1195 SDF_API
1196 size_t GetNumSubLayerPaths() const;
1197
1201 SDF_API
1202 void InsertSubLayerPath(const std::string& path, int index = -1);
1203
1205 SDF_API
1206 void RemoveSubLayerPath(int index);
1207
1209 SDF_API
1210 SdfLayerOffsetVector GetSubLayerOffsets() const;
1211
1213 SDF_API
1215
1217 SDF_API
1218 void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1219
1223
1232 SDF_API
1234
1237 SDF_API
1238 void SetRelocates(const SdfRelocates& relocates);
1239
1244 SDF_API
1245 bool HasRelocates() const;
1246
1248 SDF_API
1250
1252
1273
1290 {
1291 public:
1295
1298 {
1299 _includeAll = true;
1300 _include.clear();
1301 return *this;
1302 }
1303
1306 SDF_API
1307 DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1308
1311 SDF_API
1312 DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1313
1314 bool IncludedAll() const { return _includeAll; }
1315 const std::vector<std::string>& GetIncluded() const { return _include; }
1316 const std::vector<std::string>& GetExcluded() const { return _exclude; }
1317
1325 SDF_API
1326 bool IsIncluded(const std::string& identifier) const;
1327
1328 private:
1329 friend class SdfLayer;
1330
1331 std::vector<std::string> _include;
1332 std::vector<std::string> _exclude;
1333 bool _includeAll = false;
1334 };
1335
1358 SDF_API
1360
1362 SDF_API
1364
1368 SDF_API
1369 static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1370
1372
1375
1377 SDF_API
1378 static std::set<std::string> GetMutedLayers();
1379
1381 SDF_API
1382 bool IsMuted() const;
1383
1385 SDF_API
1386 static bool IsMuted(const std::string &path);
1387
1390 SDF_API
1391 void SetMuted(bool muted);
1392
1394 SDF_API
1395 static void AddToMutedLayers(const std::string &mutedPath);
1396
1398 SDF_API
1399 static void RemoveFromMutedLayers(const std::string &mutedPath);
1400
1404
1413 SDF_API
1414 SdfPrimSpecHandle GetPseudoRoot() const;
1415
1422 SDF_API
1423 SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1424
1430 SDF_API
1431 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1432
1438 SDF_API
1439 SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1440
1446 SDF_API
1447 SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1448
1454 SDF_API
1455 SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1456
1460
1464 SDF_API
1465 bool PermissionToEdit() const;
1466
1469 SDF_API
1470 bool PermissionToSave() const;
1471
1473 SDF_API
1474 void SetPermissionToEdit(bool allow);
1475
1477 SDF_API
1478 void SetPermissionToSave(bool allow);
1479
1483
1507 SDF_API
1510 SdfNamespaceEditDetailVector* details = NULL) const;
1511
1515 SDF_API
1517
1521
1524 SDF_API
1525 SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1526
1530 SDF_API
1531 void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1532
1535 SDF_API
1536 bool IsDirty() const;
1537
1539
1542 SDF_API
1543 std::set<double> ListAllTimeSamples() const;
1544
1545 SDF_API
1546 std::set<double>
1547 ListTimeSamplesForPath(const SdfPath& path) const;
1548
1549 SDF_API
1550 bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1551
1552 SDF_API
1553 size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1554
1555 SDF_API
1556 bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1557 double time,
1558 double* tLower, double* tUpper);
1559
1560 SDF_API
1561 bool QueryTimeSample(const SdfPath& path, double time,
1562 VtValue *value=NULL) const;
1563 SDF_API
1564 bool QueryTimeSample(const SdfPath& path, double time,
1565 SdfAbstractDataValue *value) const;
1566
1567 template <class T>
1568 bool QueryTimeSample(const SdfPath& path, double time,
1569 T* data) const
1570 {
1571 if (!data) {
1572 return QueryTimeSample(path, time);
1573 }
1574
1575 SdfAbstractDataTypedValue<T> outValue(data);
1576 const bool hasValue = QueryTimeSample(
1577 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1578
1579 if (std::is_same<T, SdfValueBlock>::value) {
1580 return hasValue && outValue.isValueBlock;
1581 }
1582
1583 return hasValue && (!outValue.isValueBlock);
1584 }
1585
1586 SDF_API
1587 void SetTimeSample(const SdfPath& path, double time,
1588 const VtValue & value);
1589 SDF_API
1590 void SetTimeSample(const SdfPath& path, double time,
1591 const SdfAbstractDataConstValue& value);
1592
1593 template <class T>
1594 void SetTimeSample(const SdfPath& path, double time,
1595 const T& value)
1596 {
1597 const SdfAbstractDataConstTypedValue<T> inValue(&value);
1598 const SdfAbstractDataConstValue& untypedInValue = inValue;
1599 return SetTimeSample(path, time, untypedInValue);
1600 }
1601
1602 SDF_API
1603 void EraseTimeSample(const SdfPath& path, double time);
1604
1606
1607 // Debugging
1608 // @{
1609
1610 SDF_API
1611 static void DumpLayerInfo();
1612
1613 // Write this layer's SdfData to a file in a simple generic format.
1614 SDF_API
1615 bool WriteDataFile(const std::string &filename);
1616
1617 // @}
1618
1619protected:
1620 // Private constructor -- use New(), FindOrCreate(), etc.
1621 // Precondition: _layerRegistryMutex must be locked.
1622 SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1623 const std::string &identifier,
1624 const std::string &realPath = std::string(),
1625 const ArAssetInfo& assetInfo = ArAssetInfo(),
1627 bool validateAuthoring = false);
1628
1629private:
1630 // Create a new layer.
1631 // Precondition: _layerRegistryMutex must be locked.
1632 static SdfLayerRefPtr _CreateNew(
1633 SdfFileFormatConstPtr fileFormat,
1634 const std::string& identifier,
1635 const FileFormatArguments& args,
1636 bool saveLayer = true);
1637
1638 static SdfLayerRefPtr _CreateNewWithFormat(
1639 const SdfFileFormatConstPtr &fileFormat,
1640 const std::string& identifier,
1641 const std::string& realPath,
1642 const ArAssetInfo& assetInfo = ArAssetInfo(),
1644
1645 static SdfLayerRefPtr _CreateAnonymousWithFormat(
1646 const SdfFileFormatConstPtr &fileFormat,
1647 const std::string& tag,
1648 const FileFormatArguments& args);
1649
1650 // Finish initializing this layer (which may have succeeded or not)
1651 // and publish the results to other threads by unlocking the mutex.
1652 // Sets _initializationWasSuccessful.
1653 void _FinishInitialization(bool success);
1654
1655 // Layers retrieved from the layer registry may still be in the
1656 // process of having their contents initialized. Other threads
1657 // retrieving layers from the registry must wait until initialization
1658 // is complete, using this method.
1659 // Returns _initializationWasSuccessful.
1660 //
1661 // Callers *must* be holding an SdfLayerRefPtr to this layer to
1662 // ensure that it is not deleted out from under them, in
1663 // case initialization fails. (This method cannot acquire the
1664 // reference itself internally without being susceptible to a race.)
1665 bool _WaitForInitializationAndCheckIfSuccessful();
1666
1667 // Returns whether or not this layer should post change
1668 // notification. This simply returns (!_GetIsLoading())
1669 bool _ShouldNotify() const;
1670
1671 // This function keeps track of the last state of IsDirty() before
1672 // updating it. It returns false if the last saved dirty state is the
1673 // same than the current state. It returns true if the state differs and
1674 // will update the 'last dirty state' to the current state. So, after
1675 // returning true, it would return false for subsequent calls until the
1676 // IsDirty() state would change again...
1677 bool _UpdateLastDirtinessState() const;
1678
1679 // Returns a handle to the spec at the given path if it exists and matches
1680 // type T.
1681 template <class T>
1682 SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1683
1684 // Returns true if a spec can be retrieved at the given path, false
1685 // otherwise. This function will return the canonicalized path to the
1686 // spec as well as the spec type.
1687 bool _CanGetSpecAtPath(const SdfPath& path,
1688 SdfPath* canonicalPath, SdfSpecType* specType) const;
1689
1693 void _InitializeFromIdentifier(
1694 const std::string &identifier,
1695 const std::string &realPath = std::string(),
1696 const std::string &fileVersion = std::string(),
1697 const ArAssetInfo& assetInfo = ArAssetInfo());
1698
1699 // Helper for computing the necessary information to lookup a layer
1700 // in the registry or open the layer.
1701 struct _FindOrOpenLayerInfo;
1702 static bool _ComputeInfoToFindOrOpenLayer(
1703 const std::string& identifier,
1705 _FindOrOpenLayerInfo* info,
1706 bool computeAssetInfo = false);
1707
1708 // Open a layer, adding an entry to the registry and releasing
1709 // the registry lock.
1710 // Precondition: _layerRegistryMutex must be locked.
1711 template <class Lock>
1712 static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1713 Lock &lock,
1714 const _FindOrOpenLayerInfo& info,
1715 bool metadataOnly);
1716
1717 // Helper function for finding a layer with \p identifier and \p args.
1718 // \p lock must be unlocked initially and will be locked by this
1719 // function when needed. See docs for \p retryAsWriter argument on
1720 // _TryToFindLayer for details on the final state of the lock when
1721 // this function returns.
1722 template <class ScopedLock>
1723 static SdfLayerRefPtr
1724 _Find(const std::string &identifier,
1725 const FileFormatArguments &args,
1726 ScopedLock &lock, bool retryAsWriter);
1727
1728 // Helper function to try to find the layer with \p identifier and
1729 // pre-resolved path \p resolvedPath in the registry. Caller must hold
1730 // registry \p lock for reading. If \p retryAsWriter is false, lock is
1731 // released upon return. Otherwise the lock is released upon return if a
1732 // layer is found successfully. If no layer is found then the lock is
1733 // upgraded to a writer lock upon return. Note that this upgrade may not be
1734 // atomic, but this function ensures that if upon return there does not
1735 // exist a matching layer in the registry.
1736 template <class ScopedLock>
1737 static SdfLayerRefPtr
1738 _TryToFindLayer(const std::string &identifier,
1739 const ArResolvedPath &resolvedPath,
1740 ScopedLock &lock, bool retryAsWriter);
1741
1749 bool _IsInert(const SdfPath &path, bool ignoreChildren,
1750 bool requiredFieldOnlyPropertiesAreInert = false) const;
1751
1755 bool _IsInertSubtree(const SdfPath &path) const;
1756
1762 void _RemoveIfInert(const SdfSpec& spec);
1763
1768 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1769
1772 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1773
1775 bool _ValidateAuthoring() const { return _validateAuthoring; }
1776
1778 std::string _GetMutedPath() const;
1779
1780 // If old and new asset path is given, rename all external prim
1781 // composition dependency referring to the old path.
1782 void _UpdatePrimCompositionDependencyPaths(
1783 const SdfPrimSpecHandle &parent,
1784 const std::string &oldLayerPath,
1785 const std::string &newLayerPath);
1786
1787 // Set the clean state to the current state.
1788 void _MarkCurrentStateAsClean() const;
1789
1790 // Return the field definition for \p fieldName if \p fieldName is a
1791 // required field for the spec type identified by \p path.
1792 inline SdfSchema::FieldDefinition const *
1793 _GetRequiredFieldDef(const SdfPath &path,
1794 const TfToken &fieldName,
1795 SdfSpecType specType = SdfSpecTypeUnknown) const;
1796
1797 // Return the field definition for \p fieldName if \p fieldName is a
1798 // required field for \p specType subject to \p schema.
1799 static inline SdfSchema::FieldDefinition const *
1800 _GetRequiredFieldDef(const SdfSchemaBase &schema,
1801 const TfToken &fieldName,
1802 SdfSpecType specType);
1803
1804 // Helper to list all fields on \p data at \p path subject to \p schema.
1805 static std::vector<TfToken>
1806 _ListFields(SdfSchemaBase const &schema,
1807 SdfAbstractData const &data, const SdfPath& path);
1808
1809 // Helper for HasField for \p path in \p data subject to \p schema.
1810 static inline bool
1811 _HasField(const SdfSchemaBase &schema,
1812 const SdfAbstractData &data,
1813 const SdfPath& path,
1814 const TfToken& fieldName,
1815 VtValue *value);
1816
1817 // Helper to get a field value for \p path in \p data subject to \p schema.
1818 static inline VtValue
1819 _GetField(const SdfSchemaBase &schema,
1820 const SdfAbstractData &data,
1821 const SdfPath& path,
1822 const TfToken& fieldName);
1823
1824 // Set a value.
1825 template <class T>
1826 void _SetValue(const TfToken& key, T value);
1827
1828 // Get a value.
1829 template <class T>
1830 T _GetValue(const TfToken& key) const;
1831
1832 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1833 _ReloadResult _Reload(bool force);
1834
1835 // Reads contents of asset specified by \p identifier with resolved
1836 // path \p resolvedPath into this layer.
1837 bool _Read(const std::string& identifier,
1838 const ArResolvedPath& resolvedPath,
1839 bool metadataOnly);
1840
1841 // Saves this layer if it is dirty or the layer doesn't already exist
1842 // on disk. If \p force is true, the layer will be written out
1843 // regardless of those conditions.
1844 bool _Save(bool force) const;
1845
1846 // A helper method used by Save and Export.
1847 // This method allows Save to specify the existing file format and Export
1848 // to use the format provided by the file extension in newFileName. If no
1849 // file format can be discovered from the file name, the existing file
1850 // format associated with the layer will be used in both cases. This allows
1851 // users to export and save to any file name, regardless of extension.
1852 bool _WriteToFile(const std::string& newFileName,
1853 const std::string& comment,
1854 SdfFileFormatConstPtr fileFormat,
1855 const FileFormatArguments& args) const;
1856
1857 // Swap contents of _data and data. This operation does not register
1858 // inverses or emit change notification.
1859 void _SwapData(SdfAbstractDataRefPtr &data);
1860
1861 // Set _data to \p newData and send coarse DidReplaceLayerContent
1862 // invalidation notice.
1863 void _AdoptData(const SdfAbstractDataRefPtr &newData);
1864
1865 // Set _data to match data, calling other primitive setter methods to
1866 // provide fine-grained inverses and notification. If \p data might adhere
1867 // to a different schema than this layer's, pass a pointer to it as \p
1868 // newDataSchema. In this case, check to see if fields from \p data are
1869 // known to this layer's schema, and if not, omit them and issue a TfError
1870 // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1871 // known fields.
1872 void _SetData(const SdfAbstractDataPtr &newData,
1873 const SdfSchemaBase *newDataSchema=nullptr);
1874
1875 // Returns const handle to _data.
1876 SdfAbstractDataConstPtr _GetData() const;
1877
1878 // Returns a new SdfAbstractData object for this layer.
1879 SdfAbstractDataRefPtr _CreateData() const;
1880
1881 // Inverse primitive for setting a single field. The previous value for the
1882 // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1883 // VtValue it points to will be moved-from after the function completes. If
1884 // \p oldValue is nullptr, the old field value will be retrieved
1885 // automatically.
1886 template <class T>
1887 void _PrimSetField(const SdfPath& path,
1888 const TfToken& fieldName,
1889 const T& value,
1890 VtValue *oldValue = nullptr,
1891 bool useDelegate = true);
1892
1893 // Inverse primitive for setting a single key in a dict-valued field. The
1894 // previous dictionary value for the field (*not* the individual entry) may
1895 // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1896 // it points to will be moved-from after the function completes. If \p
1897 // oldValue is nullptr, the old field value will be retrieved automatically.
1898 template <class T>
1899 void _PrimSetFieldDictValueByKey(const SdfPath& path,
1900 const TfToken& fieldName,
1901 const TfToken& keyPath,
1902 const T& value,
1903 VtValue *oldValue = nullptr,
1904 bool useDelegate = true);
1905
1906 // Primitive for appending a child to the list of children.
1907 template <class T>
1908 void _PrimPushChild(const SdfPath& parentPath,
1909 const TfToken& fieldName,
1910 const T& value,
1911 bool useDelegate = true);
1912 template <class T>
1913 void _PrimPopChild(const SdfPath& parentPath,
1914 const TfToken& fieldName,
1915 bool useDelegate = true);
1916
1917 // Move all the fields at all paths at or below \a oldPath to be
1918 // at a corresponding location at or below \a newPath. This does
1919 // not update the children fields of the parents of these paths.
1920 bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1921
1922 // Inverse primitive for moving a spec.
1923 void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1924 bool useDelegate = true);
1925
1926 // Create a new spec of type \p specType at \p path.
1927 // Returns true if spec was successfully created, false otherwise.
1928 bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1929
1930 // Delete all the fields at or below the specified path. This does
1931 // not update the children field of the parent of \a path.
1932 bool _DeleteSpec(const SdfPath &path);
1933
1934 // Inverse primitive for deleting a spec.
1935 void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1936 bool useDelegate = true);
1937
1938 // Inverse primitive for deleting a spec.
1939 void _PrimDeleteSpec(const SdfPath &path, bool inert,
1940 bool useDelegate = true);
1941
1942 // Inverse primitive for setting time samples.
1943 template <class T>
1944 void _PrimSetTimeSample(const SdfPath& path, double time,
1945 const T& value,
1946 bool useDelegate = true);
1947
1948 // Helper method for Traverse. Visits the children of \a path using the
1949 // specified \a ChildPolicy.
1950 template <typename ChildPolicy>
1951 void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1952
1953private:
1954 SdfLayerHandle _self;
1955
1956 // File format and arguments for this layer.
1957 SdfFileFormatConstPtr _fileFormat;
1958 FileFormatArguments _fileFormatArgs;
1959
1960 // Cached reference to the _fileFormat's schema -- we need access to this to
1961 // be as fast as possible since we look at it on every SetField(), for
1962 // example.
1963 const SdfSchemaBase &_schema;
1964
1965 // Registry of Sdf Identities
1966 mutable Sdf_IdentityRegistry _idRegistry;
1967
1968 // The underlying SdfData which stores all the data in the layer.
1969 SdfAbstractDataRefPtr _data;
1970
1971 // The state delegate for this layer.
1972 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1973
1974 // Dispatcher used in layer initialization, letting waiters participate in
1975 // loading instead of just busy-waiting.
1976 WorkDispatcher _initDispatcher;
1977
1978 // Atomic variable protecting layer initialization -- the interval between
1979 // adding a layer to the layer registry and finishing the process of
1980 // initializing its contents, at which point we can truly publish the layer
1981 // for consumption by concurrent threads. We add the layer to the registry
1982 // before initialization completes so that other threads can discover and
1983 // wait for it to finish initializing.
1984 std::atomic<bool> _initializationComplete;
1985
1986 // This is an optional<bool> that is only set once initialization
1987 // is complete, before _initializationComplete is set.
1988 std::optional<bool> _initializationWasSuccessful;
1989
1990 // remembers the last 'IsDirty' state.
1991 mutable bool _lastDirtyState;
1992
1993 // Asset information for this layer.
1994 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1995
1996 // Modification timestamp of the backing file asset when last read.
1997 mutable VtValue _assetModificationTime;
1998
1999 // All external asset dependencies, with their modification timestamps, of
2000 // the layer when last read.
2001 mutable VtDictionary _externalAssetModificationTimes;
2002
2003 // Mutable revision number for cache invalidation.
2004 mutable size_t _mutedLayersRevisionCache;
2005
2006 // Cache of whether or not this layer is muted. Only valid if
2007 // _mutedLayersRevisionCache is up-to-date with the global revision number.
2008 mutable bool _isMutedCache;
2009
2010 // Layer permission bits.
2011 bool _permissionToEdit;
2012 bool _permissionToSave;
2013
2014 // Whether layer edits are validated.
2015 bool _validateAuthoring;
2016
2017 // Layer hints as of the most recent save operation.
2018 mutable SdfLayerHints _hints;
2019
2020 // Allow access to _ValidateAuthoring() and _IsInert().
2021 friend class SdfSpec;
2022 friend class SdfPropertySpec;
2023 friend class SdfAttributeSpec;
2024
2025 friend class Sdf_ChangeManager;
2026
2027 // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
2028 template <class ChildPolicy> friend class Sdf_ChildrenUtils;
2029
2030 // Give the file format access to our data. Limit breaking encapsulation
2031 // to the base SdFileFormat class so we don't have to friend every
2032 // implementation here.
2033 friend class SdfFileFormat;
2034
2035 // Give layer state delegates access to our data as well as to
2036 // the various _Prim functions.
2037 friend class SdfLayerStateDelegateBase;
2038};
2039
2040PXR_NAMESPACE_CLOSE_SCOPE
2041
2042#endif // PXR_USD_SDF_LAYER_H
Contains information about a resolved asset.
Definition: assetInfo.h:42
Represents a resolved asset path.
Definition: resolvedPath.h:40
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:562
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:520
Interface for scene description data storage.
Definition: abstractData.h:74
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:467
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:416
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:57
A description of an arbitrarily complex namespace edit.
Provides a view onto an object's children.
Definition: childrenView.h:222
Base class for file format implementations.
Definition: fileFormat.h:67
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:1290
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1297
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:34
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:100
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:618
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:123
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:738
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
static SDF_API bool SplitIdentifier(const std::string &identifier, std::string *layerPath, FileFormatArguments *arguments)
Splits the given layer identifier into its constituent layer path and arguments.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path for this layer.
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
Returns true if the identifier is an anonymous layer unique identifier.
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API void SetIdentifier(const std::string &identifier)
Sets the layer identifier.
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
Load the given layer from disk as a new anonymous layer.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
SDF_API void ScheduleRemoveIfInert(const SdfSpec &spec)
Cause spec to be removed if it no longer affects the scene when the last change block is closed,...
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
Removes scene description that does not affect the scene in the layer namespace beginning with prim.
static SDF_API SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier for a given file format class.
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
Sets a new vector of root prims.
SDF_API void SetColorManagementSystem(const TfToken &cms)
Sets the color management system used to interpret the color configuration asset-path authored this l...
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API bool HasDefaultPrim()
Return true if the default prim metadata is set in this layer.
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer's pseudo-root prim.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
SDF_API const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
Removes prop if it has only required fields (i.e.
SDF_API bool PermissionToSave() const
Returns true if the caller is allowed to save the layer to its existing fileName and false otherwise.
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName and keyPath.
SDF_API double GetFramesPerSecond() const
Returns the layer's frames per second.
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
Returns the object at the given path.
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
std::type_info const & GetFieldTypeid(const SdfPath &path, const TfToken &name) const
Return the type of the value for name on spec path.
Definition: layer.h:638
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 void UpdateAssetInfo()
Update layer asset information.
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
SDF_API void ClearRelocates()
Clears the layer relocates opinion in the layer's metadata.
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
SDF_API SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
SDF_API void SetRelocates(const SdfRelocates &relocates)
Set the entire list of namespace relocations specified on this layer to relocates.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
SDF_API void Clear()
Clears the layer of all content.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API void SetExpressionVariables(const VtDictionary &expressionVars)
Sets the expression variables dictionary for this layer.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
SDF_API std::string GetComment() const
Returns the comment string for this layer.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
SDF_API bool HasExpressionVariables() const
Returns true if expression variables are authored on this layer.
SDF_API void ClearExpressionVariables()
Clears the expression variables dictionary authored on this layer.
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Return the value for the given path and fieldName.
Definition: layer.h:685
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:709
SDF_API void SetMuted(bool muted)
Mutes the current layer if muted is true, and unmutes it otherwise.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer's authoring state.
SDF_API void ApplyRootPrimOrder(std::vector< TfToken > *vec) const
Reorders the given list of prim names according to the reorder rootPrims statement for this layer.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer's authoring state.
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API double GetStartTimeCode() const
Returns the layer's start timeCode.
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API std::string GetDisplayName() const
Returns the layer's display name.
static SDF_API SdfLayerHandle Find(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args.
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API std::string ComputeAbsolutePath(const std::string &assetPath) const
Returns the path to the asset specified by assetPath using this layer to anchor the path if necessary...
SDF_API void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
Return the value for the given path and fieldName at keyPath.
SDF_API bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
bool HasFieldDictKey(const SdfPath &path, const TfToken &name, const TfToken &keyPath, T *value) const
Returns true if the object has a non-empty value with name name and keyPath and type T.
Definition: layer.h:662
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:771
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:61
Maintains authoring state information for an associated layer.
Represents a single list of list editing operations.
Definition: listProxy.h:54
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:60
Class defining various attributes for a field.
Definition: schema.h:73
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:62
Base class for all Sdf spec classes.
Definition: spec.h:50
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:73
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
A map with string keys and VtValue values.
Definition: dictionary.h:60
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:76
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
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:85
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
Definition: types.h:291