24 #ifndef PXR_USD_SDF_LAYER_H
25 #define PXR_USD_SDF_LAYER_H
172 static SdfLayerHandle
Find(
188 const SdfLayerHandle &anchor,
215 const SdfLayerHandle &anchor,
235 bool metadataOnly =
false,
401 static bool ReloadLayers(
const std::set<SdfLayerHandle>& layers,
622 return HasField(path, name, static_cast<VtValue *>(NULL));
627 path, name, static_cast<SdfAbstractDataValue *>(&outValue));
640 return _data->GetTypeid(path, name);
667 static_cast<VtValue *>(NULL));
672 static_cast<SdfAbstractDataValue *>(&outValue));
680 const TfToken& fieldName)
const;
686 const TfToken& fieldName,
const T& defaultValue =
T())
const
688 return _data->GetAs<
T>(
path, fieldName, defaultValue);
1081 void SetRootPrims(
const SdfPrimSpecHandleVector &rootPrims);
1284 const std::vector<std::string>&
GetIncluded()
const {
return _include; }
1285 const std::vector<std::string>&
GetExcluded()
const {
return _exclude; }
1300 std::vector<std::string> _include;
1301 std::vector<std::string> _exclude;
1302 bool _includeAll =
false;
1527 double* tLower,
double* tUpper);
1546 path, time, static_cast<SdfAbstractDataValue *>(&outValue));
1591 SdfLayer(
const SdfFileFormatConstPtr& fileFormat,
1596 bool validateAuthoring =
false);
1602 SdfFileFormatConstPtr fileFormat,
1605 bool saveLayer =
true);
1608 const SdfFileFormatConstPtr &fileFormat,
1615 const SdfFileFormatConstPtr &fileFormat,
1622 void _FinishInitialization(
bool success);
1634 bool _WaitForInitializationAndCheckIfSuccessful();
1638 bool _ShouldNotify()
const;
1646 bool _UpdateLastDirtinessState()
const;
1656 bool _CanGetSpecAtPath(
const SdfPath& path,
1662 void _InitializeFromIdentifier(
1670 struct _FindOrOpenLayerInfo;
1671 static bool _ComputeInfoToFindOrOpenLayer(
1674 _FindOrOpenLayerInfo* info,
1675 bool computeAssetInfo =
false);
1680 template <
class Lock>
1683 const _FindOrOpenLayerInfo& info,
1691 template <
class ScopedLock>
1695 ScopedLock &lock,
bool retryAsWriter);
1705 template <
class ScopedLock>
1709 ScopedLock &lock,
bool retryAsWriter);
1718 bool _IsInert(
const SdfPath &path,
bool ignoreChildren,
1719 bool requiredFieldOnlyPropertiesAreInert =
false)
const;
1724 bool _IsInertSubtree(
const SdfPath &path)
const;
1731 void _RemoveIfInert(
const SdfSpec& spec);
1737 bool _RemoveInertDFS(SdfPrimSpecHandle prim);
1741 void _RemoveInertToRootmost(SdfPrimSpecHandle prim);
1744 bool _ValidateAuthoring()
const {
return _validateAuthoring; }
1751 void _UpdatePrimCompositionDependencyPaths(
1752 const SdfPrimSpecHandle &parent,
1757 void _MarkCurrentStateAsClean()
const;
1762 _GetRequiredFieldDef(
const SdfPath &path,
1774 static std::vector<TfToken>
1799 T _GetValue(
const TfToken& key)
const;
1801 enum _ReloadResult { _ReloadFailed, _ReloadSucceeded, _ReloadSkipped };
1802 _ReloadResult _Reload(
bool force);
1813 bool _Save(
bool force)
const;
1823 SdfFileFormatConstPtr fileFormat =
TfNullPtr,
1829 void _SwapData(SdfAbstractDataRefPtr &
data);
1833 void _AdoptData(
const SdfAbstractDataRefPtr &newData);
1842 void _SetData(
const SdfAbstractDataPtr &newData,
1846 SdfAbstractDataConstPtr _GetData()
const;
1849 SdfAbstractDataRefPtr _CreateData()
const;
1857 void _PrimSetField(
const SdfPath& path,
1861 bool useDelegate =
true);
1869 void _PrimSetFieldDictValueByKey(
const SdfPath& path,
1874 bool useDelegate =
true);
1878 void _PrimPushChild(
const SdfPath& parentPath,
1881 bool useDelegate =
true);
1883 void _PrimPopChild(
const SdfPath& parentPath,
1885 bool useDelegate =
true);
1893 void _PrimMoveSpec(
const SdfPath &oldPath,
const SdfPath &newPath,
1894 bool useDelegate =
true);
1902 bool _DeleteSpec(
const SdfPath &path);
1906 bool useDelegate =
true);
1909 void _PrimDeleteSpec(
const SdfPath &path,
bool inert,
1910 bool useDelegate =
true);
1914 void _PrimSetTimeSample(
const SdfPath& path,
double time,
1916 bool useDelegate =
true);
1920 template <
typename ChildPolicy>
1924 SdfLayerHandle _self;
1927 SdfFileFormatConstPtr _fileFormat;
1939 SdfAbstractDataRefPtr _data;
1942 SdfLayerStateDelegateBaseRefPtr _stateDelegate;
1954 std::atomic<bool> _initializationComplete;
1958 std::optional<bool> _initializationWasSuccessful;
1961 mutable bool _lastDirtyState;
1964 std::unique_ptr<Sdf_AssetInfo> _assetInfo;
1967 mutable VtValue _assetModificationTime;
1974 mutable size_t _mutedLayersRevisionCache;
1978 mutable bool _isMutedCache;
1981 bool _permissionToEdit;
1982 bool _permissionToSave;
1985 bool _validateAuthoring;
2012 #endif // PXR_USD_SDF_LAYER_H
static SDF_API SdfLayerRefPtr FindOrOpen(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
SDF_API void ClearColorConfiguration()
std::vector< SdfNamespaceEditDetail > SdfNamespaceEditDetailVector
A sequence of SdfNamespaceEditDetail.
SDF_API bool HasDefaultPrim()
SDF_API void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)
T GetFieldAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
SDF_API SdfAssetPath GetColorConfiguration() const
SDF_API void EraseTimeSample(const SdfPath &path, double time)
const std::vector< std::string > & GetExcluded() const
DetachedLayerRules & IncludeAll()
Include all layers in the detached layer set.
Result
Validity of an edit.
GT_API const UT_StringHolder filename
SDF_API void SetSubLayerPaths(const std::vector< std::string > &newPaths)
Sets the paths of the layer's sublayers.
SDF_API bool WriteDataFile(const std::string &filename)
SDF_API void RemoveInertSceneDescription()
SDF_API bool InsertRootPrim(const SdfPrimSpecHandle &prim, int index=-1)
SDF_API bool HasEndTimeCode() const
Returns true if the layer has an endTimeCode opinion.
SDF_API void SetComment(const std::string &comment)
Sets the comment string for this layer.
SDF_API VtDictionary GetCustomLayerData() const
SDF_API void SetFramePrecision(int framePrecision)
Sets the layer's frame precision.
SDF_API std::string ComputeAbsolutePath(const std::string &assetPath) const
SDF_API std::set< std::string > GetExternalReferences() const
SDF_API void EraseFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath)
bool HasFieldDictKey(const SdfPath &path, const TfToken &name, const TfToken &keyPath, T *value) const
SDF_API void RemovePropertyIfHasOnlyRequiredFields(SdfPropertySpecHandle prop)
SDF_API void SetDocumentation(const std::string &documentation)
Sets the documentation string for this layer.
SDF_API void ClearFramesPerSecond()
Clear the framesPerSecond opinion.
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(SdfFileFormat)
static SDF_API SdfLayerRefPtr New(const SdfFileFormatConstPtr &fileFormat, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
static SDF_API bool ReloadLayers(const std::set< SdfLayerHandle > &layers, bool force=false)
SDF_API bool IsMuted() const
Returns true if the current layer is muted.
SDF_API void SetStartTimeCode(double startTimecode)
Sets the layer's start timeCode.
SDF_API bool ExportToString(std::string *result) const
GT_API const UT_StringHolder time
SDF_API const VtValue & GetAssetInfo() const
static SDF_API bool SplitIdentifier(const std::string &identifier, std::string *layerPath, FileFormatArguments *arguments)
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
SDF_API bool HasStartTimeCode() const
Returns true if the layer has a startTimeCode opinion.
static SDF_API SdfLayerRefPtr FindOrOpenRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
DetachedLayerRules()=default
SDF_API const std::string & GetAssetName() const
Returns the asset name associated with this layer.
SDF_API void SetDefaultPrim(const TfToken &name)
GLsizei const GLchar *const * path
std::map< std::string, std::string > FileFormatArguments
SDF_API bool QueryTimeSample(const SdfPath &path, double time, VtValue *value=NULL) const
SDF_API void ClearSessionOwner()
SDF_API SdfNameOrderProxy GetRootPrimOrder() const
std::type_info const & GetFieldTypeid(const SdfPath &path, const TfToken &name) const
SDF_API bool HasSpec(const SdfPath &path) const
Return whether a spec exists at path.
SDF_API SdfAttributeSpecHandle GetAttributeAtPath(const SdfPath &path)
SDF_API void RemoveFromRootPrimOrderByIndex(int index)
Removes a root prim name from the root prim order by index.
SDF_API SdfRelationshipSpecHandle GetRelationshipAtPath(const SdfPath &path)
SDF_API void SetPermissionToEdit(bool allow)
Sets permission to edit.
SDF_API void Traverse(const SdfPath &path, const TraversalFunction &func)
TF_API const TfNullPtrType TfNullPtr
TF_DECLARE_WEAK_AND_REF_PTRS(SdfLayerStateDelegateBase)
SDF_API bool HasSessionOwner() const
Returns true if the layer has a session owner opinion.
friend class Sdf_ChangeManager
SDF_API SdfPrimSpecHandle GetPseudoRoot() const
SDF_API bool PermissionToEdit() const
std::set< SdfHandleTo< SdfLayer >::Handle > SdfLayerHandleSet
static SDF_API SdfLayerRefPtr CreateAnonymous(const std::string &tag=std::string(), const FileFormatArguments &args=FileFormatArguments())
SDF_API void SetSubLayerOffset(const SdfLayerOffset &offset, int index)
Sets the layer offset for the subLayer path at the given index.
SDF_API void ScheduleRemoveIfInert(const SdfSpec &spec)
**But if you need a result
std::function< void(const SdfPath &)> TraversalFunction
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 GetDocumentation() const
SDF_API void SetPermissionToSave(bool allow)
Sets permission to save.
SDF_API bool Apply(const SdfBatchNamespaceEdit &)
SDF_API bool Import(const std::string &layerPath)
SDF_API const std::string & GetRepositoryPath() const
SDF_API SdfPrimSpecHandle GetPrimAtPath(const SdfPath &path)
SDF_API void SetTimeCodesPerSecond(double timeCodesPerSecond)
Sets the layer's timeCodes per second.
static SDF_API std::set< std::string > GetMutedLayers()
Returns the set of muted layer paths.
SDF_API std::set< double > ListTimeSamplesForPath(const SdfPath &path) const
SDF_API SdfLayerOffset GetSubLayerOffset(int index) const
Returns the layer offset for the subLayer path at the given index.
SDF_API double GetTimeCodesPerSecond() const
SDF_API void SetColorConfiguration(const SdfAssetPath &colorConfiguration)
Sets the color configuration asset-path for this layer.
SDF_API std::string GetSessionOwner() const
static SDF_API bool IsIncludedByDetachedLayerRules(const std::string &identifier)
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
SDF_API void SetEndTimeCode(double endTimeCode)
Sets the layer's end timeCode.
SDF_API bool Reload(bool force=false)
SDF_API double GetStartTimeCode() const
GLenum GLuint GLint GLint layer
SDF_API size_t GetNumSubLayerPaths() const
Returns the number of sublayer paths (and offsets).
SDF_API SdfLayerOffsetVector GetSubLayerOffsets() const
Returns the layer offsets for all the subLayer paths.
SDF_API const SdfFileFormatConstPtr & GetFileFormat() const
Returns the file format used by this layer.
SDF_API void ClearOwner()
Clear the owner opinion.
SDF_API const FileFormatArguments & GetFileFormatArguments() const
SDF_API SdfDataRefPtr GetMetadata() const
Returns the data from the absolute root path of this layer.
SDF_API void RemoveRootPrim(const SdfPrimSpecHandle &prim)
Remove a root prim.
static SDF_API SdfLayerRefPtr OpenAsAnonymous(const std::string &layerPath, bool metadataOnly=false, const std::string &tag=std::string())
SDF_API void ClearFramePrecision()
Clear the framePrecision opinion.
SDF_API void SetStateDelegate(const SdfLayerStateDelegateBaseRefPtr &delegate)
SDF_API void SetColorManagementSystem(const TfToken &cms)
std::vector< SdfLayerOffset > SdfLayerOffsetVector
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
SDF_API void SetSessionOwner(const std::string &owner)
SDF_API void SetRootPrims(const SdfPrimSpecHandleVector &rootPrims)
SDF_API void SetCustomLayerData(const VtDictionary &value)
Sets the CustomLayerData dictionary associated with this layer.
SDF_API void EraseField(const SdfPath &path, const TfToken &fieldName)
Remove the field at path and fieldName, if one exists.
SDF_API std::set< std::string > GetCompositionAssetDependencies() const
SDF_API void ClearEndTimeCode()
Clear the endTimeCode opinion.
SDF_API bool HasCustomLayerData() const
Returns true if CustomLayerData is authored on the layer.
SDF_API bool UpdateExternalReference(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
SDF_API double GetFramesPerSecond() const
SDF_API void ClearDefaultPrim()
static SDF_API std::string GetDisplayNameFromIdentifier(const std::string &identifier)
SDF_API VtValue GetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath) const
SDF_API bool ImportFromString(const std::string &string)
GLint GLint GLsizei GLint GLenum format
SDF_API std::set< std::string > GetExternalAssetDependencies() const
const std::vector< std::string > & GetIncluded() const
SDF_API bool HasFramesPerSecond() const
Returns true if the layer has a frames per second opinion.
SdfPrimSpecView RootPrimsView
Returns a vector of the layer's root prims.
SDF_API void SetRootPrimOrder(const std::vector< TfToken > &names)
SDF_API bool Export(const std::string &filename, const std::string &comment=std::string(), const FileFormatArguments &args=FileFormatArguments()) const
SDF_API double GetEndTimeCode() const
SDF_API SdfLayerStateDelegateBasePtr GetStateDelegate() const
SDF_API DetachedLayerRules & Include(const std::vector< std::string > &patterns)
SDF_API void SetHasOwnedSubLayers(bool)
Sets whether the layer's sublayers are expected to have owners.
SDF_API const std::string & GetRealPath() const
SDF_API void ClearTimeCodesPerSecond()
Clear the timeCodesPerSecond opinion.
SDF_API void RemoveFromRootPrimOrder(const TfToken &name)
Removes a root prim name from the root prim order.
SDF_API TfToken GetColorManagementSystem() const
SDF_API bool HasTimeCodesPerSecond() const
Returns true if the layer has a timeCodesPerSecond opinion.
GLuint const GLchar * name
SDF_API void ClearExpressionVariables()
Clears the expression variables dictionary authored on this layer.
void SetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const T &val)
SdfLayer & operator=(const SdfLayer &)=delete
SDF_API bool StreamsData() const
SDF_API DetachedLayerRules & Exclude(const std::vector< std::string > &patterns)
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
SDF_API bool HasExpressionVariables() const
Returns true if expression variables are authored on this layer.
SDF_API bool GetBracketingTimeSamples(double time, double *tLower, double *tUpper)
SDF_API void SetFramesPerSecond(double framesPerSecond)
Sets the layer's frames per second.
SDF_API std::string GetDisplayName() const
SDF_API void UpdateAssetInfo()
SDF_API bool IsIncluded(const std::string &identifier) const
SDF_API bool UpdateCompositionAssetDependency(const std::string &oldAssetPath, const std::string &newAssetPath=std::string())
SDF_API const ArResolvedPath & GetResolvedPath() const
SdfLayer(const SdfLayer &)=delete
Noncopyable.
SDF_API SdfNamespaceEditDetail::Result CanApply(const SdfBatchNamespaceEdit &, SdfNamespaceEditDetailVector *details=NULL) const
static SDF_API void SetDetachedLayerRules(const DetachedLayerRules &mask)
SDF_API void InsertSubLayerPath(const std::string &path, int index=-1)
static SDF_API SdfLayerHandle FindRelativeToLayer(const SdfLayerHandle &anchor, const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
SDF_API SdfSpecHandle GetObjectAtPath(const SdfPath &path)
SDF_API void SetIdentifier(const std::string &identifier)
SDF_API void SetExpressionVariables(const VtDictionary &expressionVars)
Sets the expression variables dictionary for this layer.
SDF_API bool IsAnonymous() const
Returns true if this layer is an anonymous layer.
bool HasField(const SdfPath &path, const TfToken &name, T *value) const
SDF_API std::string GetFileExtension() const
SDF_API void InsertInRootPrimOrder(const TfToken &name, int index=-1)
SDF_API void RemoveSubLayerPath(int index)
Removes sublayer path at the given index.
SDF_API void SetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)
Set the value of the given path and fieldName.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
SDF_API bool GetBracketingTimeSamplesForPath(const SdfPath &path, double time, double *tLower, double *tUpper)
SDF_API void TransferContent(const SdfLayerHandle &layer)
SIM_API const UT_StringHolder force
void SetField(const SdfPath &path, const TfToken &fieldName, const T &val)
Set the value of the given path and fieldName.
bool QueryTimeSample(const SdfPath &path, double time, T *data) const
SDF_API bool HasColorManagementSystem() const
SDF_API VtDictionary GetExpressionVariables() const
SDF_API std::string GetOwner() const
Returns the layer's owner.
SDF_API void SetMuted(bool muted)
SDF_API void ClearCustomLayerData()
Clears out the CustomLayerData dictionary associated with this layer.
SDF_API bool PermissionToSave() const
virtual SDF_API ~SdfLayer()
Destructor.
SDF_API bool HasColorConfiguration() const
SDF_API bool HasOwner() const
Returns true if the layer has an owner opinion.
SDF_API void SetTimeSample(const SdfPath &path, double time, const VtValue &value)
#define PXR_NAMESPACE_CLOSE_SCOPE
SDF_API bool IsDetached() const
SDF_API bool HasFramePrecision() const
Returns true if the layer has a frames precision opinion.
**If you just want to fire and args
SDF_API int GetFramePrecision() const
Returns the layer's frame precision.
SDF_API void SetOwner(const std::string &owner)
Sets the layer's owner.
SDF_API const std::string & GetIdentifier() const
Returns the layer identifier.
SDF_API bool GetHasOwnedSubLayers() const
Returns true if the layer's sublayers are expected to have owners.
static SDF_API void RemoveFromMutedLayers(const std::string &mutedPath)
Remove the specified path from the muted layers set.
SDF_API RootPrimsView GetRootPrims() const
Returns a vector of the layer's root prims.
static SDF_API void AddToMutedLayers(const std::string &mutedPath)
Add the specified path to the muted layers set.
SDF_API TfToken GetDefaultPrim() const
SDF_API std::vector< TfToken > ListFields(const SdfPath &path) const
Return the names of all the fields that are set at path.
SDF_API SdfPropertySpecHandle GetPropertyAtPath(const SdfPath &path)
static SDF_API void DumpLayerInfo()
SDF_API size_t GetNumTimeSamplesForPath(const SdfPath &path) const
SDF_API const std::string & GetVersion() const
SDF_API SdfSubLayerProxy GetSubLayerPaths() const
SDF_API void RemovePrimIfInert(SdfPrimSpecHandle prim)
static SDF_API const DetachedLayerRules & GetDetachedLayerRules()
Returns the current rules for the detached layer set.
static SDF_API SdfLayerRefPtr CreateNew(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
SDF_API SdfLayerHints GetHints() const
static SDF_API SdfLayerHandleSet GetLoadedLayers()
Returns handles for all layers currently held by the layer registry.
SDF_API const SdfSchemaBase & GetSchema() const
SDF_API bool IsDirty() const
SDF_API void ApplyRootPrimOrder(std::vector< TfToken > *vec) const
SDF_API void ClearStartTimeCode()
Clear the startTimeCode opinion.
SDF_API void ClearColorManagementSystem()
SDF_API std::string GetComment() const
SDF_API bool Save(bool force=false) const
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
static SDF_API bool IsAnonymousLayerIdentifier(const std::string &identifier)
SDF_API std::set< double > ListAllTimeSamples() const
SDF_API bool IsEmpty() const
Returns whether this layer has no significant data.
static SDF_API SdfLayerHandle Find(const std::string &identifier, const FileFormatArguments &args=FileFormatArguments())
void SetTimeSample(const SdfPath &path, double time, const T &value)