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 
928  SDF_API
929  double GetTimeCodesPerSecond() const;
930 
932  SDF_API
933  void SetTimeCodesPerSecond(double timeCodesPerSecond);
934 
936  SDF_API
937  bool HasTimeCodesPerSecond() const;
938 
940  SDF_API
942 
952  SDF_API
953  double GetFramesPerSecond() const;
954 
956  SDF_API
957  void SetFramesPerSecond(double framesPerSecond);
958 
960  SDF_API
961  bool HasFramesPerSecond() const;
962 
964  SDF_API
965  void ClearFramesPerSecond();
966 
968  SDF_API
969  int GetFramePrecision() const;
970 
972  SDF_API
973  void SetFramePrecision(int framePrecision);
974 
976  SDF_API
977  bool HasFramePrecision() const;
978 
980  SDF_API
981  void ClearFramePrecision();
982 
984  SDF_API
985  std::string GetOwner() const;
986 
988  SDF_API
989  void SetOwner(const std::string& owner);
990 
992  SDF_API
993  bool HasOwner() const;
994 
996  SDF_API
997  void ClearOwner();
998 
1001  SDF_API
1002  std::string GetSessionOwner() const;
1003 
1006  SDF_API
1007  void SetSessionOwner(const std::string& owner);
1008 
1010  SDF_API
1011  bool HasSessionOwner() const;
1012 
1013  // Clear the session owner opinion.
1014  SDF_API
1015  void ClearSessionOwner();
1016 
1018  SDF_API
1019  bool GetHasOwnedSubLayers() const;
1020 
1022  SDF_API
1023  void SetHasOwnedSubLayers(bool);
1024 
1030  SDF_API
1032 
1034  SDF_API
1035  void SetCustomLayerData(const VtDictionary& value);
1036 
1038  SDF_API
1039  bool HasCustomLayerData() const;
1040 
1042  SDF_API
1043  void ClearCustomLayerData();
1044 
1048 
1049  // Type for root prims view.
1051 
1053  SDF_API
1054  RootPrimsView GetRootPrims() const;
1055 
1060  SDF_API
1061  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1062 
1068  SDF_API
1069  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1070 
1072  SDF_API
1073  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1074 
1077  SDF_API
1078  void ScheduleRemoveIfInert(const SdfSpec& spec);
1079 
1092  SDF_API
1093  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1094 
1101  SDF_API
1102  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1103 
1109  SDF_API
1111 
1116  SDF_API
1118 
1127  SDF_API
1128  void SetRootPrimOrder(const std::vector<TfToken>& names);
1129 
1132  SDF_API
1133  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1134 
1136  SDF_API
1137  void RemoveFromRootPrimOrder(const TfToken & name);
1138 
1140  SDF_API
1141  void RemoveFromRootPrimOrderByIndex(int index);
1142 
1148  SDF_API
1149  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1150 
1154 
1167  SDF_API
1169 
1171  SDF_API
1172  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1173 
1175  SDF_API
1176  size_t GetNumSubLayerPaths() const;
1177 
1181  SDF_API
1182  void InsertSubLayerPath(const std::string& path, int index = -1);
1183 
1185  SDF_API
1186  void RemoveSubLayerPath(int index);
1187 
1189  SDF_API
1190  SdfLayerOffsetVector GetSubLayerOffsets() const;
1191 
1193  SDF_API
1194  SdfLayerOffset GetSubLayerOffset(int index) const;
1195 
1197  SDF_API
1198  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1199 
1201 
1222 
1239  {
1240  public:
1243  DetachedLayerRules() = default;
1244 
1247  {
1248  _includeAll = true;
1249  _include.clear();
1250  return *this;
1251  }
1252 
1255  SDF_API
1256  DetachedLayerRules& Include(const std::vector<std::string>& patterns);
1257 
1260  SDF_API
1261  DetachedLayerRules& Exclude(const std::vector<std::string>& patterns);
1262 
1263  bool IncludedAll() const { return _includeAll; }
1264  const std::vector<std::string>& GetIncluded() const { return _include; }
1265  const std::vector<std::string>& GetExcluded() const { return _exclude; }
1266 
1274  SDF_API
1275  bool IsIncluded(const std::string& identifier) const;
1276 
1277  private:
1278  friend class SdfLayer;
1279 
1280  std::vector<std::string> _include;
1281  std::vector<std::string> _exclude;
1282  bool _includeAll = false;
1283  };
1284 
1307  SDF_API
1308  static void SetDetachedLayerRules(const DetachedLayerRules& mask);
1309 
1311  SDF_API
1312  static const DetachedLayerRules& GetDetachedLayerRules();
1313 
1317  SDF_API
1318  static bool IsIncludedByDetachedLayerRules(const std::string& identifier);
1319 
1321 
1324 
1326  SDF_API
1327  static std::set<std::string> GetMutedLayers();
1328 
1330  SDF_API
1331  bool IsMuted() const;
1332 
1334  SDF_API
1335  static bool IsMuted(const std::string &path);
1336 
1339  SDF_API
1340  void SetMuted(bool muted);
1341 
1343  SDF_API
1344  static void AddToMutedLayers(const std::string &mutedPath);
1345 
1347  SDF_API
1348  static void RemoveFromMutedLayers(const std::string &mutedPath);
1349 
1353 
1362  SDF_API
1363  SdfPrimSpecHandle GetPseudoRoot() const;
1364 
1371  SDF_API
1372  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1373 
1379  SDF_API
1380  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1381 
1387  SDF_API
1388  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1389 
1395  SDF_API
1396  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1397 
1403  SDF_API
1404  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1405 
1409 
1413  SDF_API
1414  bool PermissionToEdit() const;
1415 
1418  SDF_API
1419  bool PermissionToSave() const;
1420 
1422  SDF_API
1423  void SetPermissionToEdit(bool allow);
1424 
1426  SDF_API
1427  void SetPermissionToSave(bool allow);
1428 
1432 
1456  SDF_API
1459  SdfNamespaceEditDetailVector* details = NULL) const;
1460 
1464  SDF_API
1465  bool Apply(const SdfBatchNamespaceEdit&);
1466 
1470 
1473  SDF_API
1474  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1475 
1479  SDF_API
1480  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1481 
1484  SDF_API
1485  bool IsDirty() const;
1486 
1488 
1491  SDF_API
1492  std::set<double> ListAllTimeSamples() const;
1493 
1494  SDF_API
1495  std::set<double>
1496  ListTimeSamplesForPath(const SdfPath& path) const;
1497 
1498  SDF_API
1499  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1500 
1501  SDF_API
1502  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1503 
1504  SDF_API
1505  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1506  double time,
1507  double* tLower, double* tUpper);
1508 
1509  SDF_API
1510  bool QueryTimeSample(const SdfPath& path, double time,
1511  VtValue *value=NULL) const;
1512  SDF_API
1513  bool QueryTimeSample(const SdfPath& path, double time,
1514  SdfAbstractDataValue *value) const;
1515 
1516  template <class T>
1517  bool QueryTimeSample(const SdfPath& path, double time,
1518  T* data) const
1519  {
1520  if (!data) {
1521  return QueryTimeSample(path, time);
1522  }
1523 
1524  SdfAbstractDataTypedValue<T> outValue(data);
1525  const bool hasValue = QueryTimeSample(
1526  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1527 
1528  if (std::is_same<T, SdfValueBlock>::value) {
1529  return hasValue && outValue.isValueBlock;
1530  }
1531 
1532  return hasValue && (!outValue.isValueBlock);
1533  }
1534 
1535  SDF_API
1536  void SetTimeSample(const SdfPath& path, double time,
1537  const VtValue & value);
1538  SDF_API
1539  void SetTimeSample(const SdfPath& path, double time,
1540  const SdfAbstractDataConstValue& value);
1541 
1542  template <class T>
1543  void SetTimeSample(const SdfPath& path, double time,
1544  const T& value)
1545  {
1546  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1547  const SdfAbstractDataConstValue& untypedInValue = inValue;
1548  return SetTimeSample(path, time, untypedInValue);
1549  }
1550 
1551  SDF_API
1552  void EraseTimeSample(const SdfPath& path, double time);
1553 
1555 
1556  // Debugging
1557  // @{
1558 
1559  SDF_API
1560  static void DumpLayerInfo();
1561 
1562  // Write this layer's SdfData to a file in a simple generic format.
1563  SDF_API
1564  bool WriteDataFile(const std::string &filename);
1565 
1566  // @}
1567 
1568 protected:
1569  // Private constructor -- use New(), FindOrCreate(), etc.
1570  // Precondition: _layerRegistryMutex must be locked.
1571  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1572  const std::string &identifier,
1573  const std::string &realPath = std::string(),
1574  const ArAssetInfo& assetInfo = ArAssetInfo(),
1575  const FileFormatArguments &args = FileFormatArguments(),
1576  bool validateAuthoring = false);
1577 
1578 private:
1579  // Create a new layer.
1580  // Precondition: _layerRegistryMutex must be locked.
1581  static SdfLayerRefPtr _CreateNew(
1582  SdfFileFormatConstPtr fileFormat,
1583  const std::string& identifier,
1584  const FileFormatArguments& args,
1585  bool saveLayer = true);
1586 
1587  static SdfLayerRefPtr _CreateNewWithFormat(
1588  const SdfFileFormatConstPtr &fileFormat,
1589  const std::string& identifier,
1590  const std::string& realPath,
1591  const ArAssetInfo& assetInfo = ArAssetInfo(),
1592  const FileFormatArguments& args = FileFormatArguments());
1593 
1594  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1595  const SdfFileFormatConstPtr &fileFormat,
1596  const std::string& tag,
1597  const FileFormatArguments& args);
1598 
1599  // Finish initializing this layer (which may have succeeded or not)
1600  // and publish the results to other threads by unlocking the mutex.
1601  // Sets _initializationWasSuccessful.
1602  void _FinishInitialization(bool success);
1603 
1604  // Layers retrieved from the layer registry may still be in the
1605  // process of having their contents initialized. Other threads
1606  // retrieving layers from the registry must wait until initialization
1607  // is complete, using this method.
1608  // Returns _initializationWasSuccessful.
1609  //
1610  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1611  // ensure that it is not deleted out from under them, in
1612  // case initialization fails. (This method cannot acquire the
1613  // reference itself internally without being susceptible to a race.)
1614  bool _WaitForInitializationAndCheckIfSuccessful();
1615 
1616  // Returns whether or not this menv layer should post change
1617  // notification. This simply returns (!_GetIsLoading())
1618  bool _ShouldNotify() const;
1619 
1620  // This function keeps track of the last state of IsDirty() before
1621  // updating it. It returns false if the last saved dirty state is the
1622  // same than the current state. It returns true if the state differs and
1623  // will update the 'last dirty state' to the current state. So, after
1624  // returning true, it would return false for subsequent calls until the
1625  // IsDirty() state would change again...
1626  bool _UpdateLastDirtinessState() const;
1627 
1628  // Returns a handle to the spec at the given path if it exists and matches
1629  // type T.
1630  template <class T>
1631  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1632 
1633  // Returns true if a spec can be retrieved at the given path, false
1634  // otherwise. This function will return the canonicalized path to the
1635  // spec as well as the spec type.
1636  bool _CanGetSpecAtPath(const SdfPath& path,
1637  SdfPath* canonicalPath, SdfSpecType* specType) const;
1638 
1642  void _InitializeFromIdentifier(
1643  const std::string &identifier,
1644  const std::string &realPath = std::string(),
1645  const std::string &fileVersion = std::string(),
1646  const ArAssetInfo& assetInfo = ArAssetInfo());
1647 
1648  // Helper for computing the necessary information to lookup a layer
1649  // in the registry or open the layer.
1650  struct _FindOrOpenLayerInfo;
1651  static bool _ComputeInfoToFindOrOpenLayer(
1652  const std::string& identifier,
1653  const SdfLayer::FileFormatArguments& args,
1654  _FindOrOpenLayerInfo* info,
1655  bool computeAssetInfo = false);
1656 
1657  // Open a layer, adding an entry to the registry and releasing
1658  // the registry lock.
1659  // Precondition: _layerRegistryMutex must be locked.
1660  template <class Lock>
1661  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1662  Lock &lock,
1663  const _FindOrOpenLayerInfo& info,
1664  bool metadataOnly);
1665 
1666  // Helper function for finding a layer with \p identifier and \p args.
1667  // \p lock must be unlocked initially and will be locked by this
1668  // function when needed. See docs for \p retryAsWriter argument on
1669  // _TryToFindLayer for details on the final state of the lock when
1670  // this function returns.
1671  template <class ScopedLock>
1672  static SdfLayerRefPtr
1673  _Find(const std::string &identifier,
1674  const FileFormatArguments &args,
1675  ScopedLock &lock, bool retryAsWriter);
1676 
1677  // Helper function to try to find the layer with \p identifier and
1678  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1679  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1680  // released upon return. Otherwise the lock is released upon return if a
1681  // layer is found successfully. If no layer is found then the lock is
1682  // upgraded to a writer lock upon return. Note that this upgrade may not be
1683  // atomic, but this function ensures that if upon return there does not
1684  // exist a matching layer in the registry.
1685  template <class ScopedLock>
1686  static SdfLayerRefPtr
1687  _TryToFindLayer(const std::string &identifier,
1688  const ArResolvedPath &resolvedPath,
1689  ScopedLock &lock, bool retryAsWriter);
1690 
1698  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1699  bool requiredFieldOnlyPropertiesAreInert = false) const;
1700 
1704  bool _IsInertSubtree(const SdfPath &path) const;
1705 
1711  void _RemoveIfInert(const SdfSpec& spec);
1712 
1717  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1718 
1721  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1722 
1724  bool _ValidateAuthoring() const { return _validateAuthoring; }
1725 
1727  std::string _GetMutedPath() const;
1728 
1729  // If old and new asset path is given, rename all external prim
1730  // composition dependency referring to the old path.
1731  void _UpdatePrimCompositionDependencyPaths(
1732  const SdfPrimSpecHandle &parent,
1733  const std::string &oldLayerPath,
1734  const std::string &newLayerPath);
1735 
1736  // Set the clean state to the current state.
1737  void _MarkCurrentStateAsClean() const;
1738 
1739  // Return the field definition for \p fieldName if \p fieldName is a
1740  // required field for the spec type identified by \p path.
1741  inline SdfSchema::FieldDefinition const *
1742  _GetRequiredFieldDef(const SdfPath &path,
1743  const TfToken &fieldName,
1744  SdfSpecType specType = SdfSpecTypeUnknown) const;
1745 
1746  // Return the field definition for \p fieldName if \p fieldName is a
1747  // required field for \p specType subject to \p schema.
1748  static inline SdfSchema::FieldDefinition const *
1749  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1750  const TfToken &fieldName,
1751  SdfSpecType specType);
1752 
1753  // Helper to list all fields on \p data at \p path subject to \p schema.
1754  static std::vector<TfToken>
1755  _ListFields(SdfSchemaBase const &schema,
1756  SdfAbstractData const &data, const SdfPath& path);
1757 
1758  // Helper for HasField for \p path in \p data subject to \p schema.
1759  static inline bool
1760  _HasField(const SdfSchemaBase &schema,
1761  const SdfAbstractData &data,
1762  const SdfPath& path,
1763  const TfToken& fieldName,
1764  VtValue *value);
1765 
1766  // Helper to get a field value for \p path in \p data subject to \p schema.
1767  static inline VtValue
1768  _GetField(const SdfSchemaBase &schema,
1769  const SdfAbstractData &data,
1770  const SdfPath& path,
1771  const TfToken& fieldName);
1772 
1773  // Set a value.
1774  template <class T>
1775  void _SetValue(const TfToken& key, T value);
1776 
1777  // Get a value.
1778  template <class T>
1779  T _GetValue(const TfToken& key) const;
1780 
1781  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1782  _ReloadResult _Reload(bool force);
1783 
1784  // Reads contents of asset specified by \p identifier with resolved
1785  // path \p resolvedPath into this layer.
1786  bool _Read(const std::string& identifier,
1787  const ArResolvedPath& resolvedPath,
1788  bool metadataOnly);
1789 
1790  // Saves this layer if it is dirty or the layer doesn't already exist
1791  // on disk. If \p force is true, the layer will be written out
1792  // regardless of those conditions.
1793  bool _Save(bool force) const;
1794 
1795  // A helper method used by Save and Export.
1796  // This method allows Save to specify the existing file format and Export
1797  // to use the format provided by the file extension in newFileName. If no
1798  // file format can be discovered from the file name, the existing file
1799  // format associated with the layer will be used in both cases. This allows
1800  // users to export and save to any file name, regardless of extension.
1801  bool _WriteToFile(const std::string& newFileName,
1802  const std::string& comment,
1803  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1804  const FileFormatArguments& args = FileFormatArguments())
1805  const;
1806 
1807  // Swap contents of _data and data. This operation does not register
1808  // inverses or emit change notification.
1809  void _SwapData(SdfAbstractDataRefPtr &data);
1810 
1811  // Set _data to \p newData and send coarse DidReplaceLayerContent
1812  // invalidation notice.
1813  void _AdoptData(const SdfAbstractDataRefPtr &newData);
1814 
1815  // Set _data to match data, calling other primitive setter methods to
1816  // provide fine-grained inverses and notification. If \p data might adhere
1817  // to a different schema than this layer's, pass a pointer to it as \p
1818  // newDataSchema. In this case, check to see if fields from \p data are
1819  // known to this layer's schema, and if not, omit them and issue a TfError
1820  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1821  // known fields.
1822  void _SetData(const SdfAbstractDataPtr &newData,
1823  const SdfSchemaBase *newDataSchema=nullptr);
1824 
1825  // Returns const handle to _data.
1826  SdfAbstractDataConstPtr _GetData() const;
1827 
1828  // Returns a new SdfAbstractData object for this layer.
1829  SdfAbstractDataRefPtr _CreateData() const;
1830 
1831  // Inverse primitive for setting a single field. The previous value for the
1832  // field may be given via \p oldValue. If \p oldValue is non-nullptr, the
1833  // VtValue it points to will be moved-from after the function completes. If
1834  // \p oldValue is nullptr, the old field value will be retrieved
1835  // automatically.
1836  template <class T>
1837  void _PrimSetField(const SdfPath& path,
1838  const TfToken& fieldName,
1839  const T& value,
1840  VtValue *oldValue = nullptr,
1841  bool useDelegate = true);
1842 
1843  // Inverse primitive for setting a single key in a dict-valued field. The
1844  // previous dictionary value for the field (*not* the individual entry) may
1845  // be supplied via \p oldValue. If \p oldValue is non-nullptr, the VtValue
1846  // it points to will be moved-from after the function completes. If \p
1847  // oldValue is nullptr, the old field value will be retrieved automatically.
1848  template <class T>
1849  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1850  const TfToken& fieldName,
1851  const TfToken& keyPath,
1852  const T& value,
1853  VtValue *oldValue = nullptr,
1854  bool useDelegate = true);
1855 
1856  // Primitive for appending a child to the list of children.
1857  template <class T>
1858  void _PrimPushChild(const SdfPath& parentPath,
1859  const TfToken& fieldName,
1860  const T& value,
1861  bool useDelegate = true);
1862  template <class T>
1863  void _PrimPopChild(const SdfPath& parentPath,
1864  const TfToken& fieldName,
1865  bool useDelegate = true);
1866 
1867  // Move all the fields at all paths at or below \a oldPath to be
1868  // at a corresponding location at or below \a newPath. This does
1869  // not update the children fields of the parents of these paths.
1870  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1871 
1872  // Inverse primitive for moving a spec.
1873  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1874  bool useDelegate = true);
1875 
1876  // Create a new spec of type \p specType at \p path.
1877  // Returns true if spec was successfully created, false otherwise.
1878  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1879 
1880  // Delete all the fields at or below the specified path. This does
1881  // not update the children field of the parent of \a path.
1882  bool _DeleteSpec(const SdfPath &path);
1883 
1884  // Inverse primitive for deleting a spec.
1885  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1886  bool useDelegate = true);
1887 
1888  // Inverse primitive for deleting a spec.
1889  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1890  bool useDelegate = true);
1891 
1892  // Inverse primitive for setting time samples.
1893  template <class T>
1894  void _PrimSetTimeSample(const SdfPath& path, double time,
1895  const T& value,
1896  bool useDelegate = true);
1897 
1898  // Helper method for Traverse. Visits the children of \a path using the
1899  // specified \a ChildPolicy.
1900  template <typename ChildPolicy>
1901  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1902 
1903 private:
1904  SdfLayerHandle _self;
1905 
1906  // File format and arguments for this layer.
1907  SdfFileFormatConstPtr _fileFormat;
1908  FileFormatArguments _fileFormatArgs;
1909 
1910  // Cached reference to the _fileFormat's schema -- we need access to this to
1911  // be as fast as possible since we look at it on every SetField(), for
1912  // example.
1913  const SdfSchemaBase &_schema;
1914 
1915  // Registry of Sdf Identities
1916  mutable Sdf_IdentityRegistry _idRegistry;
1917 
1918  // The underlying SdfData which stores all the data in the layer.
1919  SdfAbstractDataRefPtr _data;
1920 
1921  // The state delegate for this layer.
1922  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1923 
1924  // Dispatcher used in layer initialization, letting waiters participate in
1925  // loading instead of just busy-waiting.
1926  WorkDispatcher _initDispatcher;
1927 
1928  // Atomic variable protecting layer initialization -- the interval between
1929  // adding a layer to the layer registry and finishing the process of
1930  // initializing its contents, at which point we can truly publish the layer
1931  // for consumption by concurrent threads. We add the layer to the registry
1932  // before initialization completes so that other threads can discover and
1933  // wait for it to finish initializing.
1934  std::atomic<bool> _initializationComplete;
1935 
1936  // This is an optional<bool> that is only set once initialization
1937  // is complete, before _initializationComplete is set.
1938  boost::optional<bool> _initializationWasSuccessful;
1939 
1940  // remembers the last 'IsDirty' state.
1941  mutable bool _lastDirtyState;
1942 
1943  // Asset information for this layer.
1944  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1945 
1946  // Modification timestamp of the backing file asset when last read.
1947  mutable VtValue _assetModificationTime;
1948 
1949  // All external asset dependencies, with their modification timestamps, of
1950  // the layer when last read.
1951  mutable VtDictionary _externalAssetModificationTimes;
1952 
1953  // Mutable revision number for cache invalidation.
1954  mutable size_t _mutedLayersRevisionCache;
1955 
1956  // Cache of whether or not this layer is muted. Only valid if
1957  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1958  mutable bool _isMutedCache;
1959 
1960  // Layer permission bits.
1961  bool _permissionToEdit;
1962  bool _permissionToSave;
1963 
1964  // Whether layer edits are validated.
1965  bool _validateAuthoring;
1966 
1967  // Layer hints as of the most recent save operation.
1968  mutable SdfLayerHints _hints;
1969 
1970  // Allow access to _ValidateAuthoring() and _IsInert().
1971  friend class SdfSpec;
1972  friend class SdfPropertySpec;
1973  friend class SdfAttributeSpec;
1974 
1975  friend class Sdf_ChangeManager;
1976 
1977  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1978  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1979 
1980  // Give the file format access to our data. Limit breaking encapsulation
1981  // to the base SdFileFormat class so we don't have to friend every
1982  // implementation here.
1983  friend class SdfFileFormat;
1984 
1985  // Give layer state delegates access to our data as well as to
1986  // the various _Prim functions.
1987  friend class SdfLayerStateDelegateBase;
1988 };
1989 
1990 PXR_NAMESPACE_CLOSE_SCOPE
1991 
1992 #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:1238
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:91
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:1246
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:41
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.