HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
changeBlock.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_CHANGE_BLOCK_H
25 #define PXR_USD_SDF_CHANGE_BLOCK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
29 
31 
32 /// \class SdfChangeBlock
33 ///
34 /// <b>DANGER DANGER DANGER</b>
35 ///
36 /// Please make sure you have read and fully understand the
37 /// issues below before using a changeblock! They are very
38 /// easy to use in an unsafe way that could make the system
39 /// crash or corrupt data. If you have any questions, please
40 /// contact the USD team, who would be happy to help!
41 ///
42 /// SdfChangeBlock provides a way to group a round of related changes to
43 /// scene description in order to process them more efficiently.
44 ///
45 /// Normally, Sdf sends notification immediately as changes are made so
46 /// that downstream representations like UsdStage can update accordingly.
47 ///
48 /// However, sometimes it can be advantageous to group a series of Sdf
49 /// changes into a batch so that they can be processed more efficiently,
50 /// with a single round of change processing. An example might be when
51 /// setting many avar values on a model at the same time.
52 ///
53 /// Opening a changeblock tells Sdf to delay sending notification about
54 /// changes until the outermost changeblock is exited. Until then,
55 /// Sdf internally queues up the notification it needs to send.
56 ///
57 /// \note It is *not* safe to use Usd or other downstream API
58 /// while a changeblock is open!! This is because those derived
59 /// representations will not have had a chance to update while the
60 /// changeblock is open. Not only will their view of the world be
61 /// stale, it could be unsafe to even make queries from, since they
62 /// may be holding onto expired handles to Sdf objects that no longer
63 /// exist.
64 ///
65 /// If you need to make a bunch of changes to scene description,
66 /// the best approach is to build a list of necessary changes that
67 /// can be performed directly via the Sdf API, then submit those all
68 /// inside a changeblock without talking to any downstream libraries.
69 /// For example, this is how many mutators in Usd that operate on more
70 /// than one field or Spec work.
71 ///
72 
74 public:
75  SDF_API
78  if (_key) {
79  _CloseChangeBlock(_key);
80  }
81  }
82 private:
83  SDF_API
84  void _CloseChangeBlock(void const *key) const;
85 
86  void const *_key;
87 };
88 
90 
91 #endif // PXR_USD_SDF_CHANGE_BLOCK_H
#define SDF_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SDF_API SdfChangeBlock()