layer.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_SDF_LAYER_H
25 #define PXR_USD_SDF_LAYER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/data.h"
33 #include "pxr/usd/sdf/identity.h"
34 #include "pxr/usd/sdf/layerHints.h"
37 #include "pxr/usd/sdf/path.h"
38 #include "pxr/usd/sdf/proxyTypes.h"
39 #include "pxr/usd/sdf/spec.h"
40 #include "pxr/usd/sdf/types.h"
41 #include "pxr/usd/ar/ar.h"
42 #include "pxr/usd/ar/assetInfo.h"
45 #include "pxr/base/vt/value.h"
47 
48 #include <boost/optional.hpp>
49 
50 #include <atomic>
51 #include <functional>
52 #include <memory>
53 #include <set>
54 #include <string>
55 #include <vector>
56 
57 PXR_NAMESPACE_OPEN_SCOPE
58 
61 
62 struct Sdf_AssetInfo;
63 
94 class SdfLayer
95  : public TfRefBase
96  , public TfWeakBase
97 {
98 public:
100  SDF_API
101  virtual ~SdfLayer();
102 
104  SdfLayer(const SdfLayer&) = delete;
105  SdfLayer& operator=(const SdfLayer&) = delete;
106 
110 
113  SDF_API const SdfSchemaBase& GetSchema() const;
114 
116  SDF_API const SdfFileFormatConstPtr& GetFileFormat() const;
117 
120  typedef std::map<std::string, std::string> FileFormatArguments;
121 
124  SDF_API const FileFormatArguments& GetFileFormatArguments() const;
125 
131  SDF_API
132  static SdfLayerRefPtr CreateNew(const std::string &identifier,
133  const FileFormatArguments &args =
135 
142  SDF_API
143  static SdfLayerRefPtr CreateNew(const SdfFileFormatConstPtr& fileFormat,
144  const std::string &identifier,
145  const FileFormatArguments &args =
147 
156  SDF_API
157  static SdfLayerRefPtr New(const SdfFileFormatConstPtr& fileFormat,
158  const std::string &identifier,
159  const FileFormatArguments &args =
161 
168  SDF_API
169  static SdfLayerHandle Find(
170  const std::string &identifier,
171  const FileFormatArguments &args = FileFormatArguments());
172 
183  SDF_API
184  static SdfLayerHandle FindRelativeToLayer(
185  const SdfLayerHandle &anchor,
186  const std::string &identifier,
187  const FileFormatArguments &args = FileFormatArguments());
188 
195  SDF_API
196  static SdfLayerRefPtr FindOrOpen(
197  const std::string &identifier,
198  const FileFormatArguments &args = FileFormatArguments());
199 
210  SDF_API
212  const SdfLayerHandle &anchor,
213  const std::string &identifier,
214  const FileFormatArguments &args = FileFormatArguments());
215 
229  SDF_API
231  const std::string &layerPath,
232  bool metadataOnly = false,
233  const std::string& tag = std::string());
234 
236  SDF_API
237  SdfDataRefPtr GetMetadata() const;
238 
242  SDF_API
243  SdfLayerHints GetHints() const;
244 
246  SDF_API
247  static SdfLayerHandleSet GetLoadedLayers();
248 
250  SDF_API
251  bool IsEmpty() const;
252 
255  SDF_API
256  void TransferContent(const SdfLayerHandle& layer);
257 
272  SDF_API
274  const std::string& tag = std::string(),
275  const FileFormatArguments& args = FileFormatArguments());
276 
278  SDF_API
280  const std::string &tag, const SdfFileFormatConstPtr &format,
281  const FileFormatArguments& args = FileFormatArguments());
282 
284  SDF_API
285  bool IsAnonymous() const;
286 
289  SDF_API
290  static bool IsAnonymousLayerIdentifier(const std::string& identifier);
291 
294  SDF_API
295  static std::string GetDisplayNameFromIdentifier(
296  const std::string& identifier);
297 
301 
306  SDF_API
307  bool Save(bool force = false) const;
308 
321  SDF_API
322  bool Export(const std::string& filename,
323  const std::string& comment = std::string(),
324  const FileFormatArguments& args = FileFormatArguments()) const;
325 
330  SDF_API
331  bool ExportToString(std::string* result) const;
332 
336  SDF_API
337  bool ImportFromString(const std::string &string);
338 
346  SDF_API
347  void Clear();
348 
370  SDF_API
371  bool Reload(bool force = false);
372 
379  SDF_API
380  static bool ReloadLayers(const std::set<SdfLayerHandle>& layers,
381  bool force = false);
382 
388  SDF_API
389  bool Import(const std::string &layerPath);
390 
394 
397  SDF_API
398  std::set<std::string> GetExternalReferences() const;
399 
402  SDF_API
404  const std::string &oldAssetPath,
405  const std::string &newAssetPath=std::string());
406 
414  SDF_API
415  std::set<std::string> GetCompositionAssetDependencies() const;
416 
426  SDF_API
428  const std::string &oldAssetPath,
429  const std::string &newAssetPath=std::string());
430 
439  SDF_API
440  std::set<std::string> GetExternalAssetDependencies() const;
441 
461 
464  SDF_API
465  static bool SplitIdentifier(
466  const std::string& identifier,
467  std::string* layerPath,
468  FileFormatArguments* arguments);
469 
471  SDF_API
472  static std::string CreateIdentifier(
473  const std::string& layerPath,
474  const FileFormatArguments& arguments);
475 
477  SDF_API
478  const std::string& GetIdentifier() const;
479 
483  SDF_API
484  void SetIdentifier(const std::string& identifier);
485 
490 #if AR_VERSION == 1
491  SDF_API
492  void UpdateAssetInfo(const std::string& fileVersion = std::string());
493 #else
494  SDF_API
495  void UpdateAssetInfo();
496 #endif
497 
501  SDF_API
502  std::string GetDisplayName() const;
503 
506  SDF_API
507  const ArResolvedPath& GetResolvedPath() const;
508 
511  SDF_API
512  const std::string& GetRealPath() const;
513 
518  SDF_API
519  std::string GetFileExtension() const;
520 
526  SDF_API
527  const std::string& GetVersion() const;
528 
533  SDF_API
534  const std::string& GetRepositoryPath() const;
535 
537  SDF_API
538  const std::string& GetAssetName() const;
539 
542  SDF_API
543  const VtValue& GetAssetInfo() const;
544 
560  SDF_API
561  std::string ComputeAbsolutePath(const std::string& assetPath) const;
562 
564 
575 
578  SDF_API
579  SdfSpecType GetSpecType(const SdfPath& path) const;
580 
582  SDF_API
583  bool HasSpec(const SdfPath& path) const;
584 
586  SDF_API
587  std::vector<TfToken> ListFields(const SdfPath& path) const;
588 
591  SDF_API
592  bool HasField(const SdfPath& path, const TfToken& fieldName,
593  VtValue *value=NULL) const;
594  SDF_API
595  bool HasField(const SdfPath& path, const TfToken& fieldName,
596  SdfAbstractDataValue *value) const;
597 
601  template <class T>
602  bool HasField(const SdfPath& path, const TfToken &name,
603  T* value) const
604  {
605  if (!value) {
606  return HasField(path, name, static_cast<VtValue *>(NULL));
607  }
608 
609  SdfAbstractDataTypedValue<T> outValue(value);
610  const bool hasValue = HasField(
611  path, name, static_cast<SdfAbstractDataValue *>(&outValue));
612 
613  if (std::is_same<T, SdfValueBlock>::value) {
614  return hasValue && outValue.isValueBlock;
615  }
616 
617  return hasValue && (!outValue.isValueBlock);
618  }
619 
622  std::type_info const &GetFieldTypeid(
623  const SdfPath &path, const TfToken &name) const {
624  return _data->GetTypeid(path, name);
625  }
626 
630  SDF_API
631  bool HasFieldDictKey(const SdfPath& path,
632  const TfToken &fieldName,
633  const TfToken &keyPath,
634  VtValue *value=NULL) const;
635  SDF_API
636  bool HasFieldDictKey(const SdfPath& path,
637  const TfToken &fieldName,
638  const TfToken &keyPath,
639  SdfAbstractDataValue *value) const;
640 
645  template <class T>
646  bool HasFieldDictKey(const SdfPath& path, const TfToken &name,
647  const TfToken &keyPath, T* value) const
648  {
649  if (!value) {
650  return HasFieldDictKey(path, name, keyPath,
651  static_cast<VtValue *>(NULL));
652  }
653 
654  SdfAbstractDataTypedValue<T> outValue(value);
655  return HasFieldDictKey(path, name, keyPath,
656  static_cast<SdfAbstractDataValue *>(&outValue));
657  }
658 
659 
662  SDF_API
663  VtValue GetField(const SdfPath& path,
664  const TfToken& fieldName) const;
665 
668  template <class T>
669  inline T GetFieldAs(const SdfPath& path,
670  const TfToken& fieldName, const T& defaultValue = T()) const
671  {
672  return _data->GetAs<T>(path, fieldName, defaultValue);
673  }
674 
678  SDF_API
680  const TfToken& fieldName,
681  const TfToken& keyPath) const;
682 
684  SDF_API
685  void SetField(const SdfPath& path, const TfToken& fieldName,
686  const VtValue& value);
687  SDF_API
688  void SetField(const SdfPath& path, const TfToken& fieldName,
689  const SdfAbstractDataConstValue& value);
690 
692  template <class T>
693  void SetField(const SdfPath& path, const TfToken& fieldName,
694  const T& val)
695  {
696  // Ideally, this would make use of the SdfAbstractDataConstValue
697  // API to avoid unnecessarily copying the value into a VtValue.
698  // However, Sdf needs to create a VtValue for change processing.
699  // If the underlying SdAbstractData implementation also needs a
700  // VtValue, using the SdfAbstractDataConstValue API would cause
701  // another copy to be made. So, it's more efficient to just create
702  // the VtValue once here and push that along.
703  SetField(path, fieldName, VtValue(val));
704  }
705 
708  SDF_API
709  void SetFieldDictValueByKey(const SdfPath& path,
710  const TfToken& fieldName,
711  const TfToken& keyPath,
712  const VtValue& value);
713  SDF_API
714  void SetFieldDictValueByKey(const SdfPath& path,
715  const TfToken& fieldName,
716  const TfToken& keyPath,
717  const SdfAbstractDataConstValue& value);
718 
721  template <class T>
722  void SetFieldDictValueByKey(const SdfPath& path,
723  const TfToken& fieldName,
724  const TfToken& keyPath,
725  const T& val)
726  {
727  // Ideally, this would make use of the SdfAbstractDataConstValue
728  // API to avoid unnecessarily copying the value into a VtValue.
729  // However, Sdf needs to create a VtValue for change processing.
730  // If the underlying SdAbstractData implementation also needs
731  // VtValue, using the SdfAbstractDataConstValue API would cause
732  // another copy to be made. So, it's more efficient to just create
733  // the VtValue once here and push that along.
734  SetFieldDictValueByKey(path, fieldName, keyPath, VtValue(val));
735  }
736 
738  SDF_API
739  void EraseField(const SdfPath& path, const TfToken& fieldName);
740 
744  SDF_API
745  void EraseFieldDictValueByKey(const SdfPath& path,
746  const TfToken& fieldName,
747  const TfToken& keyPath);
748 
751 
755  typedef std::function<void(const SdfPath&)> TraversalFunction;
756 
757  // Traverse will perform a traversal of the scene description hierarchy
758  // rooted at \a path, calling \a func on each spec that it finds.
759  SDF_API
760  void Traverse(const SdfPath& path, const TraversalFunction& func);
761 
763 
766 
770  SDF_API
772 
774  SDF_API
775  void SetColorConfiguration(const SdfAssetPath &colorConfiguration);
776 
779  SDF_API
780  bool HasColorConfiguration() const;
781 
784  SDF_API
786 
794  SDF_API
796 
799  SDF_API
800  void SetColorManagementSystem(const TfToken &cms);
801 
804  SDF_API
805  bool HasColorManagementSystem() const;
806 
809  SDF_API
811 
815  SDF_API
816  std::string GetComment() const;
817 
819  SDF_API
820  void SetComment(const std::string &comment);
821 
827  SDF_API
828  TfToken GetDefaultPrim() const;
829 
835  SDF_API
836  void SetDefaultPrim(const TfToken &name);
837 
840  SDF_API
841  void ClearDefaultPrim();
842 
845  SDF_API
846  bool HasDefaultPrim();
847 
851  SDF_API
852  std::string GetDocumentation() const;
853 
855  SDF_API
856  void SetDocumentation(const std::string &documentation);
857 
865  SDF_API
866  double GetStartTimeCode() const;
867 
869  SDF_API
870  void SetStartTimeCode(double startTimecode);
871 
873  SDF_API
874  bool HasStartTimeCode() const;
875 
877  SDF_API
878  void ClearStartTimeCode();
879 
886  SDF_API
887  double GetEndTimeCode() const;
888 
890  SDF_API
891  void SetEndTimeCode(double endTimeCode);
892 
894  SDF_API
895  bool HasEndTimeCode() const;
896 
898  SDF_API
899  void ClearEndTimeCode();
900 
916  SDF_API
917  double GetTimeCodesPerSecond() const;
918 
920  SDF_API
921  void SetTimeCodesPerSecond(double timeCodesPerSecond);
922 
924  SDF_API
925  bool HasTimeCodesPerSecond() const;
926 
928  SDF_API
930 
940  SDF_API
941  double GetFramesPerSecond() const;
942 
944  SDF_API
945  void SetFramesPerSecond(double framesPerSecond);
946 
948  SDF_API
949  bool HasFramesPerSecond() const;
950 
952  SDF_API
953  void ClearFramesPerSecond();
954 
956  SDF_API
957  int GetFramePrecision() const;
958 
960  SDF_API
961  void SetFramePrecision(int framePrecision);
962 
964  SDF_API
965  bool HasFramePrecision() const;
966 
968  SDF_API
969  void ClearFramePrecision();
970 
972  SDF_API
973  std::string GetOwner() const;
974 
976  SDF_API
977  void SetOwner(const std::string& owner);
978 
980  SDF_API
981  bool HasOwner() const;
982 
984  SDF_API
985  void ClearOwner();
986 
989  SDF_API
990  std::string GetSessionOwner() const;
991 
994  SDF_API
995  void SetSessionOwner(const std::string& owner);
996 
998  SDF_API
999  bool HasSessionOwner() const;
1000 
1001  // Clear the session owner opinion.
1002  SDF_API
1003  void ClearSessionOwner();
1004 
1006  SDF_API
1007  bool GetHasOwnedSubLayers() const;
1008 
1010  SDF_API
1011  void SetHasOwnedSubLayers(bool);
1012 
1018  SDF_API
1020 
1022  SDF_API
1023  void SetCustomLayerData(const VtDictionary& value);
1024 
1026  SDF_API
1027  bool HasCustomLayerData() const;
1028 
1030  SDF_API
1031  void ClearCustomLayerData();
1032 
1036 
1037  // Type for root prims view.
1039 
1041  SDF_API
1042  RootPrimsView GetRootPrims() const;
1043 
1048  SDF_API
1049  void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims);
1050 
1056  SDF_API
1057  bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index = -1);
1058 
1060  SDF_API
1061  void RemoveRootPrim(const SdfPrimSpecHandle &prim);
1062 
1065  SDF_API
1066  void ScheduleRemoveIfInert(const SdfSpec& spec);
1067 
1080  SDF_API
1081  void RemovePrimIfInert(SdfPrimSpecHandle prim);
1082 
1089  SDF_API
1090  void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop);
1091 
1097  SDF_API
1099 
1104  SDF_API
1106 
1115  SDF_API
1116  void SetRootPrimOrder(const std::vector<TfToken>& names);
1117 
1120  SDF_API
1121  void InsertInRootPrimOrder(const TfToken &name, int index = -1);
1122 
1124  SDF_API
1125  void RemoveFromRootPrimOrder(const TfToken & name);
1126 
1128  SDF_API
1129  void RemoveFromRootPrimOrderByIndex(int index);
1130 
1136  SDF_API
1137  void ApplyRootPrimOrder(std::vector<TfToken> *vec) const;
1138 
1142 
1155  SDF_API
1157 
1159  SDF_API
1160  void SetSubLayerPaths(const std::vector<std::string>& newPaths);
1161 
1163  SDF_API
1164  size_t GetNumSubLayerPaths() const;
1165 
1169  SDF_API
1170  void InsertSubLayerPath(const std::string& path, int index = -1);
1171 
1173  SDF_API
1174  void RemoveSubLayerPath(int index);
1175 
1177  SDF_API
1178  SdfLayerOffsetVector GetSubLayerOffsets() const;
1179 
1181  SDF_API
1182  SdfLayerOffset GetSubLayerOffset(int index) const;
1183 
1185  SDF_API
1186  void SetSubLayerOffset(const SdfLayerOffset& offset, int index);
1187 
1191 
1193  SDF_API
1194  static std::set<std::string> GetMutedLayers();
1195 
1197  SDF_API
1198  bool IsMuted() const;
1199 
1201  SDF_API
1202  static bool IsMuted(const std::string &path);
1203 
1206  SDF_API
1207  void SetMuted(bool muted);
1208 
1210  SDF_API
1211  static void AddToMutedLayers(const std::string &mutedPath);
1212 
1214  SDF_API
1215  static void RemoveFromMutedLayers(const std::string &mutedPath);
1216 
1220 
1229  SDF_API
1230  SdfPrimSpecHandle GetPseudoRoot() const;
1231 
1238  SDF_API
1239  SdfSpecHandle GetObjectAtPath(const SdfPath &path);
1240 
1246  SDF_API
1247  SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path);
1248 
1254  SDF_API
1255  SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path);
1256 
1262  SDF_API
1263  SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path);
1264 
1270  SDF_API
1271  SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path);
1272 
1276 
1280  SDF_API
1281  bool PermissionToEdit() const;
1282 
1285  SDF_API
1286  bool PermissionToSave() const;
1287 
1289  SDF_API
1290  void SetPermissionToEdit(bool allow);
1291 
1293  SDF_API
1294  void SetPermissionToSave(bool allow);
1295 
1299 
1323  SDF_API
1326  SdfNamespaceEditDetailVector* details = NULL) const;
1327 
1331  SDF_API
1332  bool Apply(const SdfBatchNamespaceEdit&);
1333 
1337 
1340  SDF_API
1341  SdfLayerStateDelegateBasePtr GetStateDelegate() const;
1342 
1346  SDF_API
1347  void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr& delegate);
1348 
1351  SDF_API
1352  bool IsDirty() const;
1353 
1355 
1358  SDF_API
1359  std::set<double> ListAllTimeSamples() const;
1360 
1361  SDF_API
1362  std::set<double>
1363  ListTimeSamplesForPath(const SdfPath& path) const;
1364 
1365  SDF_API
1366  bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper);
1367 
1368  SDF_API
1369  size_t GetNumTimeSamplesForPath(const SdfPath& path) const;
1370 
1371  SDF_API
1372  bool GetBracketingTimeSamplesForPath(const SdfPath& path,
1373  double time,
1374  double* tLower, double* tUpper);
1375 
1376  SDF_API
1377  bool QueryTimeSample(const SdfPath& path, double time,
1378  VtValue *value=NULL) const;
1379  SDF_API
1380  bool QueryTimeSample(const SdfPath& path, double time,
1381  SdfAbstractDataValue *value) const;
1382 
1383  template <class T>
1384  bool QueryTimeSample(const SdfPath& path, double time,
1385  T* data) const
1386  {
1387  if (!data) {
1388  return QueryTimeSample(path, time);
1389  }
1390 
1391  SdfAbstractDataTypedValue<T> outValue(data);
1392  const bool hasValue = QueryTimeSample(
1393  path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1394 
1395  if (std::is_same<T, SdfValueBlock>::value) {
1396  return hasValue && outValue.isValueBlock;
1397  }
1398 
1399  return hasValue && (!outValue.isValueBlock);
1400  }
1401 
1402  SDF_API
1403  void SetTimeSample(const SdfPath& path, double time,
1404  const VtValue & value);
1405  SDF_API
1406  void SetTimeSample(const SdfPath& path, double time,
1407  const SdfAbstractDataConstValue& value);
1408 
1409  template <class T>
1410  void SetTimeSample(const SdfPath& path, double time,
1411  const T& value)
1412  {
1413  const SdfAbstractDataConstTypedValue<T> inValue(&value);
1414  const SdfAbstractDataConstValue& untypedInValue = inValue;
1415  return SetTimeSample(path, time, untypedInValue);
1416  }
1417 
1418  SDF_API
1419  void EraseTimeSample(const SdfPath& path, double time);
1420 
1422 
1423  // Debugging
1424  // @{
1425 
1426  SDF_API
1427  static void DumpLayerInfo();
1428 
1429  // Write this layer's SdfData to a file in a simple generic format.
1430  SDF_API
1431  bool WriteDataFile(const std::string &filename);
1432 
1433  // @}
1434 
1435 protected:
1436  // Private constructor -- use New(), FindOrCreate(), etc.
1437  // Precondition: _layerRegistryMutex must be locked.
1438  SdfLayer(const SdfFileFormatConstPtr& fileFormat,
1439  const std::string &identifier,
1440  const std::string &realPath = std::string(),
1441  const ArAssetInfo& assetInfo = ArAssetInfo(),
1442  const FileFormatArguments &args = FileFormatArguments(),
1443  bool validateAuthoring = false);
1444 
1445 private:
1446  // Create a new layer.
1447  // Precondition: _layerRegistryMutex must be locked.
1448  static SdfLayerRefPtr _CreateNew(
1449  SdfFileFormatConstPtr fileFormat,
1450  const std::string& identifier,
1451  const FileFormatArguments& args);
1452 
1453  static SdfLayerRefPtr _CreateNewWithFormat(
1454  const SdfFileFormatConstPtr &fileFormat,
1455  const std::string& identifier,
1456  const std::string& realPath,
1457  const ArAssetInfo& assetInfo = ArAssetInfo(),
1458  const FileFormatArguments& args = FileFormatArguments());
1459 
1460  static SdfLayerRefPtr _CreateAnonymousWithFormat(
1461  const SdfFileFormatConstPtr &fileFormat,
1462  const std::string& tag,
1463  const FileFormatArguments& args);
1464 
1465  // Finish initializing this layer (which may have succeeded or not)
1466  // and publish the results to other threads by unlocking the mutex.
1467  // Sets _initializationWasSuccessful.
1468  void _FinishInitialization(bool success);
1469 
1470  // Layers retrieved from the layer registry may still be in the
1471  // process of having their contents initialized. Other threads
1472  // retrieving layers from the registry must wait until initialization
1473  // is complete, using this method.
1474  // Returns _initializationWasSuccessful.
1475  //
1476  // Callers *must* be holding an SdfLayerRefPtr to this layer to
1477  // ensure that it is not deleted out from under them, in
1478  // case initialization fails. (This method cannot acquire the
1479  // reference itself internally without being susceptible to a race.)
1480  bool _WaitForInitializationAndCheckIfSuccessful();
1481 
1482  // Returns whether or not this menv layer should post change
1483  // notification. This simply returns (!_GetIsLoading())
1484  bool _ShouldNotify() const;
1485 
1486  // This function keeps track of the last state of IsDirty() before
1487  // updating it. It returns false if the last saved dirty state is the
1488  // same than the current state. It returns true if the state differs and
1489  // will update the 'last dirty state' to the current state. So, after
1490  // returning true, it would return false for subsequent calls until the
1491  // IsDirty() state would change again...
1492  bool _UpdateLastDirtinessState() const;
1493 
1494  // Returns a handle to the spec at the given path if it exists and matches
1495  // type T.
1496  template <class T>
1497  SdfHandle<T> _GetSpecAtPath(const SdfPath& path);
1498 
1499  // Returns true if a spec can be retrieved at the given path, false
1500  // otherwise. This function will return the canonicalized path to the
1501  // spec as well as the spec type.
1502  bool _CanGetSpecAtPath(const SdfPath& path,
1503  SdfPath* canonicalPath, SdfSpecType* specType) const;
1504 
1508  void _InitializeFromIdentifier(
1509  const std::string &identifier,
1510  const std::string &realPath = std::string(),
1511  const std::string &fileVersion = std::string(),
1512  const ArAssetInfo& assetInfo = ArAssetInfo());
1513 
1514  // Helper for computing the necessary information to lookup a layer
1515  // in the registry or open the layer.
1516  struct _FindOrOpenLayerInfo;
1517  static bool _ComputeInfoToFindOrOpenLayer(
1518  const std::string& identifier,
1519  const SdfLayer::FileFormatArguments& args,
1520  _FindOrOpenLayerInfo* info,
1521  bool computeAssetInfo = false);
1522 
1523  // Open a layer, adding an entry to the registry and releasing
1524  // the registry lock.
1525  // Precondition: _layerRegistryMutex must be locked.
1526  template <class Lock>
1527  static SdfLayerRefPtr _OpenLayerAndUnlockRegistry(
1528  Lock &lock,
1529  const _FindOrOpenLayerInfo& info,
1530  bool metadataOnly);
1531 
1532  // Helper function for finding a layer with \p identifier and \p args.
1533  // \p lock must be unlocked initially and will be locked by this
1534  // function when needed. See docs for \p retryAsWriter argument on
1535  // _TryToFindLayer for details on the final state of the lock when
1536  // this function returns.
1537  template <class ScopedLock>
1538  static SdfLayerRefPtr
1539  _Find(const std::string &identifier,
1540  const FileFormatArguments &args,
1541  ScopedLock &lock, bool retryAsWriter);
1542 
1543  // Helper function to try to find the layer with \p identifier and
1544  // pre-resolved path \p resolvedPath in the registry. Caller must hold
1545  // registry \p lock for reading. If \p retryAsWriter is false, lock is
1546  // released upon return. Otherwise the lock is released upon return if a
1547  // layer is found successfully. If no layer is found then the lock is
1548  // upgraded to a writer lock upon return. Note that this upgrade may not be
1549  // atomic, but this function ensures that if upon return there does not
1550  // exist a matching layer in the registry.
1551  template <class ScopedLock>
1552  static SdfLayerRefPtr
1553  _TryToFindLayer(const std::string &identifier,
1554  const std::string &resolvedPath,
1555  ScopedLock &lock, bool retryAsWriter);
1556 
1564  bool _IsInert(const SdfPath &path, bool ignoreChildren,
1565  bool requiredFieldOnlyPropertiesAreInert = false) const;
1566 
1575  bool _IsInertSubtree(const SdfPath &path,
1576  std::vector<SdfPath>* inertSpecs = nullptr);
1577 
1583  void _RemoveIfInert(const SdfSpec& spec);
1584 
1589  bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1590 
1593  void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1594 
1596  bool _ValidateAuthoring() const { return _validateAuthoring; }
1597 
1599  std::string _GetMutedPath() const;
1600 
1601  // If old and new asset path is given, rename all external prim
1602  // composition dependency referring to the old path.
1603  void _UpdatePrimCompositionDependencyPaths(
1604  const SdfPrimSpecHandle &parent,
1605  const std::string &oldLayerPath,
1606  const std::string &newLayerPath);
1607 
1608  // Set the clean state to the current state.
1609  void _MarkCurrentStateAsClean() const;
1610 
1611  // Return the field definition for \p fieldName if \p fieldName is a
1612  // required field for the spec type identified by \p path.
1613  inline SdfSchema::FieldDefinition const *
1614  _GetRequiredFieldDef(const SdfPath &path,
1615  const TfToken &fieldName,
1616  SdfSpecType specType = SdfSpecTypeUnknown) const;
1617 
1618  // Return the field definition for \p fieldName if \p fieldName is a
1619  // required field for \p specType subject to \p schema.
1620  static inline SdfSchema::FieldDefinition const *
1621  _GetRequiredFieldDef(const SdfSchemaBase &schema,
1622  const TfToken &fieldName,
1623  SdfSpecType specType);
1624 
1625  // Helper to list all fields on \p data at \p path subject to \p schema.
1626  static std::vector<TfToken>
1627  _ListFields(SdfSchemaBase const &schema,
1628  SdfAbstractData const &data, const SdfPath& path);
1629 
1630  // Helper for HasField for \p path in \p data subject to \p schema.
1631  static inline bool
1632  _HasField(const SdfSchemaBase &schema,
1633  const SdfAbstractData &data,
1634  const SdfPath& path,
1635  const TfToken& fieldName,
1636  VtValue *value);
1637 
1638  // Helper to get a field value for \p path in \p data subject to \p schema.
1639  static inline VtValue
1640  _GetField(const SdfSchemaBase &schema,
1641  const SdfAbstractData &data,
1642  const SdfPath& path,
1643  const TfToken& fieldName);
1644 
1645  // Set a value.
1646  template <class T>
1647  void _SetValue(const TfToken& key, T value);
1648 
1649  // Get a value.
1650  template <class T>
1651  T _GetValue(const TfToken& key) const;
1652 
1653  enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1654  _ReloadResult _Reload(bool force);
1655 
1656  // Reads contents of asset specified by \p identifier with resolved
1657  // path \p resolvedPath into this layer.
1658  bool _Read(const std::string& identifier,
1659  const std::string& resolvedPath,
1660  bool metadataOnly);
1661 
1662  // Saves this layer if it is dirty or the layer doesn't already exist
1663  // on disk. If \p force is true, the layer will be written out
1664  // regardless of those conditions.
1665  bool _Save(bool force) const;
1666 
1667  // A helper method used by Save and Export.
1668  // This method allows Save to specify the existing file format and Export
1669  // to use the format provided by the file extension in newFileName. If no
1670  // file format can be discovered from the file name, the existing file
1671  // format associated with the layer will be used in both cases. This allows
1672  // users to export and save to any file name, regardless of extension.
1673  bool _WriteToFile(const std::string& newFileName,
1674  const std::string& comment,
1675  SdfFileFormatConstPtr fileFormat = TfNullPtr,
1676  const FileFormatArguments& args = FileFormatArguments())
1677  const;
1678 
1679  // Swap contents of _data and data. This operation does not register
1680  // inverses or emit change notification.
1681  void _SwapData(SdfAbstractDataRefPtr &data);
1682 
1683  // Set _data to match data, calling other primitive setter methods to
1684  // provide fine-grained inverses and notification. If \p data might adhere
1685  // to a different schema than this layer's, pass a pointer to it as \p
1686  // newDataSchema. In this case, check to see if fields from \p data are
1687  // known to this layer's schema, and if not, omit them and issue a TfError
1688  // with SdfAuthoringErrorUnrecognizedFields, but continue to set all other
1689  // known fields.
1690  void _SetData(const SdfAbstractDataPtr &newData,
1691  const SdfSchemaBase *newDataSchema=nullptr);
1692 
1693  // Returns const handle to _data.
1694  SdfAbstractDataConstPtr _GetData() const;
1695 
1696  // Inverse primitive for setting a single field.
1697  template <class T>
1698  void _PrimSetField(const SdfPath& path,
1699  const TfToken& fieldName,
1700  const T& value,
1701  const VtValue *oldValue = NULL,
1702  bool useDelegate = true);
1703 
1704  // Inverse primitive for setting a single key in a dict-valued field.
1705  template <class T>
1706  void _PrimSetFieldDictValueByKey(const SdfPath& path,
1707  const TfToken& fieldName,
1708  const TfToken& keyPath,
1709  const T& value,
1710  const VtValue *oldValue = NULL,
1711  bool useDelegate = true);
1712 
1713  // Primitive for appending a child to the list of children.
1714  template <class T>
1715  void _PrimPushChild(const SdfPath& parentPath,
1716  const TfToken& fieldName,
1717  const T& value,
1718  bool useDelegate = true);
1719  template <class T>
1720  void _PrimPopChild(const SdfPath& parentPath,
1721  const TfToken& fieldName,
1722  bool useDelegate = true);
1723 
1724  // Move all the fields at all paths at or below \a oldPath to be
1725  // at a corresponding location at or below \a newPath. This does
1726  // not update the children fields of the parents of these paths.
1727  bool _MoveSpec(const SdfPath &oldPath, const SdfPath &newPath);
1728 
1729  // Inverse primitive for moving a spec.
1730  void _PrimMoveSpec(const SdfPath &oldPath, const SdfPath &newPath,
1731  bool useDelegate = true);
1732 
1733  // Create a new spec of type \p specType at \p path.
1734  // Returns true if spec was successfully created, false otherwise.
1735  bool _CreateSpec(const SdfPath& path, SdfSpecType specType, bool inert);
1736 
1737  // Delete all the fields at or below the specified path. This does
1738  // not update the children field of the parent of \a path.
1739  bool _DeleteSpec(const SdfPath &path);
1740 
1741  // Inverse primitive for deleting a spec.
1742  void _PrimCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert,
1743  bool useDelegate = true);
1744 
1745  // Inverse primitive for deleting a spec.
1746  void _PrimDeleteSpec(const SdfPath &path, bool inert,
1747  bool useDelegate = true);
1748 
1749  // Inverse primitive for setting time samples.
1750  template <class T>
1751  void _PrimSetTimeSample(const SdfPath& path, double time,
1752  const T& value,
1753  bool useDelegate = true);
1754 
1755  // Helper method for Traverse. Visits the children of \a path using the
1756  // specified \a ChildPolicy.
1757  template <typename ChildPolicy>
1758  void _TraverseChildren(const SdfPath &path, const TraversalFunction &func);
1759 
1760 private:
1761  SdfLayerHandle _self;
1762 
1763  // File format and arguments for this layer.
1764  SdfFileFormatConstPtr _fileFormat;
1765  FileFormatArguments _fileFormatArgs;
1766 
1767  // Cached reference to the _fileFormat's schema -- we need access to this to
1768  // be as fast as possible since we look at it on every SetField(), for
1769  // example.
1770  const SdfSchemaBase &_schema;
1771 
1772  // Registry of Sdf Identities
1773  mutable Sdf_IdentityRegistry _idRegistry;
1774 
1775  // The underlying SdfData which stores all the data in the layer.
1776  SdfAbstractDataRefPtr _data;
1777 
1778  // The state delegate for this layer.
1779  SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1780 
1781  // Dispatcher used in layer initialization, letting waiters participate in
1782  // loading instead of just busy-waiting.
1783  WorkDispatcher _initDispatcher;
1784 
1785  // Atomic variable protecting layer initialization -- the interval between
1786  // adding a layer to the layer registry and finishing the process of
1787  // initializing its contents, at which point we can truly publish the layer
1788  // for consumption by concurrent threads. We add the layer to the registry
1789  // before initialization completes so that other threads can discover and
1790  // wait for it to finish initializing.
1791  std::atomic<bool> _initializationComplete;
1792 
1793  // This is an optional<bool> that is only set once initialization
1794  // is complete, before _initializationComplete is set.
1795  boost::optional<bool> _initializationWasSuccessful;
1796 
1797  // remembers the last 'IsDirty' state.
1798  mutable bool _lastDirtyState;
1799 
1800  // Asset information for this layer.
1801  std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1802 
1803  // Modification timestamp of the backing file asset when last read.
1804  mutable VtValue _assetModificationTime;
1805 
1806  // All external asset dependencies, with their modification timestamps, of
1807  // the layer when last read.
1808  mutable VtDictionary _externalAssetModificationTimes;
1809 
1810  // Mutable revision number for cache invalidation.
1811  mutable size_t _mutedLayersRevisionCache;
1812 
1813  // Cache of whether or not this layer is muted. Only valid if
1814  // _mutedLayersRevisionCache is up-to-date with the global revision number.
1815  mutable bool _isMutedCache;
1816 
1817  // Layer permission bits.
1818  bool _permissionToEdit;
1819  bool _permissionToSave;
1820 
1821  // Whether layer edits are validated.
1822  bool _validateAuthoring;
1823 
1824  // Layer hints as of the most recent save operation.
1825  mutable SdfLayerHints _hints;
1826 
1827  // Allow access to _ValidateAuthoring() and _IsInert().
1828  friend class SdfSpec;
1829  friend class SdfPropertySpec;
1830  friend class SdfAttributeSpec;
1831 
1832  friend class Sdf_ChangeManager;
1833 
1834  // Allow access to _CreateSpec and _DeleteSpec and _MoveSpec
1835  template <class ChildPolicy> friend class Sdf_ChildrenUtils;
1836 
1837  // Give the file format access to our data. Limit breaking encapsulation
1838  // to the base SdFileFormat class so we don't have to friend every
1839  // implementation here.
1840  friend class SdfFileFormat;
1841 
1842  // Give layer state delegates access to our data as well as to
1843  // the various _Prim functions.
1844  friend class SdfLayerStateDelegateBase;
1845 };
1846 
1847 PXR_NAMESPACE_CLOSE_SCOPE
1848 
1849 #endif // PXR_USD_SDF_LAYER_H
SDF_API void SetSessionOwner(const std::string &owner)
Sets the layer's session owner.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
Sets the state delegate used to manage this layer's authoring state.
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:94
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API bool PermissionToSave() const
Returns true if the caller is allowed to save the layer to its existing fileName and false otherwise.
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for the given path and fieldName.
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
SDF_API bool UpdateCompositionAssetDependency(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
Updates the asset path of a composation dependency in this layer.
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
A work dispatcher runs concurrent tasks.
Definition: dispatcher.h:75
SDF_API bool ExportToString(std::string *result) const
Writes this layer to the given string.
Standard pointer typedefs.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:59
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
Returns the object at the given path.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
Performs a batch of namespace edits.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName and keyPath.
SDF_API double GetStartTimeCode() const
Returns the layer's start timeCode.
SDF_API void UpdateAssetInfo()
Update layer asset information.
SDF_API bool Save(bool force=false) const
Returns true if successful, false if an error occurred.
SDF_API bool IsDirty() const
Returns true if the layer is dirty, i.e.
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
SDF_API std::string ComputeAbsolutePath(const std::string &assetPath) const
Returns the path to the asset specified by assetPath using this layer to anchor the path if necessary...
SDF_API std::string GetOwner() const
Returns the layer's owner.
SDF_API std::string GetComment() const
Returns the comment string for this layer.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:498
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:540
static SDF_API SdfLayerRefPtr FindOrOpenRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args, or else load it.
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:394
SDF_API std::set< std::string > GetExternalAssetDependencies() const
Returns a set of resolved paths to all external asset dependencies the layer needs to generate its co...
SDF_API const VtValue & GetAssetInfo() const
Returns resolve information from the last time the layer identifier was resolved.
A map with string keys and VtValue values.
Definition: dictionary.h:63
std::function< void(const SdfPath &)> TraversalFunction
Callback function for Traverse.
Definition: layer.h:755
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
Adds a new root prim at the given index.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
Returns a property at the given path.
Generic class that provides information about scene description fields but doesn't actually provide a...
Definition: schema.h:62
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
Base class for all Sdf spec classes.
Definition: spec.h:51
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
Returns the file format-specific arguments used during the construction of this layer.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API double GetFramesPerSecond() const
Returns the layer's frames per second.
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
Removes scene description that does not affect the scene in the layer namespace beginning with prim.
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
Removes prop if it has only required fields (i.e.
SDF_API std::string GetDocumentation() const
Returns the documentation string for this layer.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
SDF_API bool Export(const std::string &filename, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
Exports this layer to a file.
SDF_API bool ImportFromString(const std::string &string)
Reads this layer from the given string.
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API std::set< std::string > GetCompositionAssetDependencies() const
Return paths of all assets this layer depends on due to composition fields.
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
Inserts new sublayer path at the given index.
SdfHandle is a smart ptr that calls IsDormant() on the pointed-to object as an extra expiration check...
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
SDF_API VtDictionary GetCustomLayerData() const
Returns the CustomLayerData dictionary associated with this layer.
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
Basic Sdf data types.
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
Return the value for the given path and fieldName at keyPath.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
SDF_API void RemoveInertSceneDescription()
Removes all scene description in this layer that does not affect the scene.
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
Returns the state delegate used to manage this layer's authoring state.
static SDF_API SdfLayerHandle Find(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args.
SDF_API bool PermissionToEdit() const
Returns true if the caller is allowed to modify the layer and false otherwise.
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
Sets a new vector of root prims.
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
Returns the list of prim names for this layer's reorder rootPrims statement.
SDF_API SdfLayerHints GetHints() const
Return hints about the layer's current contents.
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
Reloads the specified layers.
SDF_API void SetMuted(bool muted)
Mutes the current layer if muted is true, and unmutes it otherwise.
SDF_API bool HasDefaultPrim()
Return true if the default prim metadata is set in this layer.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDF_API const ArResolvedPath & GetResolvedPath() const
Returns the resolved path for this layer.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
SDF_API bool Reload(bool force=false)
Reloads the layer from its persistent representation.
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:56
Class defining various attributes for a field.
Definition: schema.h:72
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API void SetIdentifier(const std::string &identifier)
Sets the layer identifier.
A description of an arbitrarily complex namespace edit.
SDF_API const SdfSchemaBase & GetSchema() const
Returns the schema this layer adheres to.
Represents a single list of list editing operations.
Definition: listProxy.h:57
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier.
SDF_API void TransferContent(const SdfLayerHandle &layer)
Copies the content of the given layer into this layer.
bool HasField(const SdfPath &path, const TfToken &name, T *value) const
Returns true if the object has a non-empty value with name name and type T.
Definition: layer.h:602
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API TfToken GetColorManagementSystem() const
Returns the color management system used to interpret the color configuration asset-path authored in ...
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:445
virtual SDF_API ~SdfLayer()
Destructor.
SDF_API void SetRootPrimOrder(const std::vector< TfToken > &names)
Given a list of (possible sparse) prim names, authors a reorder rootPrims statement for this prim.
Result
Validity of an edit.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
static SDF_API SdfLayerHandle FindRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Return an existing layer with the given identifier and args.
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:120
SDF_API const std::string & GetRepositoryPath() const
Returns the layer identifier in asset path form.
SDF_API TfToken GetDefaultPrim() const
Return the defaultPrim metadata for this layer.
SDF_API void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)
Set the value of the given path and fieldName.
void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:722
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
Returns a relationship at the given path.
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
Returns the prim at the given path.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
Check if a batch of namespace edits will succeed.
SDF_API const std::string & GetVersion() const
Returns the asset system version of this layer.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
SDF_API void ClearColorConfiguration()
Clears the color configuration metadata authored in this layer.
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
Creates a new empty layer with the given identifier for a given file format class.
SDF_API void ScheduleRemoveIfInert(const SdfSpec &spec)
Cause spec to be removed if it no longer affects the scene when the last change block is closed,...
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
Returns the layer's pseudo-root prim.
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
Adds a new root prim name in the root prim order.
bool HasFieldDictKey(const SdfPath &path, const TfToken &name, const TfToken &keyPath, T *value) const
Returns true if the object has a non-empty value with name name and keyPath and type T.
Definition: layer.h:646
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
Returns a proxy for this layer's sublayers.
SDF_API bool HasColorManagementSystem() const
Returns true if colorManagementSystem metadata is set in this layer.
SDF_API std::string GetDisplayName() const
Returns the layer's display name.
SDF_API void ClearOwner()
Clear the owner opinion.
void SetField(const SdfPath &path, const TfToken &fieldName, const T &val)
Set the value of the given path and fieldName.
Definition: layer.h:693
SDF_API std::string GetFileExtension() const
Returns the file extension to use for this layer.
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
Represents a resolved asset path.
Definition: resolvedPath.h:39
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API void Clear()
Clears the layer of all content.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
static SDF_API std::string GetDisplayNameFromIdentifier(const std::string &identifier)
Returns the display name for the given identifier, using the same rules as GetDisplayName.
SDF_API const std::string & GetRealPath() const
Returns the resolved path for this layer.
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API void SetDefaultPrim(const TfToken &name)
Set the default prim metadata for this layer.
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
SDF_API void ClearColorManagementSystem()
Clears the 'colorManagementSystem' metadata authored in this layer.
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Return the value for the given path and fieldName.
Definition: layer.h:669
SDF_API void ClearDefaultPrim()
Clear the default prim metadata for this layer.
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
SDF_API void EraseFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath)
Remove the field at path and fieldName and keyPath, if one exists.
Contains hints about layer contents that may be used to accelerate certain composition operations.
Definition: layerHints.h:33
SDF_API double GetTimeCodesPerSecond() const
Returns the layer's timeCodes per second.
Provides a view onto an object's children.
Definition: childrenView.h:171
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
Returns an attribute at the given path.
Maintains authoring state information for an associated layer.
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
Returns true if the identifier is an anonymous layer unique identifier.
SDF_API SdfAssetPath GetColorConfiguration() const
Returns the color configuration asset-path for this layer.
SDF_API void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
SDF_API void ApplyRootPrimOrder(std::vector< TfToken > *vec) const
Reorders the given list of prim names according to the reorder rootPrims statement for this layer.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
SDF_API std::string GetSessionOwner() const
Returns the layer's session owner.
Base class for file format implementations.
Definition: fileFormat.h:64
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API double GetEndTimeCode() const
Returns the layer's end timeCode.
SDF_API bool HasColorConfiguration() const
Returns true if color configuration metadata is set in this layer.
SDF_API bool Import(const std::string &layerPath)
Imports the content of the given layer path, replacing the content of the current layer.
static SDF_API bool SplitIdentifier(const std::string &identifier, std::string *layerPath, FileFormatArguments *arguments)
Splits the given layer identifier into its constituent layer path and arguments.
static SDF_API std::string CreateIdentifier(const std::string &layerPath, const FileFormatArguments &arguments)
Joins the given layer path and arguments into an identifier.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
SDF_API void SetColorManagementSystem(const TfToken &cms)
Sets the color management system used to interpret the color configuration asset-path authored this l...
SDF_API void SetPermissionToSave(bool allow)
Sets permission to save.
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
Load the given layer from disk as a new anonymous layer.
std::type_info const & GetFieldTypeid(const SdfPath &path, const TfToken &name) const
Return the type of the value for name on spec path.
Definition: layer.h:622
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
Interface for scene description data storage.
Definition: abstractData.h:73
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
Contains information about a resolved asset.
Definition: assetInfo.h:40
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
Creates a new anonymous layer with an optional tag.