All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
46 
47 #include <boost/optional.hpp>
48 
49 #include <atomic>
50 #include <functional>
51 #include <memory>
52 #include <set>
53 #include <string>
54 #include <vector>
55 
56 PXR_NAMESPACE_OPEN_SCOPE
57 
60 
61 struct Sdf_AssetInfo;
62 
96 class SdfLayer
97  : public TfRefBase
98  , public TfWeakBase
99 {
100 public:
102  SDF_API
103  virtual ~SdfLayer();
104 
106  SdfLayer(const SdfLayer&) = delete;
107  SdfLayer& operator=(const SdfLayer&) = delete;
108 
112 
115  SDF_API const SdfSchemaBase& GetSchema() const;
116 
118  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
119 
122  typedef std::map<std::string, std::string> FileFormatArguments;
123 
126  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
127 
133  SDF_API
134  static SdfLayerRefPtr CreateNew(const std::string &identifier,
135  const FileFormatArguments &args =
137 
144  SDF_API
145  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
146  const std::string &identifier,
147  const FileFormatArguments &args =
149 
158  SDF_API
159  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
160  const std::string &identifier,
161  const FileFormatArguments &args =
163 
170  SDF_API
171  static SdfLayerHandle Find(
172  const std::string &identifier,
173  const FileFormatArguments &args = FileFormatArguments());
174 
185  SDF_API
186  static SdfLayerHandle FindRelativeToLayer(
187  const SdfLayerHandle &anchor,
188  const std::string &identifier,
189  const FileFormatArguments &args = FileFormatArguments());
190 
197  SDF_API
198  static SdfLayerRefPtr FindOrOpen(
199  const std::string &identifier,
200  const FileFormatArguments &args = FileFormatArguments());
201 
212  SDF_API
214  const SdfLayerHandle &anchor,
215  const std::string &identifier,
216  const FileFormatArguments &args = FileFormatArguments());
217 
231  SDF_API
233  const std::string &layerPath,
234  bool metadataOnly = false,
235  const std::string& tag = std::string());
236 
238  SDF_API
239  SdfDataRefPtr GetMetadata() const;
240 
244  SDF_API
245  SdfLayerHints GetHints() const;
246 
248  SDF_API
249  static SdfLayerHandleSet GetLoadedLayers();
250 
252  SDF_API
253  bool IsEmpty() const;
254 
257  SDF_API
258  void TransferContent(const SdfLayerHandle& layer);
259 
274  SDF_API
276  const std::string& tag = std::string(),
277  const FileFormatArguments& args = FileFormatArguments());
278 
280  SDF_API
282  const std::string &tag, const SdfFileFormatConstPtr &format,
283  const FileFormatArguments& args = FileFormatArguments());
284 
286  SDF_API
287  bool IsAnonymous() const;
288 
291  SDF_API
292  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
293 
296  SDF_API
297  static std::string GetDisplayNameFromIdentifier(
298  const std::string& identifier);
299 
303 
308  SDF_API
309  bool Save(bool force = false) const;
310 
323  SDF_API
324  bool Export(const std::string& filename,
325  const std::string& comment = std::string(),
326  const FileFormatArguments& args = FileFormatArguments()) const;
327 
332  SDF_API
333  bool ExportToString(std::string* result) const;
334 
338  SDF_API
339  bool ImportFromString(const std::string &string);
340 
348  SDF_API
349  void Clear();
350 
372  SDF_API
373  bool Reload(bool force = false);
374 
381  SDF_API
382  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
383  bool force = false);
384 
390  SDF_API
391  bool Import(const std::string &layerPath);
392 
396 
398  SDF_API
399  std::set<std::string> GetExternalReferences() const;
400 
409  SDF_API
411  const std::string &oldAssetPath,
412  const std::string &newAssetPath=std::string());
413 
422  SDF_API
423  std::set<std::string> GetExternalAssetDependencies() const;
424 
444 
447  SDF_API
448  static bool SplitIdentifier(
449  const std::string& identifier,
450  std::string* layerPath,
451  FileFormatArguments* arguments);
452 
454  SDF_API
455  static std::string CreateIdentifier(
456  const std::string& layerPath,
457  const FileFormatArguments& arguments);
458 
460  SDF_API
461  const std::string& GetIdentifier() const;
462 
466  SDF_API
467  void SetIdentifier(const std::string& identifier);
468 
473 #if AR_VERSION == 1
474  SDF_API
475  void UpdateAssetInfo(const std::string& fileVersion = std::string());
476 #else
477  SDF_API
478  void UpdateAssetInfo();
479 #endif
480 
484  SDF_API
485  std::string GetDisplayName() const;
486 
489  SDF_API
490  const ArResolvedPath& GetResolvedPath() const;
491 
494  SDF_API
495  const std::string& GetRealPath() const;
496 
501  SDF_API
502  std::string GetFileExtension() const;
503 
509  SDF_API
510  const std::string& GetVersion() const;
511 
516  SDF_API
517  const std::string& GetRepositoryPath() const;
518 
520  SDF_API
521  const std::string& GetAssetName() const;
522 
525  SDF_API
526  const VtValue& GetAssetInfo() const;
527 
543  SDF_API
544  std::string ComputeAbsolutePath(const std::string& assetPath) const;
545 
547 
558 
561  SDF_API
562  SdfSpecType GetSpecType(const SdfPath& path) const;
563 
565  SDF_API
566  bool HasSpec(const SdfPath& path) const;
567 
569  SDF_API
570  std::vector<TfToken> ListFields(const SdfPath& path) const;
571 
574  SDF_API
575  bool HasField(const SdfPath& path, const TfToken& fieldName,
576  VtValue *value=NULL) const;
577  SDF_API
578  bool HasField(const SdfPath& path, const TfToken& fieldName,
579  SdfAbstractDataValue *value) const;
580 
584  template <class T>
585  bool HasField(const SdfPath& path, const TfToken &name,
586  T* value) const
587  {
588  if (!value) {
589  return HasField(path, name, static_cast<VtValue *>(NULL));
590  }
591 
592  SdfAbstractDataTypedValue<T> outValue(value);
593  const bool hasValue = HasField(
594  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
595 
596  if (std::is_same<T, SdfValueBlock>::value) {
597  return hasValue && outValue.isValueBlock;
598  }
599 
600  return hasValue && (!outValue.isValueBlock);
601  }
602 
605  std::type_info const &GetFieldTypeid(
606  const SdfPath &path, const TfToken &name) const {
607  return _data->GetTypeid(path, name);
608  }
609 
613  SDF_API
614  bool HasFieldDictKey(const SdfPath& path,
615  const TfToken &fieldName,
616  const TfToken &keyPath,
617  VtValue *value=NULL) const;
618  SDF_API
619  bool HasFieldDictKey(const SdfPath& path,
620  const TfToken &fieldName,
621  const TfToken &keyPath,
622  SdfAbstractDataValue *value) const;
623 
628  template <class T>
629  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
630  const TfToken &keyPath, T* value) const
631  {
632  if (!value) {
633  return HasFieldDictKey(path, name, keyPath,
634  static_cast<VtValue *>(NULL));
635  }
636 
637  SdfAbstractDataTypedValue<T> outValue(value);
638  return HasFieldDictKey(path, name, keyPath,
639  static_cast<SdfAbstractDataValue *>(&outValue));
640  }
641 
642 
645  SDF_API
646  VtValue GetField(const SdfPath& path,
647  const TfToken& fieldName) const;
648 
651  template <class T>
652  inline T GetFieldAs(const SdfPath& path,
653  const TfToken& fieldName, const T& defaultValue = T()) const
654  {
655  return _data->GetAs<T>(path, fieldName, defaultValue);
656  }
657 
661  SDF_API
663  const TfToken& fieldName,
664  const TfToken& keyPath) const;
665 
667  SDF_API
668  void SetField(const SdfPath& path, const TfToken& fieldName,
669  const VtValue& value);
670  SDF_API
671  void SetField(const SdfPath& path, const TfToken& fieldName,
672  const SdfAbstractDataConstValue& value);
673 
675  template <class T>
676  void SetField(const SdfPath& path, const TfToken& fieldName,
677  const T& val)
678  {
679  // Ideally, this would make use of the SdfAbstractDataConstValue
680  // API to avoid unnecessarily copying the value into a VtValue.
681  // However, Sdf needs to create a VtValue for change processing.
682  // If the underlying SdAbstractData implementation also needs a
683  // VtValue, using the SdfAbstractDataConstValue API would cause
684  // another copy to be made. So, it's more efficient to just create
685  // the VtValue once here and push that along.
686  SetField(path, fieldName, VtValue(val));
687  }
688 
691  SDF_API
692  void SetFieldDictValueByKey(const SdfPath& path,
693  const TfToken& fieldName,
694  const TfToken& keyPath,
695  const VtValue& value);
696  SDF_API
697  void SetFieldDictValueByKey(const SdfPath& path,
698  const TfToken& fieldName,
699  const TfToken& keyPath,
700  const SdfAbstractDataConstValue& value);
701 
704  template <class T>
705  void SetFieldDictValueByKey(const SdfPath& path,
706  const TfToken& fieldName,
707  const TfToken& keyPath,
708  const T& val)
709  {
710  // Ideally, this would make use of the SdfAbstractDataConstValue
711  // API to avoid unnecessarily copying the value into a VtValue.
712  // However, Sdf needs to create a VtValue for change processing.
713  // If the underlying SdAbstractData implementation also needs
714  // VtValue, using the SdfAbstractDataConstValue API would cause
715  // another copy to be made. So, it's more efficient to just create
716  // the VtValue once here and push that along.
717  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
718  }
719 
721  SDF_API
722  void EraseField(const SdfPath& path, const TfToken& fieldName);
723 
727  SDF_API
728  void EraseFieldDictValueByKey(const SdfPath& path,
729  const TfToken& fieldName,
730  const TfToken& keyPath);
731 
734 
738  typedef std::function<void(const SdfPath&)> TraversalFunction;
739 
740  // Traverse will perform a traversal of the scene description hierarchy
741  // rooted at \a path, calling \a func on each spec that it finds.
742  SDF_API
743  void Traverse(const SdfPath& path, const TraversalFunction& func);
744 
746 
749 
753  SDF_API
755 
757  SDF_API
758  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
759 
762  SDF_API
763  bool HasColorConfiguration() const;
764 
767  SDF_API
769 
777  SDF_API
779 
782  SDF_API
783  void SetColorManagementSystem(const TfToken &cms);
784 
787  SDF_API
788  bool HasColorManagementSystem() const;
789 
792  SDF_API
794 
798  SDF_API
799  std::string GetComment() const;
800 
802  SDF_API
803  void SetComment(const std::string &comment);
804 
810  SDF_API
811  TfToken GetDefaultPrim() const;
812 
818  SDF_API
819  void SetDefaultPrim(const TfToken &name);
820 
823  SDF_API
824  void ClearDefaultPrim();
825 
828  SDF_API
829  bool HasDefaultPrim();
830 
834  SDF_API
835  std::string GetDocumentation() const;
836 
838  SDF_API
839  void SetDocumentation(const std::string &documentation);
840 
848  SDF_API
849  double GetStartTimeCode() const;
850 
852  SDF_API
853  void SetStartTimeCode(double startTimecode);
854 
856  SDF_API
857  bool HasStartTimeCode() const;
858 
860  SDF_API
861  void ClearStartTimeCode();
862 
869  SDF_API
870  double GetEndTimeCode() const;
871 
873  SDF_API
874  void SetEndTimeCode(double endTimeCode);
875 
877  SDF_API
878  bool HasEndTimeCode() const;
879 
881  SDF_API
882  void ClearEndTimeCode();
883 
899  SDF_API
900  double GetTimeCodesPerSecond() const;
901 
903  SDF_API
904  void SetTimeCodesPerSecond(double timeCodesPerSecond);
905 
907  SDF_API
908  bool HasTimeCodesPerSecond() const;
909 
911  SDF_API
913 
923  SDF_API
924  double GetFramesPerSecond() const;
925 
927  SDF_API
928  void SetFramesPerSecond(double framesPerSecond);
929 
931  SDF_API
932  bool HasFramesPerSecond() const;
933 
935  SDF_API
936  void ClearFramesPerSecond();
937 
939  SDF_API
940  int GetFramePrecision() const;
941 
943  SDF_API
944  void SetFramePrecision(int framePrecision);
945 
947  SDF_API
948  bool HasFramePrecision() const;
949 
951  SDF_API
952  void ClearFramePrecision();
953 
955  SDF_API
956  std::string GetOwner() const;
957 
959  SDF_API
960  void SetOwner(const std::string& owner);
961 
963  SDF_API
964  bool HasOwner() const;
965 
967  SDF_API
968  void ClearOwner();
969 
972  SDF_API
973  std::string GetSessionOwner() const;
974 
977  SDF_API
978  void SetSessionOwner(const std::string& owner);
979 
981  SDF_API
982  bool HasSessionOwner() const;
983 
984  // Clear the session owner opinion.
985  SDF_API
986  void ClearSessionOwner();
987 
989  SDF_API
990  bool GetHasOwnedSubLayers() const;
991 
993  SDF_API
994  void SetHasOwnedSubLayers(bool);
995 
1001  SDF_API
1003 
1005  SDF_API
1006  void SetCustomLayerData(const VtDictionary& value);
1007 
1009  SDF_API
1010  bool HasCustomLayerData() const;
1011 
1013  SDF_API
1014  void ClearCustomLayerData();
1015 
1019 
1020  // Type for root prims view.
1022 
1024  SDF_API
1025  RootPrimsView GetRootPrims() const;
1026 
1031  SDF_API
1032  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1033 
1039  SDF_API
1040  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1041 
1043  SDF_API
1044  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1045 
1048  SDF_API
1049  void ScheduleRemoveIfInert(const SdfSpec& spec);
1050 
1063  SDF_API
1064  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1065 
1072  SDF_API
1073  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1074 
1080  SDF_API
1082 
1087  SDF_API
1089 
1098  SDF_API
1099  void SetRootPrimOrder(const std::vector<TfToken>& names);
1100 
1103  SDF_API
1104  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1105 
1107  SDF_API
1108  void RemoveFromRootPrimOrder(const TfToken & name);
1109 
1111  SDF_API
1112  void RemoveFromRootPrimOrderByIndex(int index);
1113 
1119  SDF_API
1120  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1121 
1125 
1138  SDF_API
1140 
1142  SDF_API
1143  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1144 
1146  SDF_API
1147  size_t GetNumSubLayerPaths() const;
1148 
1152  SDF_API
1153  void InsertSubLayerPath(const std::string& path, int index = -1);
1154 
1156  SDF_API
1157  void RemoveSubLayerPath(int index);
1158 
1160  SDF_API
1161  SdfLayerOffsetVector GetSubLayerOffsets() const;
1162 
1164  SDF_API
1165  SdfLayerOffset GetSubLayerOffset(int index) const;
1166 
1168  SDF_API
1169  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1170 
1174 
1176  SDF_API
1177  static std::set<std::string> GetMutedLayers();
1178 
1180  SDF_API
1181  bool IsMuted() const;
1182 
1184  SDF_API
1185  static bool IsMuted(const std::string &path);
1186 
1189  SDF_API
1190  void SetMuted(bool muted);
1191 
1193  SDF_API
1194  static void AddToMutedLayers(const std::string &mutedPath);
1195 
1197  SDF_API
1198  static void RemoveFromMutedLayers(const std::string &mutedPath);
1199 
1203 
1212  SDF_API
1213  SdfPrimSpecHandle GetPseudoRoot() const;
1214 
1221  SDF_API
1222  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1223 
1229  SDF_API
1230  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1231 
1237  SDF_API
1238  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1239 
1245  SDF_API
1246  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1247 
1253  SDF_API
1254  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1255 
1259 
1263  SDF_API
1264  bool PermissionToEdit() const;
1265 
1268  SDF_API
1269  bool PermissionToSave() const;
1270 
1272  SDF_API
1273  void SetPermissionToEdit(bool allow);
1274 
1276  SDF_API
1277  void SetPermissionToSave(bool allow);
1278 
1282 
1306  SDF_API
1309  SdfNamespaceEditDetailVector* details = NULL) const;
1310 
1314  SDF_API
1315  bool Apply(const SdfBatchNamespaceEdit&);
1316 
1320 
1323  SDF_API
1324  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1325 
1329  SDF_API
1330  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1331 
1334  SDF_API
1335  bool IsDirty() const;
1336 
1338 
1341  SDF_API
1342  std::set<double> ListAllTimeSamples() const;
1343 
1344  SDF_API
1345  std::set<double>
1346  ListTimeSamplesForPath(const SdfPath& path) const;
1347 
1348  SDF_API
1349  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1350 
1351  SDF_API
1352  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1353 
1354  SDF_API
1355  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1356  double time,
1357  double* tLower, double* tUpper);
1358 
1359  SDF_API
1360  bool QueryTimeSample(const SdfPath& path, double time,
1361  VtValue *value=NULL) const;
1362  SDF_API
1363  bool QueryTimeSample(const SdfPath& path, double time,
1364  SdfAbstractDataValue *value) const;
1365 
1366  template <class T>
1367  bool QueryTimeSample(const SdfPath& path, double time,
1368  T* data) const
1369  {
1370  if (!data) {
1371  return QueryTimeSample(path, time);
1372  }
1373 
1374  SdfAbstractDataTypedValue<T> outValue(data);
1375  const bool hasValue = QueryTimeSample(
1376  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1377 
1378  if (std::is_same<T, SdfValueBlock>::value) {
1379  return hasValue && outValue.isValueBlock;
1380  }
1381 
1382  return hasValue && (!outValue.isValueBlock);
1383  }
1384 
1385  SDF_API
1386  void SetTimeSample(const SdfPath& path, double time,
1387  const VtValue & value);
1388  SDF_API
1389  void SetTimeSample(const SdfPath& path, double time,
1390  const SdfAbstractDataConstValue& value);
1391 
1392  template <class T>
1393  void SetTimeSample(const SdfPath& path, double time,
1394  const T& value)
1395  {
1396  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1397  const SdfAbstractDataConstValue& untypedInValue = inValue;
1398  return SetTimeSample(path, time, untypedInValue);
1399  }
1400 
1401  SDF_API
1402  void EraseTimeSample(const SdfPath& path, double time);
1403 
1405 
1406  // Debugging
1407  // @{
1408 
1409  SDF_API
1410  static void DumpLayerInfo();
1411 
1412  // Write this layer's SdfData to a file in a simple generic format.
1413  SDF_API
1414  bool WriteDataFile(const std::string &filename);
1415 
1416  // @}
1417 
1418 protected:
1419  // Private constructor -- use New(), FindOrCreate(), etc.
1420  // Precondition: _layerRegistryMutex must be locked.
1421  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1422  const std::string &identifier,
1423  const std::string &realPath = std::string(),
1424  const ArAssetInfo& assetInfo = ArAssetInfo(),
1425  const FileFormatArguments &args = FileFormatArguments(),
1426  bool validateAuthoring = false);
1427 
1428 private:
1429  // Create a new layer.
1430  // Precondition: _layerRegistryMutex must be locked.
1431  static SdfLayerRefPtr _CreateNew(
1432  SdfFileFormatConstPtr fileFormat,
1433  const std::string& identifier,
1434  const FileFormatArguments& args);
1435 
1436  static SdfLayerRefPtr _CreateNewWithFormat(
1437  const SdfFileFormatConstPtr &fileFormat,
1438  const std::string& identifier,
1439  const std::string& realPath,
1440  const ArAssetInfo& assetInfo = ArAssetInfo(),
1441  const FileFormatArguments& args = FileFormatArguments());
1442 
1443  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1444  const SdfFileFormatConstPtr &fileFormat,
1445  const std::string& tag,
1446  const FileFormatArguments& args);
1447 
1448  // Finish initializing this layer (which may have succeeded or not)
1449  // and publish the results to other threads by unlocking the mutex.
1450  // Sets _initializationWasSuccessful and unlocks _initializationMutex.
1451  void _FinishInitialization(bool success);
1452 
1453  // Layers retrieved from the layer registry may still be in the
1454  // process of having their contents initialized. Other threads
1455  // retrieving layers from the registry must wait until initialization
1456  // is complete, using this method. See _initializationMutex.
1457  // Returns _initializationWasSuccessful.
1458  //
1459  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1460  // ensure that it is not deleted out from under them, in
1461  // case initialization fails. (This method cannot acquire the
1462  // reference itself internally without being susceptible to a race.)
1463  bool _WaitForInitializationAndCheckIfSuccessful();
1464 
1465  // Returns whether or not this menv layer should post change
1466  // notification. This simply returns (!_GetIsLoading())
1467  bool _ShouldNotify() const;
1468 
1469  // This function keeps track of the last state of IsDirty() before
1470  // updating it. It returns false if the last saved dirty state is the
1471  // same than the current state. It returns true if the state differs and
1472  // will update the 'last dirty state' to the current state. So, after
1473  // returning true, it would return false for subsequent calls until the
1474  // IsDirty() state would change again...
1475  bool _UpdateLastDirtinessState() const;
1476 
1477  // Returns a handle to the spec at the given path if it exists and matches
1478  // type T.
1479  template <class T>
1480  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1481 
1482  // Returns true if a spec can be retrieved at the given path, false
1483  // otherwise. This function will return the canonicalized path to the
1484  // spec as well as the spec type.
1485  bool _CanGetSpecAtPath(const SdfPath& path,
1486  SdfPath* canonicalPath, SdfSpecType* specType) const;
1487 
1491  void _InitializeFromIdentifier(
1492  const std::string &identifier,
1493  const std::string &realPath = std::string(),
1494  const std::string &fileVersion = std::string(),
1495  const ArAssetInfo& assetInfo = ArAssetInfo());
1496 
1497  // Helper for computing the necessary information to lookup a layer
1498  // in the registry or open the layer.
1499  struct _FindOrOpenLayerInfo;
1500  static bool _ComputeInfoToFindOrOpenLayer(
1501  const std::string& identifier,
1502  const SdfLayer::FileFormatArguments& args,
1503  _FindOrOpenLayerInfo* info,
1504  bool computeAssetInfo = false);
1505 
1506  // Open a layer, adding an entry to the registry and releasing
1507  // the registry lock.
1508  // Precondition: _layerRegistryMutex must be locked.
1509  template <class Lock>
1510  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1511  Lock &lock,
1512  const _FindOrOpenLayerInfo& info,
1513  bool metadataOnly);
1514 
1515  // Helper function for finding a layer with \p identifier and \p args.
1516  // \p lock must be unlocked initially and will be locked by this
1517  // function when needed. See docs for \p retryAsWriter argument on
1518  // _TryToFindLayer for details on the final state of the lock when
1519  // this function returns.
1520  template <class ScopedLock>
1521  static SdfLayerRefPtr
1522  _Find(const std::string &identifier,
1523  const FileFormatArguments &args,
1524  ScopedLock &lock, bool retryAsWriter);
1525 
1526  // Helper function to try to find the layer with \p identifier and
1527  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1528  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1529  // released upon return. Otherwise the lock is released upon return if a
1530  // layer is found successfully. If no layer is found then the lock is
1531  // upgraded to a writer lock upon return. Note that this upgrade may not be
1532  // atomic, but this function ensures that if upon return there does not
1533  // exist a matching layer in the registry.
1534  template <class ScopedLock>
1535  static SdfLayerRefPtr
1536  _TryToFindLayer(const std::string &identifier,
1537  const std::string &resolvedPath,
1538  ScopedLock &lock, bool retryAsWriter);
1539 
1547  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1548  bool requiredFieldOnlyPropertiesAreInert = false) const;
1549 
1558  bool _IsInertSubtree(const SdfPath &path,
1559  std::vector<SdfPath>* inertSpecs = nullptr);
1560 
1566  void _RemoveIfInert(const SdfSpec& spec);
1567 
1572  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1573 
1576  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1577 
1579  bool _ValidateAuthoring() const { return _validateAuthoring; }
1580 
1582  std::string _GetMutedPath() const;
1583 
1584  // If old and new asset path is given, rename all external prim
1585  // references referring to the old path.
1586  void _UpdateReferencePaths(const SdfPrimSpecHandle &parent,
1587  const std::string &oldLayerPath,
1588  const std::string &newLayerPath);
1589 
1590  // Set the clean state to the current state.
1591  void _MarkCurrentStateAsClean() const;
1592 
1593  // Return the field definition for \p fieldName if \p fieldName is a
1594  // required field for the spec type identified by \p path.
1595  inline SdfSchema::FieldDefinition const *
1596  _GetRequiredFieldDef(const SdfPath &path,
1597  const TfToken &fieldName,
1598  SdfSpecType specType = SdfSpecTypeUnknown) const;
1599 
1600  // Return the field definition for \p fieldName if \p fieldName is a
1601  // required field for \p specType subject to \p schema.
1602  static inline SdfSchema::FieldDefinition const *
1603  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1604  const TfToken &fieldName,
1605  SdfSpecType specType);
1606 
1607  // Helper to list all fields on \p data at \p path subject to \p schema.
1608  static std::vector<TfToken>
1609  _ListFields(SdfSchemaBase const &schema,
1610  SdfAbstractData const &data, const SdfPath& path);
1611 
1612  // Helper for HasField for \p path in \p data subject to \p schema.
1613  static inline bool
1614  _HasField(const SdfSchemaBase &schema,
1615  const SdfAbstractData &data,
1616  const SdfPath& path,
1617  const TfToken& fieldName,
1618  VtValue *value);
1619 
1620  // Helper to get a field value for \p path in \p data subject to \p schema.
1621  static inline VtValue
1622  _GetField(const SdfSchemaBase &schema,
1623  const SdfAbstractData &data,
1624  const SdfPath& path,
1625  const TfToken& fieldName);
1626 
1627  // Set a value.
1628  template <class T>
1629  void _SetValue(const TfToken& key, T value);
1630 
1631  // Get a value.
1632  template <class T>
1633  T _GetValue(const TfToken& key) const;
1634 
1635  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1636  _ReloadResult _Reload(bool force);
1637 
1638  // Reads contents of asset specified by \p identifier with resolved
1639  // path \p resolvedPath into this layer.
1640  bool _Read(const std::string& identifier,
1641  const std::string& resolvedPath,
1642  bool metadataOnly);
1643 
1644  // Saves this layer if it is dirty or the layer doesn't already exist
1645  // on disk. If \p force is true, the layer will be written out
1646  // regardless of those conditions.
1647  bool _Save(bool force) const;
1648 
1649  // A helper method used by Save and Export.
1650  // This method allows Save to specify the existing file format and Export
1651  // to use the format provided by the file extension in newFileName. If no
1652  // file format can be discovered from the file name, the existing file
1653  // format associated with the layer will be used in both cases. This allows
1654  // users to export and save to any file name, regardless of extension.
1655  bool _WriteToFile(const std::string& newFileName,
1656  const std::string& comment,
1657  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1658  const FileFormatArguments& args = FileFormatArguments())
1659  const;
1660 
1661  // Swap contents of _data and data. This operation does not register
1662  // inverses or emit change notification.
1663  void _SwapData(SdfAbstractDataRefPtr &data);
1664 
1665  // Set _data to match data, calling other primitive setter methods to
1666  // provide fine-grained inverses and notification. If \p data might adhere
1667  // to a different schema than this layer's, pass a pointer to it as \p
1668  // newDataSchema. In this case, check to see if fields from \p data are
1669  // known to this layer's schema, and if not, omit them and issue a TfError
1670  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1671  // known fields.
1672  void _SetData(const SdfAbstractDataPtr &newData,
1673  const SdfSchemaBase *newDataSchema=nullptr);
1674 
1675  // Returns const handle to _data.
1676  SdfAbstractDataConstPtr _GetData() const;
1677 
1678  // Inverse primitive for setting a single field.
1679  template <class T>
1680  void _PrimSetField(const SdfPath& path,
1681  const TfToken& fieldName,
1682  const T& value,
1683  const VtValue *oldValue = NULL,
1684  bool useDelegate = true);
1685 
1686  // Inverse primitive for setting a single key in a dict-valued field.
1687  template <class T>
1688  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1689  const TfToken& fieldName,
1690  const TfToken& keyPath,
1691  const T& value,
1692  const VtValue *oldValue = NULL,
1693  bool useDelegate = true);
1694 
1695  // Primitive for appending a child to the list of children.
1696  template <class T>
1697  void _PrimPushChild(const SdfPath& parentPath,
1698  const TfToken& fieldName,
1699  const T& value,
1700  bool useDelegate = true);
1701  template <class T>
1702  void _PrimPopChild(const SdfPath& parentPath,
1703  const TfToken& fieldName,
1704  bool useDelegate = true);
1705 
1706  // Move all the fields at all paths at or below \a oldPath to be
1707  // at a corresponding location at or below \a newPath. This does
1708  // not update the children fields of the parents of these paths.
1709  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1710 
1711  // Inverse primitive for moving a spec.
1712  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1713  bool useDelegate = true);
1714 
1715  // Create a new spec of type \p specType at \p path.
1716  // Returns true if spec was successfully created, false otherwise.
1717  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1718 
1719  // Delete all the fields at or below the specified path. This does
1720  // not update the children field of the parent of \a path.
1721  bool _DeleteSpec(const SdfPath &path);
1722 
1723  // Inverse primitive for deleting a spec.
1724  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1725  bool useDelegate = true);
1726 
1727  // Inverse primitive for deleting a spec.
1728  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1729  bool useDelegate = true);
1730 
1731  // Inverse primitive for setting time samples.
1732  template <class T>
1733  void _PrimSetTimeSample(const SdfPath& path, double time,
1734  const T& value,
1735  bool useDelegate = true);
1736 
1737  // Helper method for Traverse. Visits the children of \a path using the
1738  // specified \a ChildPolicy.
1739  template <typename ChildPolicy>
1740  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1741 
1742 private:
1743  SdfLayerHandle _self;
1744 
1745  // File format and arguments for this layer.
1746  SdfFileFormatConstPtr _fileFormat;
1747  FileFormatArguments _fileFormatArgs;
1748 
1749  // Registry of Sdf Identities
1750  mutable Sdf_IdentityRegistry _idRegistry;
1751 
1752  // The underlying SdfData which stores all the data in the layer.
1753  SdfAbstractDataRefPtr _data;
1754 
1755  // The state delegate for this layer.
1756  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1757 
1758  // Atomic variable protecting layer initialization -- the interval between
1759  // adding a layer to the layer registry and finishing the process of
1760  // initializing its contents, at which point we can truly publish the layer
1761  // for consumption by concurrent threads. We add the layer to the registry
1762  // before initialization completes so that other threads can discover and
1763  // wait for it to finish initializing.
1764  std::atomic<bool> _initializationComplete;
1765 
1766  // This is an optional<bool> that is only set once initialization
1767  // is complete, while _initializationMutex is locked. If the
1768  // optional<bool> is unset, initialization is still underway.
1769  boost::optional<bool> _initializationWasSuccessful;
1770 
1771  // remembers the last 'IsDirty' state.
1772  mutable bool _lastDirtyState;
1773 
1774  // Asset information for this layer.
1775  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1776 
1777  // Modification timestamp of the backing file asset when last read.
1778  mutable VtValue _assetModificationTime;
1779 
1780  // All external asset dependencies, with their modification timestamps, of
1781  // the layer when last read.
1782  mutable VtDictionary _externalAssetModificationTimes;
1783 
1784  // Mutable revision number for cache invalidation.
1785  mutable size_t _mutedLayersRevisionCache;
1786 
1787  // Cache of whether or not this layer is muted. Only valid if
1788  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1789  mutable bool _isMutedCache;
1790 
1791  // Layer permission bits.
1792  bool _permissionToEdit;
1793  bool _permissionToSave;
1794 
1795  // Whether layer edits are validated.
1796  bool _validateAuthoring;
1797 
1798  // Layer hints as of the most recent save operation.
1799  mutable SdfLayerHints _hints;
1800 
1801  // Allow access to _ValidateAuthoring() and _IsInert().
1802  friend class SdfSpec;
1803  friend class SdfPropertySpec;
1804  friend class SdfAttributeSpec;
1805 
1806  friend class Sdf_ChangeManager;
1807 
1808  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1809  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1810 
1811  // Give the file format access to our data. Limit breaking encapsulation
1812  // to the base SdFileFormat class so we don't have to friend every
1813  // implementation here.
1814  friend class SdfFileFormat;
1815 
1816  // Give layer state delegates access to our data as well as to
1817  // the various _Prim functions.
1818  friend class SdfLayerStateDelegateBase;
1819 };
1820 
1821 PXR_NAMESPACE_CLOSE_SCOPE
1822 
1823 #endif // PXR_USD_SDF_LAYER_H
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer&#39;s session owner.
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer&#39;s authoring state.
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:605
SDF_API bool HasColorManagementSystem() const
Returns true if colorManagementSystem metadata is set in this layer.
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:96
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved. ...
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
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 SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer&#39;s pseudo-root prim.
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:585
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 std::set< std::string > GetExternalAssetDependencies() const
Returns a set of resolved paths to all external asset dependencies the layer needs to generate its co...
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer&#39;s sublayers are expected to have owners.
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 void SetEndTimeCode(double endTimeCode)
Sets the layer&#39;s end timeCode.
SDF_API double GetFramesPerSecond() const
Returns the layer&#39;s frames per second.
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema this layer adheres to.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
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&#39;s owner.
SDF_API void UpdateAssetInfo()
Update layer asset information.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:477
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:519
static SDF_API SdfLayerRefPtr FindOrOpenRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
Returns a proxy for this layer&#39;s sublayers.
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:394
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:738
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer&#39;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&#39;t actually provide a...
Definition: schema.h:62
Base class for all Sdf spec classes.
Definition: spec.h:51
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
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 bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API bool IsDirty() const
Returns true if the layer is dirty, i.e.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
SDF_API bool ImportFromString(const std::string &string)
Reads this layer from the given string.
SDF_API bool Export(const std::string &filename, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
Exports this layer to a file.
SDF_API void 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&#39;s frames per second.
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
Basic Sdf data types.
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 SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
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 TfToken GetColorManagementSystem() const
Returns the color management system used to interpret the color configuration asset-path authored in ...
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
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 std::set< std::string > GetExternalReferences() const
Return paths of all external references of layer.
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
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 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 void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetSessionOwner() const
Returns the layer&#39;s session owner.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer&#39;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 bool GetHasOwnedSubLayers() const
Returns true if the layer&#39;s sublayers are expected to have owners.
Represents a single list of list editing operations.
Definition: listProxy.h:57
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:629
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.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API double GetTimeCodesPerSecond() const
Returns the layer&#39;s timeCodes per second.
SDF_API double GetEndTimeCode() const
Returns the layer&#39;s end timeCode.
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:444
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path for this layer.
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())
Updates the external references of the layer.
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:122
SDF_API std::string GetOwner() const
Returns the layer&#39;s owner.
SDF_API void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)
Set the value of the given path and fieldName.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for 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:705
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
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 SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
Returns the prim at the given path.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
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 bool ExportToString(std::string *result) const
Writes this layer to the given string.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer&#39;s authoring state.
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
Adds a new root prim name in the root prim order.
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:676
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer&#39;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.
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
Represents a resolved asset path.
Definition: resolvedPath.h:39
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API double GetStartTimeCode() const
Returns the layer&#39;s start timeCode.
SDF_API void Clear()
Clears the layer of all content.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
static SDF_API std::string GetDisplayNameFromIdentifier(const std::string &identifier)
Returns the display name for the given identifier, using the same rules as GetDisplayName.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
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 std::string GetComment() const
Returns the comment string for this layer.
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
Return the value for the given path and fieldName at keyPath.
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
SDF_API void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API void ClearColorManagementSystem()
Clears the &#39;colorManagementSystem&#39; metadata authored in this layer.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
SDF_API const std::string & GetVersion() const
Returns the asset system version of this layer.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
SDF_API int GetFramePrecision() const
Returns the layer&#39;s frame precision.
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.
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...
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:652
Contains hints about layer contents that may be used to accelerate certain composition operations...
Definition: layerHints.h:33
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
Provides a view onto an object&#39;s children.
Definition: childrenView.h:171
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
Check if a batch of namespace edits will succeed.
Maintains authoring state information for an associated layer.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
SDF_API std::string GetDisplayName() const
Returns the layer&#39;s display name.
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
Returns true if the identifier is an anonymous layer unique identifier.
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
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.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
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 bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API bool Import(const std::string &layerPath)
Imports the content of the given layer path, replacing the content of the current layer...
SDF_API bool PermissionToEdit() const
Returns true if the caller is allowed to modify the layer and false otherwise.
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.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer&#39;s root prims.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer&#39;s current contents.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
Returns the list of prim names for this layer&#39;s reorder rootPrims statement.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
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.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
Load the given layer from disk as a new anonymous layer.
SDF_API bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
SDF_API const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer&#39;s timeCodes per second.
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
Interface for scene description data storage.
Definition: abstractData.h:73
Contains information about a resolved asset.
Definition: assetInfo.h:40
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.