HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_LockedStageRegistry.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_LockedStageRegistry_h__
19 #define __HUSD_LockedStageRegistry_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_LockedStage.h"
24 #include <UT/UT_StringMap.h>
25 #include <utility>
26 
27 class GU_PackedImpl;
28 class OP_Context;
29 
30 // This singleton class is used to generate safely locked, unalterable copies
31 // of stages generated by LOP nodes. This is primarily for LOP nodes that
32 // introduce references to the stages output from other LOP nodes. See the
33 // HUSD_LockedStage class for more information.
35 {
36 public:
37  static HUSD_LockedStageRegistry &getInstance();
38 
39  // This function isd called by GusdGU_PackedUSD to track all packed USD
40  // prims so we can ensure that any packed USD prims that point to LOP node
41  // stages keep alive a shared pointer to that locked stage as long as the
42  // packed primitive exists.
43  static void packedUSDTracker(const GU_PackedImpl *prim, bool create);
44 
45  // Exit callback used to clean up the locked stage tracker objects at a
46  // predicatable time during shutdown, rather than relying on static object
47  // destruction ordering.
48  static void exitCallback(void *);
49 
50  HUSD_LockedStagePtr getLockedStage(OP_Node *node,
51  const HUSD_DataHandle &data,
52  bool strip_layers,
53  fpreal t,
54  HUSD_StripLayerResponse response);
55  void clearLockedStage(OP_Node *node,
56  const OP_Context &context);
57  void clearLockedStage(OP_Node *node);
58 
59 private:
62 
63  // Locked stages are identified by a string generateed from the stage
64  // cook time and a bool flag indicating whether that node's stage was
65  // flattened with or without layers from above layer breaks stripped out.
66  // Use a weak pointer so that we can track the life of the locked stage
67  // pointer accurately. Keeping a shared pointer in this structure would
68  // mean the locked stage would never be deleted.
70 
71  // A map from the LOP node id to the locked stage map for that LOP node.
72  // Each LOP node may have any number of locked stages active at the same
73  // time, depending on the range of time samples for which the LOP has been
74  // cooked.
75  UT_Map<int, LockedStageMap> myLockedStageMaps;
76 };
77 
78 #endif
79 
Unsorted map container.
Definition: UT_Map.h:107
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_StripLayerResponse
Definition: HUSD_Utils.h:91
GLdouble t
Definition: glad.h:2397
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_SharedPtr< HUSD_LockedStage > HUSD_LockedStagePtr
Definition: format.h:895