HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cleanupEnabler.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_SDF_CLEANUP_ENABLER_H
8 #define PXR_USD_SDF_CLEANUP_ENABLER_H
9 
10 /// \file sdf/cleanupEnabler.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/sdf/api.h"
14 #include "pxr/base/tf/stacked.h"
15 
17 
18 /// \class SdfCleanupEnabler
19 ///
20 /// An RAII class which, when an instance is alive, enables scheduling of
21 /// automatic cleanup of SdfLayers.
22 ///
23 /// Any affected specs which no longer contribute to the scene will be removed
24 /// when the last SdfCleanupEnabler instance goes out of scope. Note that for
25 /// this purpose, SdfPropertySpecs are removed if they have only required fields
26 /// (see SdfPropertySpecs::HasOnlyRequiredFields), but only if the property spec
27 /// itself was affected by an edit that left it with only required fields. This
28 /// will have the effect of uninstantiating on-demand attributes. For example,
29 /// if its parent prim was affected by an edit that left it otherwise inert, it
30 /// will not be removed if it contains an SdfPropertySpec with only required
31 /// fields, but if the property spec itself is edited leaving it with only
32 /// required fields, it will be removed, potentially uninstantiating it if it's
33 /// an on-demand property.
34 ///
35 /// SdfCleanupEnablers are accessible in both C++ and Python.
36 ///
37 /// /// SdfCleanupEnabler can be used in the following manner:
38 /// \code
39 /// {
40 /// SdfCleanupEnabler enabler;
41 ///
42 /// // Perform any action that might otherwise leave inert specs around,
43 /// // such as removing info from properties or prims, or removing name
44 /// // children. i.e:
45 /// primSpec->ClearInfo(SdfFieldKeys->Default);
46 ///
47 /// // When enabler goes out of scope on the next line, primSpec will
48 /// // be removed if it has been left as an empty over.
49 /// }
50 /// \endcode
51 ///
53 {
54 public:
55 
57 
58  SDF_API ~SdfCleanupEnabler();
59 
60  /// Returns whether cleanup is currently being scheduled.
61  SDF_API static bool IsCleanupEnabled();
62 };
63 
65 
66 #endif // #ifndef PXR_USD_SDF_CLEANUP_ENABLER_H
TF_DEFINE_STACKED(SdfCleanupEnabler, false, SDF_API)
#define SDF_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74