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 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_CLEANUP_ENABLER_H
25 #define PXR_USD_SDF_CLEANUP_ENABLER_H
26 
27 /// \file sdf/cleanupEnabler.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/base/tf/stacked.h"
32 
34 
35 /// \class SdfCleanupEnabler
36 ///
37 /// An RAII class which, when an instance is alive, enables scheduling of
38 /// automatic cleanup of SdfLayers.
39 ///
40 /// Any affected specs which no longer contribute to the scene will be removed
41 /// when the last SdfCleanupEnabler instance goes out of scope. Note that for
42 /// this purpose, SdfPropertySpecs are removed if they have only required fields
43 /// (see SdfPropertySpecs::HasOnlyRequiredFields), but only if the property spec
44 /// itself was affected by an edit that left it with only required fields. This
45 /// will have the effect of uninstantiating on-demand attributes. For example,
46 /// if its parent prim was affected by an edit that left it otherwise inert, it
47 /// will not be removed if it contains an SdfPropertySpec with only required
48 /// fields, but if the property spec itself is edited leaving it with only
49 /// required fields, it will be removed, potentially uninstantiating it if it's
50 /// an on-demand property.
51 ///
52 /// SdfCleanupEnablers are accessible in both C++ and Python.
53 ///
54 /// /// SdfCleanupEnabler can be used in the following manner:
55 /// \code
56 /// {
57 /// SdfCleanupEnabler enabler;
58 ///
59 /// // Perform any action that might otherwise leave inert specs around,
60 /// // such as removing info from properties or prims, or removing name
61 /// // children. i.e:
62 /// primSpec->ClearInfo(SdfFieldKeys->Default);
63 ///
64 /// // When enabler goes out of scope on the next line, primSpec will
65 /// // be removed if it has been left as an empty over.
66 /// }
67 /// \endcode
68 ///
70 {
71 public:
72 
74 
75  SDF_API ~SdfCleanupEnabler();
76 
77  /// Returns whether cleanup is currently being scheduled.
78  SDF_API static bool IsCleanupEnabled();
79 };
80 
82 
83 #endif // #ifndef PXR_USD_SDF_CLEANUP_ENABLER_H
TF_DEFINE_STACKED(SdfCleanupEnabler, false, SDF_API)
#define SDF_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91