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"
42 #include "pxr/usd/ar/assetInfo.h"
45 #include "pxr/base/vt/value.h"
47 
48 #include <boost/optional.hpp>
49 
50 #include <atomic>
51 #include <functional>
52 #include <memory>
53 #include <set>
54 #include <string>
55 #include <vector>
56 
57 PXR_NAMESPACE_OPEN_SCOPE
58 
61 
62 struct Sdf_AssetInfo;
63 
94 class SdfLayer
95  : public TfRefBase
96  , public TfWeakBase
97 {
98 public:
100  SDF_API
101  virtual ~SdfLayer();
102 
104  SdfLayer(const SdfLayer&) = delete;
105  SdfLayer& operator=(const SdfLayer&) = delete;
106 
110 
113  SDF_API const SdfSchemaBase& GetSchema() const;
114 
116  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
117 
120  typedef std::map<std::string, std::string> FileFormatArguments;
121 
124  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
125 
131  SDF_API
132  static SdfLayerRefPtr CreateNew(const std::string &identifier,
133  const FileFormatArguments &args =
135 
142  SDF_API
143  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
144  const std::string &identifier,
145  const FileFormatArguments &args =
147 
156  SDF_API
157  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
158  const std::string &identifier,
159  const FileFormatArguments &args =
161 
168  SDF_API
169  static SdfLayerHandle Find(
170  const std::string &identifier,
171  const FileFormatArguments &args = FileFormatArguments());
172 
183  SDF_API
184  static SdfLayerHandle FindRelativeToLayer(
185  const SdfLayerHandle &anchor,
186  const std::string &identifier,
187  const FileFormatArguments &args = FileFormatArguments());
188 
195  SDF_API
196  static SdfLayerRefPtr FindOrOpen(
197  const std::string &identifier,
198  const FileFormatArguments &args = FileFormatArguments());
199 
210  SDF_API
212  const SdfLayerHandle &anchor,
213  const std::string &identifier,
214  const FileFormatArguments &args = FileFormatArguments());
215 
229  SDF_API
231  const std::string &layerPath,
232  bool metadataOnly = false,
233  const std::string& tag = std::string());
234 
236  SDF_API
237  SdfDataRefPtr GetMetadata() const;
238 
242  SDF_API
243  SdfLayerHints GetHints() const;
244 
246  SDF_API
247  static SdfLayerHandleSet GetLoadedLayers();
248 
250  SDF_API
251  bool IsEmpty() const;
252 
260  SDF_API
261  bool StreamsData() const;
262 
268  SDF_API
269  bool IsDetached() const;
270 
273  SDF_API
274  void TransferContent(const SdfLayerHandle& layer);
275 
290  SDF_API
292  const std::string& tag = std::string(),
293  const FileFormatArguments& args = FileFormatArguments());
294 
296  SDF_API
298  const std::string &tag, const SdfFileFormatConstPtr &format,
299  const FileFormatArguments& args = FileFormatArguments());
300 
302  SDF_API
303  bool IsAnonymous() const;
304 
307  SDF_API
308  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
309 
312  SDF_API
313  static std::string GetDisplayNameFromIdentifier(
314  const std::string& identifier);
315 
319 
324  SDF_API
325  bool Save(bool force = false) const;
326 
339  SDF_API
340  bool Export(const std::string& filename,
341  const std::string& comment = std::string(),
342  const FileFormatArguments& args = FileFormatArguments()) const;
343 
348  SDF_API
349  bool ExportToString(std::string* result) const;
350 
354  SDF_API
355  bool ImportFromString(const std::string &string);
356 
364  SDF_API
365  void Clear();
366 
388  SDF_API
389  bool Reload(bool force = false);
390 
397  SDF_API
398  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
399  bool force = false);
400 
406  SDF_API
407  bool Import(const std::string &layerPath);
408 
412 
415  SDF_API
416  std::set<std::string> GetExternalReferences() const;
417 
420  SDF_API
422  const std::string &oldAssetPath,
423  const std::string &newAssetPath=std::string());
424 
432  SDF_API
433  std::set<std::string> GetCompositionAssetDependencies() const;
434 
444  SDF_API
446  const std::string &oldAssetPath,
447  const std::string &newAssetPath=std::string());
448 
457  SDF_API
458  std::set<std::string> GetExternalAssetDependencies() const;
459 
479 
482  SDF_API
483  static bool SplitIdentifier(
484  const std::string& identifier,
485  std::string* layerPath,
486  FileFormatArguments* arguments);
487 
489  SDF_API
490  static std::string CreateIdentifier(
491  const std::string& layerPath,
492  const FileFormatArguments& arguments);
493 
495  SDF_API
496  const std::string& GetIdentifier() const;
497 
501  SDF_API
502  void SetIdentifier(const std::string& identifier);
503 
508  SDF_API
509  void UpdateAssetInfo();
510 
514  SDF_API
515  std::string GetDisplayName() const;
516 
519  SDF_API
520  const ArResolvedPath& GetResolvedPath() const;
521 
524  SDF_API
525  const std::string& GetRealPath() const;
526 
531  SDF_API
532  std::string GetFileExtension() const;
533 
539  SDF_API
540  const std::string& GetVersion() const;
541 
546  SDF_API
547  const std::string& GetRepositoryPath() const;
548 
550  SDF_API
551  const std::string& GetAssetName() const;
552 
555  SDF_API
556  const VtValue& GetAssetInfo() const;
557 
573  SDF_API
574  std::string ComputeAbsolutePath(const std::string& assetPath) const;
575 
577 
588 
591  SDF_API
592  SdfSpecType GetSpecType(const SdfPath& path) const;
593 
595  SDF_API
596  bool HasSpec(const SdfPath& path) const;
597 
599  SDF_API
600  std::vector<TfToken> ListFields(const SdfPath& path) const;
601 
604  SDF_API
605  bool HasField(const SdfPath& path, const TfToken& fieldName,
606  VtValue *value=NULL) const;
607  SDF_API
608  bool HasField(const SdfPath& path, const TfToken& fieldName,
609  SdfAbstractDataValue *value) const;
610 
614  template <class T>
615  bool HasField(const SdfPath& path, const TfToken &name,
616  T* value) const
617  {
618  if (!value) {
619  return HasField(path, name, static_cast<VtValue *>(NULL));
620  }
621 
622  SdfAbstractDataTypedValue<T> outValue(value);
623  const bool hasValue = HasField(
624  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
625 
626  if (std::is_same<T, SdfValueBlock>::value) {
627  return hasValue && outValue.isValueBlock;
628  }
629 
630  return hasValue && (!outValue.isValueBlock);
631  }
632 
635  std::type_info const &GetFieldTypeid(
636  const SdfPath &path, const TfToken &name) const {
637  return _data->GetTypeid(path, name);
638  }
639 
643  SDF_API
644  bool HasFieldDictKey(const SdfPath& path,
645  const TfToken &fieldName,
646  const TfToken &keyPath,
647  VtValue *value=NULL) const;
648  SDF_API
649  bool HasFieldDictKey(const SdfPath& path,
650  const TfToken &fieldName,
651  const TfToken &keyPath,
652  SdfAbstractDataValue *value) const;
653 
658  template <class T>
659  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
660  const TfToken &keyPath, T* value) const
661  {
662  if (!value) {
663  return HasFieldDictKey(path, name, keyPath,
664  static_cast<VtValue *>(NULL));
665  }
666 
667  SdfAbstractDataTypedValue<T> outValue(value);
668  return HasFieldDictKey(path, name, keyPath,
669  static_cast<SdfAbstractDataValue *>(&outValue));
670  }
671 
672 
675  SDF_API
676  VtValue GetField(const SdfPath& path,
677  const TfToken& fieldName) const;
678 
681  template <class T>
682  inline T GetFieldAs(const SdfPath& path,
683  const TfToken& fieldName, const T& defaultValue = T()) const
684  {
685  return _data->GetAs<T>(path, fieldName, defaultValue);
686  }
687 
691  SDF_API
693  const TfToken& fieldName,
694  const TfToken& keyPath) const;
695 
697  SDF_API
698  void SetField(const SdfPath& path, const TfToken& fieldName,
699  const VtValue& value);
700  SDF_API
701  void SetField(const SdfPath& path, const TfToken& fieldName,
702  const SdfAbstractDataConstValue& value);
703 
705  template <class T>
706  void SetField(const SdfPath& path, const TfToken& fieldName,
707  const T& val)
708  {
709  // Ideally, this would make use of the SdfAbstractDataConstValue
710  // API to avoid unnecessarily copying the value into a VtValue.
711  // However, Sdf needs to create a VtValue for change processing.
712  // If the underlying SdAbstractData implementation also needs a
713  // VtValue, using the SdfAbstractDataConstValue API would cause
714  // another copy to be made. So, it's more efficient to just create
715  // the VtValue once here and push that along.
716  SetField(path, fieldName, VtValue(val));
717  }
718 
721  SDF_API
722  void SetFieldDictValueByKey(const SdfPath& path,
723  const TfToken& fieldName,
724  const TfToken& keyPath,
725  const VtValue& value);
726  SDF_API
727  void SetFieldDictValueByKey(const SdfPath& path,
728  const TfToken& fieldName,
729  const TfToken& keyPath,
730  const SdfAbstractDataConstValue& value);
731 
734  template <class T>
735  void SetFieldDictValueByKey(const SdfPath& path,
736  const TfToken& fieldName,
737  const TfToken& keyPath,
738  const T& val)
739  {
740  // Ideally, this would make use of the SdfAbstractDataConstValue
741  // API to avoid unnecessarily copying the value into a VtValue.
742  // However, Sdf needs to create a VtValue for change processing.
743  // If the underlying SdAbstractData implementation also needs
744  // VtValue, using the SdfAbstractDataConstValue API would cause
745  // another copy to be made. So, it's more efficient to just create
746  // the VtValue once here and push that along.
747  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
748  }
749 
751  SDF_API
752  void EraseField(const SdfPath& path, const TfToken& fieldName);
753 
757  SDF_API
758  void EraseFieldDictValueByKey(const SdfPath& path,
759  const TfToken& fieldName,
760  const TfToken& keyPath);
761 
764 
768  typedef std::function<void(const SdfPath&)> TraversalFunction;
769 
770  // Traverse will perform a traversal of the scene description hierarchy
771  // rooted at \a path, calling \a func on each spec that it finds.
772  SDF_API
773  void Traverse(const SdfPath& path, const TraversalFunction& func);
774 
776 
779 
783  SDF_API
785 
787  SDF_API
788  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
789 
792  SDF_API
793  bool HasColorConfiguration() const;
794 
797  SDF_API
799 
807  SDF_API
809 
812  SDF_API
813  void SetColorManagementSystem(const TfToken &cms);
814 
817  SDF_API
818  bool HasColorManagementSystem() const;
819 
822  SDF_API
824 
828  SDF_API
829  std::string GetComment() const;
830 
832  SDF_API
833  void SetComment(const std::string &comment);
834 
840  SDF_API
841  TfToken GetDefaultPrim() const;
842 
848  SDF_API
849  void SetDefaultPrim(const TfToken &name);
850 
853  SDF_API
854  void ClearDefaultPrim();
855 
858  SDF_API
859  bool HasDefaultPrim();
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
891  void ClearStartTimeCode();
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
912  void ClearEndTimeCode();
913 
929  SDF_API
930  double GetTimeCodesPerSecond() const;
931 
933  SDF_API
934  void SetTimeCodesPerSecond(double timeCodesPerSecond);
935 
937  SDF_API
938  bool HasTimeCodesPerSecond() const;
939 
941  SDF_API
943 
953  SDF_API
954  double GetFramesPerSecond() const;
955 
957  SDF_API
958  void SetFramesPerSecond(double framesPerSecond);
959 
961  SDF_API
962  bool HasFramesPerSecond() const;
963 
965  SDF_API
966  void ClearFramesPerSecond();
967 
969  SDF_API
970  int GetFramePrecision() const;
971 
973  SDF_API
974  void SetFramePrecision(int framePrecision);
975 
977  SDF_API
978  bool HasFramePrecision() const;
979 
981  SDF_API
982  void ClearFramePrecision();
983 
985  SDF_API
986  std::string GetOwner() const;
987 
989  SDF_API
990  void SetOwner(const std::string& owner);
991 
993  SDF_API
994  bool HasOwner() const;
995 
997  SDF_API
998  void ClearOwner();
999 
1002  SDF_API
1003  std::string GetSessionOwner() const;
1004 
1007  SDF_API
1008  void SetSessionOwner(const std::string& owner);
1009 
1011  SDF_API
1012  bool HasSessionOwner() const;
1013 
1014  // Clear the session owner opinion.
1015  SDF_API
1016  void ClearSessionOwner();
1017 
1019  SDF_API
1020  bool GetHasOwnedSubLayers() const;
1021 
1023  SDF_API
1024  void SetHasOwnedSubLayers(bool);
1025 
1031  SDF_API
1033 
1035  SDF_API
1036  void SetCustomLayerData(const VtDictionary& value);
1037 
1039  SDF_API
1040  bool HasCustomLayerData() const;
1041 
1043  SDF_API
1044  void ClearCustomLayerData();
1045 
1049 
1050  // Type for root prims view.
1052 
1054  SDF_API
1055  RootPrimsView GetRootPrims() const;
1056 
1061  SDF_API
1062  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1063 
1069  SDF_API
1070  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1071 
1073  SDF_API
1074  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1075 
1078  SDF_API
1079  void ScheduleRemoveIfInert(const SdfSpec& spec);
1080 
1093  SDF_API
1094  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1095 
1102  SDF_API
1103  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1104 
1110  SDF_API
1112 
1117  SDF_API
1119 
1128  SDF_API
1129  void SetRootPrimOrder(const std::vector<TfToken>& names);
1130 
1133  SDF_API
1134  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1135 
1137  SDF_API
1138  void RemoveFromRootPrimOrder(const TfToken & name);
1139 
1141  SDF_API
1142  void RemoveFromRootPrimOrderByIndex(int index);
1143 
1149  SDF_API
1150  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1151 
1155 
1168  SDF_API
1170 
1172  SDF_API
1173  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1174 
1176  SDF_API
1177  size_t GetNumSubLayerPaths() const;
1178 
1182  SDF_API
1183  void InsertSubLayerPath(const std::string& path, int index = -1);
1184 
1186  SDF_API
1187  void RemoveSubLayerPath(int index);
1188 
1190  SDF_API
1191  SdfLayerOffsetVector GetSubLayerOffsets() const;
1192 
1194  SDF_API
1195  SdfLayerOffset GetSubLayerOffset(int index) const;
1196 
1198  SDF_API
1199  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1200 
1202 
1223 
1240  {
1241  public:
1244  DetachedLayerRules() = default;
1245 
1248  {
1249  _includeAll = true;
1250  _include.clear();
1251  return *this;
1252  }
1253 
1256  SDF_API
1257  DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1258 
1261  SDF_API
1262  DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1263 
1264  bool IncludedAll() const { return _includeAll; }
1265  const std::vector<std::string>& GetIncluded() const { return _include; }
1266  const std::vector<std::string>& GetExcluded() const { return _exclude; }
1267 
1275  SDF_API
1276  bool IsIncluded(const std::string& identifier) const;
1277 
1278  private:
1279  friend class SdfLayer;
1280 
1281  std::vector<std::string> _include;
1282  std::vector<std::string> _exclude;
1283  bool _includeAll = false;
1284  };
1285 
1308  SDF_API
1309  static void SetDetachedLayerRules(const DetachedLayerRules& mask);
1310 
1312  SDF_API
1313  static const DetachedLayerRules& GetDetachedLayerRules();
1314 
1318  SDF_API
1319  static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1320 
1322 
1325 
1327  SDF_API
1328  static std::set<std::string> GetMutedLayers();
1329 
1331  SDF_API
1332  bool IsMuted() const;
1333 
1335  SDF_API
1336  static bool IsMuted(const std::string &path);
1337 
1340  SDF_API
1341  void SetMuted(bool muted);
1342 
1344  SDF_API
1345  static void AddToMutedLayers(const std::string &mutedPath);
1346 
1348  SDF_API
1349  static void RemoveFromMutedLayers(const std::string &mutedPath);
1350 
1354 
1363  SDF_API
1364  SdfPrimSpecHandle GetPseudoRoot() const;
1365 
1372  SDF_API
1373  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1374 
1380  SDF_API
1381  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1382 
1388  SDF_API
1389  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1390 
1396  SDF_API
1397  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1398 
1404  SDF_API
1405  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1406 
1410 
1414  SDF_API
1415  bool PermissionToEdit() const;
1416 
1419  SDF_API
1420  bool PermissionToSave() const;
1421 
1423  SDF_API
1424  void SetPermissionToEdit(bool allow);
1425 
1427  SDF_API
1428  void SetPermissionToSave(bool allow);
1429 
1433 
1457  SDF_API
1460  SdfNamespaceEditDetailVector* details = NULL) const;
1461 
1465  SDF_API
1466  bool Apply(const SdfBatchNamespaceEdit&);
1467 
1471 
1474  SDF_API
1475  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1476 
1480  SDF_API
1481  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1482 
1485  SDF_API
1486  bool IsDirty() const;
1487 
1489 
1492  SDF_API
1493  std::set<double> ListAllTimeSamples() const;
1494 
1495  SDF_API
1496  std::set<double>
1497  ListTimeSamplesForPath(const SdfPath& path) const;
1498 
1499  SDF_API
1500  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1501 
1502  SDF_API
1503  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1504 
1505  SDF_API
1506  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1507  double time,
1508  double* tLower, double* tUpper);
1509 
1510  SDF_API
1511  bool QueryTimeSample(const SdfPath& path, double time,
1512  VtValue *value=NULL) const;
1513  SDF_API
1514  bool QueryTimeSample(const SdfPath& path, double time,
1515  SdfAbstractDataValue *value) const;
1516 
1517  template <class T>
1518  bool QueryTimeSample(const SdfPath& path, double time,
1519  T* data) const
1520  {
1521  if (!data) {
1522  return QueryTimeSample(path, time);
1523  }
1524 
1525  SdfAbstractDataTypedValue<T> outValue(data);
1526  const bool hasValue = QueryTimeSample(
1527  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1528 
1529  if (std::is_same<T, SdfValueBlock>::value) {
1530  return hasValue && outValue.isValueBlock;
1531  }
1532 
1533  return hasValue && (!outValue.isValueBlock);
1534  }
1535 
1536  SDF_API
1537  void SetTimeSample(const SdfPath& path, double time,
1538  const VtValue & value);
1539  SDF_API
1540  void SetTimeSample(const SdfPath& path, double time,
1541  const SdfAbstractDataConstValue& value);
1542 
1543  template <class T>
1544  void SetTimeSample(const SdfPath& path, double time,
1545  const T& value)
1546  {
1547  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1548  const SdfAbstractDataConstValue& untypedInValue = inValue;
1549  return SetTimeSample(path, time, untypedInValue);
1550  }
1551 
1552  SDF_API
1553  void EraseTimeSample(const SdfPath& path, double time);
1554 
1556 
1557  // Debugging
1558  // @{
1559 
1560  SDF_API
1561  static void DumpLayerInfo();
1562 
1563  // Write this layer's SdfData to a file in a simple generic format.
1564  SDF_API
1565  bool WriteDataFile(const std::string &filename);
1566 
1567  // @}
1568 
1569 protected:
1570  // Private constructor -- use New(), FindOrCreate(), etc.
1571  // Precondition: _layerRegistryMutex must be locked.
1572  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1573  const std::string &identifier,
1574  const std::string &realPath = std::string(),
1575  const ArAssetInfo& assetInfo = ArAssetInfo(),
1576  const FileFormatArguments &args = FileFormatArguments(),
1577  bool validateAuthoring = false);
1578 
1579 private:
1580  // Create a new layer.
1581  // Precondition: _layerRegistryMutex must be locked.
1582  static SdfLayerRefPtr _CreateNew(
1583  SdfFileFormatConstPtr fileFormat,
1584  const std::string& identifier,
1585  const FileFormatArguments& args,
1586  bool saveLayer = true);
1587 
1588  static SdfLayerRefPtr _CreateNewWithFormat(
1589  const SdfFileFormatConstPtr &fileFormat,
1590  const std::string& identifier,
1591  const std::string& realPath,
1592  const ArAssetInfo& assetInfo = ArAssetInfo(),
1593  const FileFormatArguments& args = FileFormatArguments());
1594 
1595  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1596  const SdfFileFormatConstPtr &fileFormat,
1597  const std::string& tag,
1598  const FileFormatArguments& args);
1599 
1600  // Finish initializing this layer (which may have succeeded or not)
1601  // and publish the results to other threads by unlocking the mutex.
1602  // Sets _initializationWasSuccessful.
1603  void _FinishInitialization(bool success);
1604 
1605  // Layers retrieved from the layer registry may still be in the
1606  // process of having their contents initialized. Other threads
1607  // retrieving layers from the registry must wait until initialization
1608  // is complete, using this method.
1609  // Returns _initializationWasSuccessful.
1610  //
1611  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1612  // ensure that it is not deleted out from under them, in
1613  // case initialization fails. (This method cannot acquire the
1614  // reference itself internally without being susceptible to a race.)
1615  bool _WaitForInitializationAndCheckIfSuccessful();
1616 
1617  // Returns whether or not this menv layer should post change
1618  // notification. This simply returns (!_GetIsLoading())
1619  bool _ShouldNotify() const;
1620 
1621  // This function keeps track of the last state of IsDirty() before
1622  // updating it. It returns false if the last saved dirty state is the
1623  // same than the current state. It returns true if the state differs and
1624  // will update the 'last dirty state' to the current state. So, after
1625  // returning true, it would return false for subsequent calls until the
1626  // IsDirty() state would change again...
1627  bool _UpdateLastDirtinessState() const;
1628 
1629  // Returns a handle to the spec at the given path if it exists and matches
1630  // type T.
1631  template <class T>
1632  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1633 
1634  // Returns true if a spec can be retrieved at the given path, false
1635  // otherwise. This function will return the canonicalized path to the
1636  // spec as well as the spec type.
1637  bool _CanGetSpecAtPath(const SdfPath& path,
1638  SdfPath* canonicalPath, SdfSpecType* specType) const;
1639 
1643  void _InitializeFromIdentifier(
1644  const std::string &identifier,
1645  const std::string &realPath = std::string(),
1646  const std::string &fileVersion = std::string(),
1647  const ArAssetInfo& assetInfo = ArAssetInfo());
1648 
1649  // Helper for computing the necessary information to lookup a layer
1650  // in the registry or open the layer.
1651  struct _FindOrOpenLayerInfo;
1652  static bool _ComputeInfoToFindOrOpenLayer(
1653  const std::string& identifier,
1654  const SdfLayer::FileFormatArguments& args,
1655  _FindOrOpenLayerInfo* info,
1656  bool computeAssetInfo = false);
1657 
1658  // Open a layer, adding an entry to the registry and releasing
1659  // the registry lock.
1660  // Precondition: _layerRegistryMutex must be locked.
1661  template <class Lock>
1662  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1663  Lock &lock,
1664  const _FindOrOpenLayerInfo& info,
1665  bool metadataOnly);
1666 
1667  // Helper function for finding a layer with \p identifier and \p args.
1668  // \p lock must be unlocked initially and will be locked by this
1669  // function when needed. See docs for \p retryAsWriter argument on
1670  // _TryToFindLayer for details on the final state of the lock when
1671  // this function returns.
1672  template <class ScopedLock>
1673  static SdfLayerRefPtr
1674  _Find(const std::string &identifier,
1675  const FileFormatArguments &args,
1676  ScopedLock &lock, bool retryAsWriter);
1677 
1678  // Helper function to try to find the layer with \p identifier and
1679  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1680  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1681  // released upon return. Otherwise the lock is released upon return if a
1682  // layer is found successfully. If no layer is found then the lock is
1683  // upgraded to a writer lock upon return. Note that this upgrade may not be
1684  // atomic, but this function ensures that if upon return there does not
1685  // exist a matching layer in the registry.
1686  template <class ScopedLock>
1687  static SdfLayerRefPtr
1688  _TryToFindLayer(const std::string &identifier,
1689  const std::string &resolvedPath,
1690  ScopedLock &lock, bool retryAsWriter);
1691 
1699  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1700  bool requiredFieldOnlyPropertiesAreInert = false) const;
1701 
1705  bool _IsInertSubtree(const SdfPath &path) const;
1706 
1712  void _RemoveIfInert(const SdfSpec& spec);
1713 
1718  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1719 
1722  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1723 
1725  bool _ValidateAuthoring() const { return _validateAuthoring; }
1726 
1728  std::string _GetMutedPath() const;
1729 
1730  // If old and new asset path is given, rename all external prim
1731  // composition dependency referring to the old path.
1732  void _UpdatePrimCompositionDependencyPaths(
1733  const SdfPrimSpecHandle &parent,
1734  const std::string &oldLayerPath,
1735  const std::string &newLayerPath);
1736 
1737  // Set the clean state to the current state.
1738  void _MarkCurrentStateAsClean() const;
1739 
1740  // Return the field definition for \p fieldName if \p fieldName is a
1741  // required field for the spec type identified by \p path.
1742  inline SdfSchema::FieldDefinition const *
1743  _GetRequiredFieldDef(const SdfPath &path,
1744  const TfToken &fieldName,
1745  SdfSpecType specType = SdfSpecTypeUnknown) const;
1746 
1747  // Return the field definition for \p fieldName if \p fieldName is a
1748  // required field for \p specType subject to \p schema.
1749  static inline SdfSchema::FieldDefinition const *
1750  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1751  const TfToken &fieldName,
1752  SdfSpecType specType);
1753 
1754  // Helper to list all fields on \p data at \p path subject to \p schema.
1755  static std::vector<TfToken>
1756  _ListFields(SdfSchemaBase const &schema,
1757  SdfAbstractData const &data, const SdfPath& path);
1758 
1759  // Helper for HasField for \p path in \p data subject to \p schema.
1760  static inline bool
1761  _HasField(const SdfSchemaBase &schema,
1762  const SdfAbstractData &data,
1763  const SdfPath& path,
1764  const TfToken& fieldName,
1765  VtValue *value);
1766 
1767  // Helper to get a field value for \p path in \p data subject to \p schema.
1768  static inline VtValue
1769  _GetField(const SdfSchemaBase &schema,
1770  const SdfAbstractData &data,
1771  const SdfPath& path,
1772  const TfToken& fieldName);
1773 
1774  // Set a value.
1775  template <class T>
1776  void _SetValue(const TfToken& key, T value);
1777 
1778  // Get a value.
1779  template <class T>
1780  T _GetValue(const TfToken& key) const;
1781 
1782  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1783  _ReloadResult _Reload(bool force);
1784 
1785  // Reads contents of asset specified by \p identifier with resolved
1786  // path \p resolvedPath into this layer.
1787  bool _Read(const std::string& identifier,
1788  const std::string& resolvedPath,
1789  bool metadataOnly);
1790 
1791  // Saves this layer if it is dirty or the layer doesn't already exist
1792  // on disk. If \p force is true, the layer will be written out
1793  // regardless of those conditions.
1794  bool _Save(bool force) const;
1795 
1796  // A helper method used by Save and Export.
1797  // This method allows Save to specify the existing file format and Export
1798  // to use the format provided by the file extension in newFileName. If no
1799  // file format can be discovered from the file name, the existing file
1800  // format associated with the layer will be used in both cases. This allows
1801  // users to export and save to any file name, regardless of extension.
1802  bool _WriteToFile(const std::string& newFileName,
1803  const std::string& comment,
1804  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1805  const FileFormatArguments& args = FileFormatArguments())
1806  const;
1807 
1808  // Swap contents of _data and data. This operation does not register
1809  // inverses or emit change notification.
1810  void _SwapData(SdfAbstractDataRefPtr &data);
1811 
1812  // Set _data to \p newData and send coarse DidReplaceLayerContent
1813  // invalidation notice.
1814  void _AdoptData(const SdfAbstractDataRefPtr &newData);
1815 
1816  // Set _data to match data, calling other primitive setter methods to
1817  // provide fine-grained inverses and notification. If \p data might adhere
1818  // to a different schema than this layer's, pass a pointer to it as \p
1819  // newDataSchema. In this case, check to see if fields from \p data are
1820  // known to this layer's schema, and if not, omit them and issue a TfError
1821  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1822  // known fields.
1823  void _SetData(const SdfAbstractDataPtr &newData,
1824  const SdfSchemaBase *newDataSchema=nullptr);
1825 
1826  // Returns const handle to _data.
1827  SdfAbstractDataConstPtr _GetData() const;
1828 
1829  // Returns a new SdfAbstractData object for this layer.
1830  SdfAbstractDataRefPtr _CreateData() const;
1831 
1832  // Inverse primitive for setting a single field. The previous value for the
1833  // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1834  // VtValue it points to will be moved-from after the function completes. If
1835  // \p oldValue is nullptr, the old field value will be retrieved
1836  // automatically.
1837  template <class T>
1838  void _PrimSetField(const SdfPath& path,
1839  const TfToken& fieldName,
1840  const T& value,
1841  VtValue *oldValue = nullptr,
1842  bool useDelegate = true);
1843 
1844  // Inverse primitive for setting a single key in a dict-valued field. The
1845  // previous dictionary value for the field (*not* the individual entry) may
1846  // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1847  // it points to will be moved-from after the function completes. If \p
1848  // oldValue is nullptr, the old field value will be retrieved automatically.
1849  template <class T>
1850  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1851  const TfToken& fieldName,
1852  const TfToken& keyPath,
1853  const T& value,
1854  VtValue *oldValue = nullptr,
1855  bool useDelegate = true);
1856 
1857  // Primitive for appending a child to the list of children.
1858  template <class T>
1859  void _PrimPushChild(const SdfPath& parentPath,
1860  const TfToken& fieldName,
1861  const T& value,
1862  bool useDelegate = true);
1863  template <class T>
1864  void _PrimPopChild(const SdfPath& parentPath,
1865  const TfToken& fieldName,
1866  bool useDelegate = true);
1867 
1868  // Move all the fields at all paths at or below \a oldPath to be
1869  // at a corresponding location at or below \a newPath. This does
1870  // not update the children fields of the parents of these paths.
1871  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1872 
1873  // Inverse primitive for moving a spec.
1874  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1875  bool useDelegate = true);
1876 
1877  // Create a new spec of type \p specType at \p path.
1878  // Returns true if spec was successfully created, false otherwise.
1879  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1880 
1881  // Delete all the fields at or below the specified path. This does
1882  // not update the children field of the parent of \a path.
1883  bool _DeleteSpec(const SdfPath &path);
1884 
1885  // Inverse primitive for deleting a spec.
1886  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1887  bool useDelegate = true);
1888 
1889  // Inverse primitive for deleting a spec.
1890  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1891  bool useDelegate = true);
1892 
1893  // Inverse primitive for setting time samples.
1894  template <class T>
1895  void _PrimSetTimeSample(const SdfPath& path, double time,
1896  const T& value,
1897  bool useDelegate = true);
1898 
1899  // Helper method for Traverse. Visits the children of \a path using the
1900  // specified \a ChildPolicy.
1901  template <typename ChildPolicy>
1902  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1903 
1904 private:
1905  SdfLayerHandle _self;
1906 
1907  // File format and arguments for this layer.
1908  SdfFileFormatConstPtr _fileFormat;
1909  FileFormatArguments _fileFormatArgs;
1910 
1911  // Cached reference to the _fileFormat's schema -- we need access to this to
1912  // be as fast as possible since we look at it on every SetField(), for
1913  // example.
1914  const SdfSchemaBase &_schema;
1915 
1916  // Registry of Sdf Identities
1917  mutable Sdf_IdentityRegistry _idRegistry;
1918 
1919  // The underlying SdfData which stores all the data in the layer.
1920  SdfAbstractDataRefPtr _data;
1921 
1922  // The state delegate for this layer.
1923  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1924 
1925  // Dispatcher used in layer initialization, letting waiters participate in
1926  // loading instead of just busy-waiting.
1927  WorkDispatcher _initDispatcher;
1928 
1929  // Atomic variable protecting layer initialization -- the interval between
1930  // adding a layer to the layer registry and finishing the process of
1931  // initializing its contents, at which point we can truly publish the layer
1932  // for consumption by concurrent threads. We add the layer to the registry
1933  // before initialization completes so that other threads can discover and
1934  // wait for it to finish initializing.
1935  std::atomic<bool> _initializationComplete;
1936 
1937  // This is an optional<bool> that is only set once initialization
1938  // is complete, before _initializationComplete is set.
1939  boost::optional<bool> _initializationWasSuccessful;
1940 
1941  // remembers the last 'IsDirty' state.
1942  mutable bool _lastDirtyState;
1943 
1944  // Asset information for this layer.
1945  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1946 
1947  // Modification timestamp of the backing file asset when last read.
1948  mutable VtValue _assetModificationTime;
1949 
1950  // All external asset dependencies, with their modification timestamps, of
1951  // the layer when last read.
1952  mutable VtDictionary _externalAssetModificationTimes;
1953 
1954  // Mutable revision number for cache invalidation.
1955  mutable size_t _mutedLayersRevisionCache;
1956 
1957  // Cache of whether or not this layer is muted. Only valid if
1958  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1959  mutable bool _isMutedCache;
1960 
1961  // Layer permission bits.
1962  bool _permissionToEdit;
1963  bool _permissionToSave;
1964 
1965  // Whether layer edits are validated.
1966  bool _validateAuthoring;
1967 
1968  // Layer hints as of the most recent save operation.
1969  mutable SdfLayerHints _hints;
1970 
1971  // Allow access to _ValidateAuthoring() and _IsInert().
1972  friend class SdfSpec;
1973  friend class SdfPropertySpec;
1974  friend class SdfAttributeSpec;
1975 
1976  friend class Sdf_ChangeManager;
1977 
1978  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1979  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1980 
1981  // Give the file format access to our data. Limit breaking encapsulation
1982  // to the base SdFileFormat class so we don't have to friend every
1983  // implementation here.
1984  friend class SdfFileFormat;
1985 
1986  // Give layer state delegates access to our data as well as to
1987  // the various _Prim functions.
1988  friend class SdfLayerStateDelegateBase;
1989 };
1990 
1991 PXR_NAMESPACE_CLOSE_SCOPE
1992 
1993 #endif // PXR_USD_SDF_LAYER_H
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer's authoring state.
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:94
SDF_API bool IsDetached() const
Returns true if this layer is detached from its serialized data store, false otherwise.
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
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 SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for the given path and fieldName.
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 bool IsMuted() const
Returns true if the current layer is muted.
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.
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:75
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
Standard pointer typedefs.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:59
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
Returns the object at the given path.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
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 GetStartTimeCode() const
Returns the layer's start timeCode.
SDF_API void UpdateAssetInfo()
Update layer asset information.
SDF_API bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
SDF_API bool IsDirty() const
Returns true if the layer is dirty, i.e.
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
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 std::string GetOwner() const
Returns the layer's owner.
SDF_API std::string GetComment() const
Returns the comment string for this layer.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:519
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:561
Object used to specify detached layers.
Definition: layer.h:1239
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.
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:415
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 const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
A map with string keys and VtValue values.
Definition: dictionary.h:63
std::function< void(const SdfPath &)> TraversalFunction
Callback function for Traverse.
Definition: layer.h:768
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
Adds a new root prim at the given index.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:62
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
Base class for all Sdf spec classes.
Definition: spec.h:51
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API bool StreamsData() const
Returns true if this layer streams data from its serialized data store on demand, false otherwise.
SDF_API double GetFramesPerSecond() const
Returns the layer's frames per second.
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
Removes scene description that does not affect the scene in the layer namespace beginning with prim.
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
Removes prop if it has only required fields (i.e.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
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 bool ImportFromString(const std::string &string)
Reads this layer from the given string.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API std::set< std::string > GetCompositionAssetDependencies() const
Return paths of all assets this layer depends on due to composition fields.
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
Inserts new sublayer path at the given index.
SdfHandle is a smart ptr that calls IsDormant() on the pointed-to object as an extra expiration check...
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
Basic Sdf data types.
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.
DetachedLayerRules()=default
A default constructed rules object Excludes all layers from the detached layer set.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
SDF_API void RemoveInertSceneDescription()
Removes all scene description in this layer that does not affect the scene.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer's authoring state.
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 bool PermissionToEdit() const
Returns true if the caller is allowed to modify the layer and false otherwise.
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
Sets a new vector of root prims.
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
Returns the list of prim names for this layer's reorder rootPrims statement.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void SetMuted(bool muted)
Mutes the current layer if muted is true, and unmutes it otherwise.
SDF_API bool HasDefaultPrim()
Return true if the default prim metadata is set in this layer.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path for this layer.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API bool Reload(bool force=false)
Reloads the layer from its persistent representation.
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:56
Class defining various attributes for a field.
Definition: schema.h:72
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API void SetIdentifier(const std::string &identifier)
Sets the layer identifier.
A description of an arbitrarily complex namespace edit.
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema this layer adheres to.
Represents a single list of list editing operations.
Definition: listProxy.h:59
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.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
SDF_API void TransferContent(const SdfLayerHandle &layer)
Copies the content of the given layer into this 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:615
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API TfToken GetColorManagementSystem() const
Returns the color management system used to interpret the color configuration asset-path authored in ...
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:466
virtual SDF_API ~SdfLayer()
Destructor.
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.
Result
Validity of an edit.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
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.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:120
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
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.
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:735
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
Returns the prim at the given path.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
Check if a batch of namespace edits will succeed.
SDF_API const std::string & GetVersion() const
Returns the asset system version of this layer.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
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 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 SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer's pseudo-root prim.
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
Adds a new root prim name in the root prim order.
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:659
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
Returns a proxy for this layer's sublayers.
SDF_API bool HasColorManagementSystem() const
Returns true if colorManagementSystem metadata is set in this layer.
SDF_API std::string GetDisplayName() const
Returns the layer's display name.
SDF_API void ClearOwner()
Clear the owner opinion.
void SetField(const SdfPath &path, const TfToken &fieldName, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:706
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
Represents a resolved asset path.
Definition: resolvedPath.h:39
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API void Clear()
Clears the layer of all content.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
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 const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:90
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
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 void ClearColorManagementSystem()
Clears the 'colorManagementSystem' metadata authored in this layer.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
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:682
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
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.
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
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.
Contains hints about layer contents that may be used to accelerate certain composition operations.
Definition: layerHints.h:33
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
Provides a view onto an object's children.
Definition: childrenView.h:171
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
SDF_API bool IsIncluded(const std::string &identifier) const
Returns true if identifier is included in the detached layer set, false otherwise.
Maintains authoring state information for an associated layer.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string 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 SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
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 void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
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.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
SDF_API std::string GetSessionOwner() const
Returns the layer's session owner.
Base class for file format implementations.
Definition: fileFormat.h:64
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API double GetEndTimeCode() const
Returns the layer's end timeCode.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
static SDF_API const DetachedLayerRules & GetDetachedLayerRules()
Returns the current rules for the detached layer set.
SDF_API bool Import(const std::string &layerPath)
Imports the content of the given layer path, replacing the content of the current layer.
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.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
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 void SetPermissionToSave(bool allow)
Sets permission to save.
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Definition: layer.h:1247
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
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.
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:635
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
Interface for scene description data storage.
Definition: abstractData.h:73
static SDF_API void SetDetachedLayerRules(const DetachedLayerRules &mask)
Sets the rules specifying detached layers.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
Contains information about a resolved asset.
Definition: assetInfo.h:40
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.