All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
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 SDF_LAYER_H
25 #define SDF_LAYER_H
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/data.h"
32 #include "pxr/usd/sdf/declareHandles.h"
33 #include "pxr/usd/sdf/identity.h"
34 #include "pxr/usd/sdf/layerOffset.h"
35 #include "pxr/usd/sdf/namespaceEdit.h"
36 #include "pxr/usd/sdf/path.h"
37 #include "pxr/usd/sdf/proxyTypes.h"
38 #include "pxr/usd/sdf/spec.h"
39 #include "pxr/usd/sdf/types.h"
40 #include "pxr/usd/ar/assetInfo.h"
41 #include "pxr/base/tf/declarePtrs.h"
42 #include "pxr/base/vt/value.h"
44 #include <boost/optional.hpp>
46 #include <functional>
47 #include <memory>
48 #include <mutex>
49 #include <set>
50 #include <string>
51 #include <vector>
58 struct Sdf_AssetInfo;
93 class SdfLayer
94  : public TfRefBase
95  , public TfWeakBase
96 {
97 public:
100  virtual ~SdfLayer();
103  SdfLayer(const SdfLayer&) = delete;
104  SdfLayer& operator=(const SdfLayer&) = delete;
112  SDF_API const SdfSchemaBase& GetSchema() const;
115  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
119  typedef std::map<std::string, std::string> FileFormatArguments;
123  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
136  SDF_API
137  static SdfLayerRefPtr CreateNew(const std::string &identifier,
138  const std::string &realPath = std::string(),
139  const FileFormatArguments &args =
148  SDF_API
149  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
150  const std::string &identifier,
151  const std::string &realPath = std::string(),
152  const FileFormatArguments &args =
168  SDF_API
169  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
170  const std::string &identifier,
171  const std::string &realPath = std::string(),
172  const FileFormatArguments &args =
177  SDF_API
178  static SdfLayerHandle Find(
179  const std::string &identifier,
180  const FileFormatArguments &args = FileFormatArguments());
186  SDF_API
187  static SdfLayerHandle FindRelativeToLayer(
188  const SdfLayerHandle &anchor,
189  const std::string &layerPath,
190  const FileFormatArguments &args = FileFormatArguments());
198  SDF_API
199  static SdfLayerRefPtr FindOrOpen(
200  const std::string &identifier,
201  const FileFormatArguments &args = FileFormatArguments());
216  SDF_API
218  const std::string &layerPath,
219  bool metadataOnly = false,
220  const std::string& tag = std::string());
223  SDF_API
224  SdfDataRefPtr GetMetadata() const;
227  SDF_API
228  static SdfLayerHandleSet GetLoadedLayers();
231  SDF_API
232  bool IsEmpty() const;
236  SDF_API
237  void TransferContent(const SdfLayerHandle& layer);
253  SDF_API
255  const std::string& tag = std::string(),
256  const FileFormatArguments& args = FileFormatArguments());
259  SDF_API
261  const std::string &tag, const SdfFileFormatConstPtr &format,
262  const FileFormatArguments& args = FileFormatArguments());
265  SDF_API
266  bool IsAnonymous() const;
270  SDF_API
271  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
275  SDF_API
276  static std::string GetDisplayNameFromIdentifier(
277  const std::string& identifier);
284  SDF_API
285  static std::string ComputeRealPath(const std::string &layerPath);
291  SDF_API
292  bool Save(bool force = false) const;
306  SDF_API
307  bool Export(const std::string& filename,
308  const std::string& comment = std::string(),
309  const FileFormatArguments& args = FileFormatArguments()) const;
315  SDF_API
316  bool ExportToString(std::string* result) const;
321  SDF_API
322  bool ImportFromString(const std::string &string);
331  SDF_API
332  void Clear();
351  SDF_API
352  bool Reload(bool force = false);
360  SDF_API
361  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
362  bool force = false);
369  SDF_API
370  bool Import(const std::string &layerPath);
377  SDF_API
378  std::set<std::string> GetExternalReferences();
388  SDF_API
390  const std::string &oldAssetPath,
391  const std::string &newAssetPath=std::string());
415  SDF_API
416  static bool SplitIdentifier(
417  const std::string& identifier,
418  std::string* layerPath,
419  FileFormatArguments* arguments);
422  SDF_API
423  static std::string CreateIdentifier(
424  const std::string& layerPath,
425  const FileFormatArguments& arguments);
428  SDF_API
429  const std::string& GetIdentifier() const;
434  SDF_API
435  void SetIdentifier(const std::string& identifier);
444  SDF_API
445  void UpdateAssetInfo(const std::string& fileVersion = std::string());
450  SDF_API
451  std::string GetDisplayName() const;
455  SDF_API
456  const std::string& GetRealPath() const;
462  SDF_API
463  std::string GetFileExtension() const;
470  SDF_API
471  const std::string& GetVersion() const;
477  SDF_API
478  const std::string& GetRepositoryPath() const;
481  SDF_API
482  const std::string& GetAssetName() const;
486  SDF_API
487  const VtValue& GetAssetInfo() const;
492  SDF_API
493  std::string ComputeAbsolutePath(const std::string &relativePath);
510  SDF_API
511  SdfSpecType GetSpecType(const SdfPath& path) const;
514  SDF_API
515  bool HasSpec(const SdfPath& path) const;
518  SDF_API
519  std::vector<TfToken> ListFields(const SdfPath& path) const;
523  SDF_API
524  bool HasField(const SdfPath& path, const TfToken& fieldName,
525  VtValue *value=NULL) const;
526  SDF_API
527  bool HasField(const SdfPath& path, const TfToken& fieldName,
528  SdfAbstractDataValue *value) const;
533  template <class T>
534  bool HasField(const SdfPath& path, const TfToken &name,
535  T* value) const
536  {
537  if (!value) {
538  return HasField(path, name, static_cast<VtValue *>(NULL));
539  }
541  SdfAbstractDataTypedValue<T> outValue(value);
542  const bool hasValue = HasField(
543  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
545  if (std::is_same<T, SdfValueBlock>::value) {
546  return hasValue && outValue.isValueBlock;
547  }
549  return hasValue && (!outValue.isValueBlock);
550  }
554  std::type_info const &GetFieldTypeid(
555  const SdfPath &path, const TfToken &name) const {
556  return _data->GetTypeid(path, name);
557  }
562  SDF_API
563  bool HasFieldDictKey(const SdfPath& path,
564  const TfToken &fieldName,
565  const TfToken &keyPath,
566  VtValue *value=NULL) const;
567  SDF_API
568  bool HasFieldDictKey(const SdfPath& path,
569  const TfToken &fieldName,
570  const TfToken &keyPath,
571  SdfAbstractDataValue *value) const;
577  template <class T>
578  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
579  const TfToken &keyPath, T* value) const
580  {
581  if (!value) {
582  return HasFieldDictKey(path, name, keyPath,
583  static_cast<VtValue *>(NULL));
584  }
586  SdfAbstractDataTypedValue<T> outValue(value);
587  return HasFieldDictKey(path, name, keyPath,
588  static_cast<SdfAbstractDataValue *>(&outValue));
589  }
594  SDF_API
595  VtValue GetField(const SdfPath& path,
596  const TfToken& fieldName) const;
600  template <class T>
601  inline T GetFieldAs(const SdfPath& path,
602  const TfToken& fieldName, const T& defaultValue = T()) const
603  {
604  return _data->GetAs<T>(path, fieldName, defaultValue);
605  }
610  SDF_API
612  const TfToken& fieldName,
613  const TfToken& keyPath) const;
616  SDF_API
617  void SetField(const SdfPath& path, const TfToken& fieldName,
618  const VtValue& value);
619  SDF_API
620  void SetField(const SdfPath& path, const TfToken& fieldName,
621  const SdfAbstractDataConstValue& value);
624  template <class T>
625  void SetField(const SdfPath& path, const TfToken& fieldName,
626  const T& val)
627  {
628  // Ideally, this would make use of the SdfAbstractDataConstValue
629  // API to avoid unnecessarily copying the value into a VtValue.
630  // However, Sdf needs to create a VtValue for change processing.
631  // If the underlying SdAbstractData implementation also needs a
632  // VtValue, using the SdfAbstractDataConstValue API would cause
633  // another copy to be made. So, it's more efficient to just create
634  // the VtValue once here and push that along.
635  SetField(path, fieldName, VtValue(val));
636  }
640  SDF_API
641  void SetFieldDictValueByKey(const SdfPath& path,
642  const TfToken& fieldName,
643  const TfToken& keyPath,
644  const VtValue& value);
645  SDF_API
646  void SetFieldDictValueByKey(const SdfPath& path,
647  const TfToken& fieldName,
648  const TfToken& keyPath,
649  const SdfAbstractDataConstValue& value);
653  template <class T>
654  void SetFieldDictValueByKey(const SdfPath& path,
655  const TfToken& fieldName,
656  const TfToken& keyPath,
657  const T& val)
658  {
659  // Ideally, this would make use of the SdfAbstractDataConstValue
660  // API to avoid unnecessarily copying the value into a VtValue.
661  // However, Sdf needs to create a VtValue for change processing.
662  // If the underlying SdAbstractData implementation also needs
663  // VtValue, using the SdfAbstractDataConstValue API would cause
664  // another copy to be made. So, it's more efficient to just create
665  // the VtValue once here and push that along.
666  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
667  }
670  SDF_API
671  void EraseField(const SdfPath& path, const TfToken& fieldName);
676  SDF_API
677  void EraseFieldDictValueByKey(const SdfPath& path,
678  const TfToken& fieldName,
679  const TfToken& keyPath);
687  typedef std::function<void(const SdfPath&)> TraversalFunction;
689  // Traverse will perform a traversal of the scene description hierarchy
690  // rooted at \a path, calling \a func on each spec that it finds.
691  SDF_API
692  void Traverse(const SdfPath& path, const TraversalFunction& func);
702  SDF_API
706  SDF_API
707  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
711  SDF_API
712  bool HasColorConfiguration() const;
716  SDF_API
726  SDF_API
731  SDF_API
732  void SetColorManagementSystem(const TfToken &cms);
736  SDF_API
737  bool HasColorManagementSystem() const;
741  SDF_API
747  SDF_API
748  std::string GetComment() const;
751  SDF_API
752  void SetComment(const std::string &comment);
759  SDF_API
760  TfToken GetDefaultPrim() const;
767  SDF_API
768  void SetDefaultPrim(const TfToken &name);
772  SDF_API
773  void ClearDefaultPrim();
777  SDF_API
778  bool HasDefaultPrim();
783  SDF_API
784  std::string GetDocumentation() const;
787  SDF_API
788  void SetDocumentation(const std::string &documentation);
797  SDF_API
798  double GetStartTimeCode() const;
801  SDF_API
802  void SetStartTimeCode(double startTimecode);
805  SDF_API
806  bool HasStartTimeCode() const;
809  SDF_API
810  void ClearStartTimeCode();
818  SDF_API
819  double GetEndTimeCode() const;
822  SDF_API
823  void SetEndTimeCode(double endTimeCode);
826  SDF_API
827  bool HasEndTimeCode() const;
830  SDF_API
831  void ClearEndTimeCode();
840  SDF_API
841  double GetTimeCodesPerSecond() const;
844  SDF_API
845  void SetTimeCodesPerSecond(double timeCodesPerSecond);
848  SDF_API
849  bool HasTimeCodesPerSecond() const;
852  SDF_API
864  SDF_API
865  double GetFramesPerSecond() const;
868  SDF_API
869  void SetFramesPerSecond(double framesPerSecond);
872  SDF_API
873  bool HasFramesPerSecond() const;
876  SDF_API
877  void ClearFramesPerSecond();
880  SDF_API
881  int GetFramePrecision() const;
884  SDF_API
885  void SetFramePrecision(int framePrecision);
888  SDF_API
889  bool HasFramePrecision() const;
892  SDF_API
893  void ClearFramePrecision();
896  SDF_API
897  std::string GetOwner() const;
900  SDF_API
901  void SetOwner(const std::string& owner);
904  SDF_API
905  bool HasOwner() const;
908  SDF_API
909  void ClearOwner();
913  SDF_API
914  std::string GetSessionOwner() const;
918  SDF_API
919  void SetSessionOwner(const std::string& owner);
922  SDF_API
923  bool HasSessionOwner() const;
925  // Clear the session owner opinion.
926  SDF_API
927  void ClearSessionOwner();
930  SDF_API
931  bool GetHasOwnedSubLayers() const;
934  SDF_API
935  void SetHasOwnedSubLayers(bool);
942  SDF_API
946  SDF_API
947  void SetCustomLayerData(const VtDictionary& value);
950  SDF_API
951  bool HasCustomLayerData() const;
954  SDF_API
955  void ClearCustomLayerData();
961  // Type for root prims view.
965  SDF_API
966  RootPrimsView GetRootPrims() const;
972  SDF_API
973  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
980  SDF_API
981  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
984  SDF_API
985  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
989  SDF_API
990  void ScheduleRemoveIfInert(const SdfSpec& spec);
1004  SDF_API
1005  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1013  SDF_API
1014  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1021  SDF_API
1028  SDF_API
1039  SDF_API
1040  void SetRootPrimOrder(const std::vector<TfToken>& names);
1044  SDF_API
1045  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1048  SDF_API
1049  void RemoveFromRootPrimOrder(const TfToken & name);
1052  SDF_API
1053  void RemoveFromRootPrimOrderByIndex(int index);
1060  SDF_API
1061  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1075  SDF_API
1079  SDF_API
1080  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1083  SDF_API
1084  size_t GetNumSubLayerPaths() const;
1089  SDF_API
1090  void InsertSubLayerPath(const std::string& path, int index = -1);
1093  SDF_API
1094  void RemoveSubLayerPath(int index);
1097  SDF_API
1098  SdfLayerOffsetVector GetSubLayerOffsets() const;
1101  SDF_API
1102  SdfLayerOffset GetSubLayerOffset(int index) const;
1105  SDF_API
1106  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1113  SDF_API
1114  static std::set<std::string> GetMutedLayers();
1117  SDF_API
1118  bool IsMuted() const;
1121  SDF_API
1122  static bool IsMuted(const std::string &path);
1126  SDF_API
1127  void SetMuted(bool muted);
1130  SDF_API
1131  static void AddToMutedLayers(const std::string &mutedPath);
1134  SDF_API
1135  static void RemoveFromMutedLayers(const std::string &mutedPath);
1149  SDF_API
1150  SdfPrimSpecHandle GetPseudoRoot() const;
1158  SDF_API
1159  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1166  SDF_API
1167  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1174  SDF_API
1175  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1182  SDF_API
1183  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1190  SDF_API
1191  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1200  SDF_API
1201  bool PermissionToEdit() const;
1205  SDF_API
1206  bool PermissionToSave() const;
1209  SDF_API
1210  void SetPermissionToEdit(bool allow);
1213  SDF_API
1214  void SetPermissionToSave(bool allow);
1243  SDF_API
1246  SdfNamespaceEditDetailVector* details = NULL) const;
1251  SDF_API
1252  bool Apply(const SdfBatchNamespaceEdit&);
1260  SDF_API
1261  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1266  SDF_API
1267  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1271  SDF_API
1272  bool IsDirty() const;
1278  SDF_API
1279  std::set<double> ListAllTimeSamples() const;
1281  SDF_API
1282  std::set<double>
1283  ListTimeSamplesForPath(const SdfPath& path) const;
1285  SDF_API
1286  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1288  SDF_API
1289  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1291  SDF_API
1292  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1293  double time,
1294  double* tLower, double* tUpper);
1296  SDF_API
1297  bool QueryTimeSample(const SdfPath& path, double time,
1298  VtValue *value=NULL) const;
1299  SDF_API
1300  bool QueryTimeSample(const SdfPath& path, double time,
1301  SdfAbstractDataValue *value) const;
1303  template <class T>
1304  bool QueryTimeSample(const SdfPath& path, double time,
1305  T* data) const
1306  {
1307  if (!data) {
1308  return QueryTimeSample(path, time);
1309  }
1311  SdfAbstractDataTypedValue<T> outValue(data);
1312  const bool hasValue = QueryTimeSample(
1313  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1315  if (std::is_same<T, SdfValueBlock>::value) {
1316  return hasValue && outValue.isValueBlock;
1317  }
1319  return hasValue && (!outValue.isValueBlock);
1320  }
1322  SDF_API
1323  void SetTimeSample(const SdfPath& path, double time,
1324  const VtValue & value);
1325  SDF_API
1326  void SetTimeSample(const SdfPath& path, double time,
1327  const SdfAbstractDataConstValue& value);
1329  template <class T>
1330  void SetTimeSample(const SdfPath& path, double time,
1331  const T& value)
1332  {
1333  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1334  const SdfAbstractDataConstValue& untypedInValue = inValue;
1335  return SetTimeSample(path, time, untypedInValue);
1336  }
1338  SDF_API
1339  void EraseTimeSample(const SdfPath& path, double time);
1343  // Debugging
1344  // @{
1346  SDF_API
1347  static void DumpLayerInfo();
1349  // Write this layer's SdfData to a file in a simple generic format.
1350  SDF_API
1351  bool WriteDataFile(const std::string &filename);
1353  // @}
1355 protected:
1356  // Private constructor -- use New(), FindOrCreate(), etc.
1357  // Precondition: _layerRegistryMutex must be locked.
1358  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1359  const std::string &identifier,
1360  const std::string &realPath = std::string(),
1361  const ArAssetInfo& assetInfo = ArAssetInfo(),
1362  const FileFormatArguments &args = FileFormatArguments(),
1363  bool validateAuthoring = false);
1365 private:
1366  // Create a new layer.
1367  // Precondition: _layerRegistryMutex must be locked.
1368  static SdfLayerRefPtr _CreateNew(
1369  SdfFileFormatConstPtr fileFormat,
1370  const std::string& identifier,
1371  const std::string& realPath,
1372  const ArAssetInfo& assetInfo = ArAssetInfo(),
1373  const FileFormatArguments& args = FileFormatArguments());
1375  static SdfLayerRefPtr _CreateNewWithFormat(
1376  const SdfFileFormatConstPtr &fileFormat,
1377  const std::string& identifier,
1378  const std::string& realPath,
1379  const ArAssetInfo& assetInfo = ArAssetInfo(),
1380  const FileFormatArguments& args = FileFormatArguments());
1382  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1383  const SdfFileFormatConstPtr &fileFormat,
1384  const std::string& tag,
1385  const FileFormatArguments& args);
1387  // Finish initializing this layer (which may have succeeded or not)
1388  // and publish the results to other threads by unlocking the mutex.
1389  // Sets _initializationWasSuccessful and unlocks _initializationMutex.
1390  void _FinishInitialization(bool success);
1392  // Layers retrieved from the layer registry may still be in the
1393  // process of having their contents initialized. Other threads
1394  // retrieving layers from the registry must wait until initialization
1395  // is complete, using this method. See _initializationMutex.
1396  // Returns _initializationWasSuccessful.
1397  //
1398  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1399  // ensure that it is not deleted out from under them, in
1400  // case initialization fails. (This method cannot acquire the
1401  // reference itself internally without being susceptible to a race.)
1402  bool _WaitForInitializationAndCheckIfSuccessful();
1404  // Returns whether or not this menv layer should post change
1405  // notification. This simply returns (!_GetIsLoading())
1406  bool _ShouldNotify() const;
1408  // This function keeps track of the last state of IsDirty() before
1409  // updating it. It returns false if the last saved dirty state is the
1410  // same than the current state. It returns true if the state differs and
1411  // will update the 'last dirty state' to the current state. So, after
1412  // returning true, it would return false for subsequent calls until the
1413  // IsDirty() state would change again...
1414  bool _UpdateLastDirtinessState() const;
1416  // Returns a handle to the spec at the given path if it exists and matches
1417  // type T.
1418  template <class T>
1419  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1421  // Returns true if a spec can be retrieved at the given path, false
1422  // otherwise. This function will return the canonicalized path to the
1423  // spec as well as the spec type.
1424  bool _CanGetSpecAtPath(const SdfPath& path,
1425  SdfPath* canonicalPath, SdfSpecType* specType) const;
1430  void _InitializeFromIdentifier(
1431  const std::string &identifier,
1432  const std::string &realPath = std::string(),
1433  const std::string &fileVersion = std::string(),
1434  const ArAssetInfo& assetInfo = ArAssetInfo());
1436  // Helper for computing the necessary information to lookup a layer
1437  // in the registry or open the layer.
1438  struct _FindOrOpenLayerInfo;
1439  static bool _ComputeInfoToFindOrOpenLayer(
1440  const std::string& identifier,
1441  const SdfLayer::FileFormatArguments& args,
1442  _FindOrOpenLayerInfo* info,
1443  bool computeAssetInfo = false);
1445  // Open a layer, adding an entry to the registry and releasing
1446  // the registry lock.
1447  // Precondition: _layerRegistryMutex must be locked.
1448  template <class Lock>
1449  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1450  Lock &lock,
1451  const _FindOrOpenLayerInfo& info,
1452  bool metadataOnly);
1454  // Helper function to try to find the layer with \p identifier and
1455  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1456  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1457  // released upon return. Otherwise the lock is released upon return if a
1458  // layer is found successfully. If no layer is found then the lock is
1459  // upgraded to a writer lock upon return. Note that this upgrade may not be
1460  // atomic, but this function ensures that if upon return there does not
1461  // exist a matching layer in the registry.
1462  template <class ScopedLock>
1463  static SdfLayerRefPtr
1464  _TryToFindLayer(const std::string &identifier,
1465  const std::string &resolvedPath,
1466  ScopedLock &lock, bool retryAsWriter);
1475  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1476  bool requiredFieldOnlyPropertiesAreInert = false) const;
1486  bool _IsInertSubtree(const SdfPath &path,
1487  std::vector<SdfPath>* inertSpecs = nullptr);
1494  void _RemoveIfInert(const SdfSpec& spec);
1500  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1504  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1507  bool _ValidateAuthoring() const { return _validateAuthoring; }
1510  std::string _GetMutedPath() const;
1512  // If old and new asset path is given, rename all external prim
1513  // references referring to the old path.
1514  void _UpdateReferencePaths(const SdfPrimSpecHandle &parent,
1515  const std::string &oldLayerPath,
1516  const std::string &newLayerPath);
1518  // Set the clean state to the current state.
1519  void _MarkCurrentStateAsClean() const;
1521  // Return the field definition for \p fieldName if \p fieldName is a
1522  // required field for the spec type identified by \p path.
1523  inline SdfSchema::FieldDefinition const *
1524  _GetRequiredFieldDef(const SdfPath &path,
1525  const TfToken &fieldName,
1526  SdfSpecType specType = SdfSpecTypeUnknown) const;
1528  // Set a value.
1529  template <class T>
1530  void _SetValue(const TfToken& key, T value);
1532  // Get a value.
1533  template <class T>
1534  T _GetValue(const TfToken& key) const;
1536  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1537  _ReloadResult _Reload(bool force);
1539  // Reads contents of asset specified by \p identifier with resolved
1540  // path \p resolvedPath into this layer.
1541  bool _Read(const std::string& identifier,
1542  const std::string& resolvedPath,
1543  bool metadataOnly);
1545  // Saves this layer if it is dirty or the layer doesn't already exist
1546  // on disk. If \p force is true, the layer will be written out
1547  // regardless of those conditions.
1548  bool _Save(bool force) const;
1550  // A helper method used by Save and Export.
1551  // This method allows Save to specify the existing file format and Export
1552  // to use the format provided by the file extension in newFileName. If no
1553  // file format can be discovered from the file name, the existing file
1554  // format associated with the layer will be used in both cases. This allows
1555  // users to export and save to any file name, regardless of extension.
1556  bool _WriteToFile(const std::string& newFileName,
1557  const std::string& comment,
1558  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1559  const FileFormatArguments& args = FileFormatArguments())
1560  const;
1562  // Swap contents of _data and data. This operation does not register
1563  // inverses or emit change notification.
1564  void _SwapData(SdfAbstractDataRefPtr &data);
1566  // Set _data to match data, calling other primitive setter methods
1567  // to provide fine-grained inverses and notification.
1568  void _SetData(const SdfAbstractDataPtr &data);
1570  // Returns const handle to _data.
1571  SdfAbstractDataConstPtr _GetData() const;
1573  // Inverse primitive for setting a single field.
1574  template <class T>
1575  void _PrimSetField(const SdfPath& path,
1576  const TfToken& fieldName,
1577  const T& value,
1578  const VtValue *oldValue = NULL,
1579  bool useDelegate = true);
1581  // Inverse primitive for setting a single key in a dict-valued field.
1582  template <class T>
1583  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1584  const TfToken& fieldName,
1585  const TfToken& keyPath,
1586  const T& value,
1587  const VtValue *oldValue = NULL,
1588  bool useDelegate = true);
1590  // Primitive for appending a child to the list of children.
1591  template <class T>
1592  void _PrimPushChild(const SdfPath& parentPath,
1593  const TfToken& fieldName,
1594  const T& value,
1595  bool useDelegate = true);
1596  template <class T>
1597  void _PrimPopChild(const SdfPath& parentPath,
1598  const TfToken& fieldName,
1599  bool useDelegate = true);
1601  // Move all the fields at all paths at or below \a oldPath to be
1602  // at a corresponding location at or below \a newPath. This does
1603  // not update the children fields of the parents of these paths.
1604  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1606  // Inverse primitive for moving a spec.
1607  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1608  bool useDelegate = true);
1610  // Create a new spec of type \p specType at \p path.
1611  // Returns true if spec was successfully created, false otherwise.
1612  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1614  // Delete all the fields at or below the specified path. This does
1615  // not update the children field of the parent of \a path.
1616  bool _DeleteSpec(const SdfPath &path);
1618  // Inverse primitive for deleting a spec.
1619  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1620  bool useDelegate = true);
1622  // Inverse primitive for deleting a spec.
1623  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1624  bool useDelegate = true);
1626  // Inverse primitive for setting time samples.
1627  template <class T>
1628  void _PrimSetTimeSample(const SdfPath& path, double time,
1629  const T& value,
1630  bool useDelegate = true);
1632  // Helper method for Traverse. Visits the children of \a path using the
1633  // specified \a ChildPolicy.
1634  template <typename ChildPolicy>
1635  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1637 private:
1638  // File format and arguments for this layer.
1639  SdfFileFormatConstPtr _fileFormat;
1640  FileFormatArguments _fileFormatArgs;
1642  // Registry of Sdf Identities
1643  mutable Sdf_IdentityRegistry _idRegistry;
1645  // The underlying SdfData which stores all the data in the layer.
1646  SdfAbstractDataRefPtr _data;
1648  // The state delegate for this layer.
1649  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1651  // Mutex protecting layer initialization -- the interval between
1652  // adding a layer to the layer registry, and finishing the process
1653  // of initialization its contents, at which point we can truly publish
1654  // the layer. We add the layer to the registry before initialization
1655  // completes so that other threads can discover and block on the
1656  // same layer while it is being initialized.
1657  std::mutex _initializationMutex;
1659  // This is an optional<bool> that is only set once initialization
1660  // is complete, while _initializationMutex is locked. If the
1661  // optional<bool> is unset, initialization is still underway.
1662  boost::optional<bool> _initializationWasSuccessful;
1664  // remembers the last 'IsDirty' state.
1665  mutable bool _lastDirtyState;
1667  // Asset information for this layer.
1668  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1670  // Modification timestamp of the backing file asset when last read.
1671  mutable VtValue _assetModificationTime;
1673  // Mutable revision number for cache invalidation.
1674  mutable size_t _mutedLayersRevisionCache;
1676  // Cache of whether or not this layer is muted. Only valid if
1677  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1678  mutable bool _isMutedCache;
1680  // Layer permission bits.
1681  bool _permissionToEdit;
1682  bool _permissionToSave;
1684  // Whether layer edits are validated.
1685  bool _validateAuthoring;
1687  // Allow access to _ValidateAuthoring() and _IsInert().
1688  friend class SdfSpec;
1689  friend class SdfPropertySpec;
1690  friend class SdfAttributeSpec;
1692  friend class Sdf_ChangeManager;
1694  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1695  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1697  // Give the file format access to our data. Limit breaking encapsulation
1698  // to the base SdFileFormat class so we don't have to friend every
1699  // implementation here.
1700  friend class SdfFileFormat;
1702  // Give layer state delegates access to our data as well as to
1703  // the various _Prim functions.
1704  friend class SdfLayerStateDelegateBase;
1705 };
1709 #endif // 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:554
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:93
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 from disk...
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:534
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 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 specifiers for path.
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 RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:472
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:514
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:61
std::function< void(const SdfPath &)> TraversalFunction
Callback function for Traverse.
Definition: layer.h:687
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.
An enum that specifies the type of an object.
Definition: types.h:91
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 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.
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())
Returns the layer for the given path if found in the layer registry.
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:72
static SDF_API SdfLayerHandle FindRelativeToLayer(const SdfLayerHandle &anchor, const std::string &layerPath, const FileFormatArguments &args=FileFormatArguments())
Returns the layer for layerPath, assumed to be relative to the path of the anchor 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:89
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:578
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:441
SDF_API std::set< std::string > GetExternalReferences()
Return paths of all external references of layer.
virtual SDF_API ~SdfLayer()
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...
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.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:119
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:654
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 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:287
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const std::string &realPath=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier for a given file format class.
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
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:625
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.
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 UpdateAssetInfo(const std::string &fileVersion=std::string())
Update layer asset information.
SDF_API void Clear()
Clears the layer of all content.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const std::string &realPath=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
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.
static SDF_API std::string ComputeRealPath(const std::string &layerPath)
Converts layerPath to a file system path.
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
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:601
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:63
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 std::string ComputeAbsolutePath(const std::string &relativePath)
Make the given relativePath absolute using the identifier of this layer.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer&#39;s root prims.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142
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:182
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 file system path where this layer exists or may exist after a call to Save...
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.
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.