HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_PythonConverter.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_PythonConverter_h__
19 #define __HUSD_PythonConverter_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_Overrides.h"
24 
25 class GU_DetailHandle;
26 
28 {
29 public:
31  HUSD_AutoAnyLock &lock);
33  const HUSD_ConstOverridesPtr &overrides);
35 
36  // Functions for getting python objects representing a stage or layer
37  // from an HUSD_AutoAnyLock. The "Editable" methods only work if the
38  // lock is an HUSD_AutoWriteLock.
39  void *getEditableLayer() const;
40  void *getEditableOverridesLayer() const;
41  void *getActiveLayer() const;
42  void *getEditableStage() const;
43  void *getEditableOverridesStage() const;
44  void *getStage() const;
45  void *getPrim(const UT_StringRef &primpath) const;
46  void *getSourceLayer(int layerindex) const;
47  int getSourceLayerCount() const;
48 
49  // Functions for getting python objects representing a layer from an
50  // HUSD_ConstOverridesPtr. Only read-only access is supported.
51  void *getOverridesLayer(
52  HUSD_OverridesLayerId layer_id) const;
53 
54  std::string addLockedGeo(
55  const UT_StringHolder &identifier,
56  const std::map<std::string, std::string> &args,
57  const GU_DetailHandle &gdh) const;
58  bool addHeldLayer(const UT_StringRef &identifier) const;
59  bool addSubLayer(const UT_StringRef &identifier) const;
60 
61  // Returns the lock the converter holds.
63  { return myAnyLock; }
64 
65 private:
66  HUSD_AutoAnyLock *myAnyLock;
67  HUSD_ConstOverridesPtr myOverrides;
68 };
69 
70 
71 // ===========================================================================
72 // Utility class for managing the python converter.
74 {
75 public:
76  /// Creates a python converter and sets the pointer reference to it.
77  /// Referenced pointer's lifetime must be greater than object of this class.
79  HUSD_PythonConverter **converter_ptr )
80  : myPythonConverter( lock )
81  , myPythonConverterPtr( converter_ptr )
82  {
83  // Set the ref to member converter. It sets the ctor's parameter too.
84  if( myPythonConverterPtr)
85  *myPythonConverterPtr = &myPythonConverter;
86  }
87 
89  {
90  // The python converter object is being destroyed, so clear the ref.
91  if( myPythonConverterPtr)
92  *myPythonConverterPtr = nullptr;
93  }
94 
95 private:
96  HUSD_PythonConverter myPythonConverter;
97  HUSD_PythonConverter **myPythonConverterPtr;
98 
99 };
100 
101 #endif
102 
HUSD_AutoAnyLock * getLock() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_OverridesLayerId
Definition: HUSD_Utils.h:73
**If you just want to fire and args
Definition: thread.h:609
HUSD_ScopedPythonConverter(HUSD_AutoAnyLock &lock, HUSD_PythonConverter **converter_ptr)