HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Module.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  * This class is not directly wrapped by swig. However, when creating
8  * the swig wrapper modules we wrap each of the methods of this class
9  * in functions. This way, the methods of this class appear as the
10  * top-level parts of the hou module.
11  */
12 
13 #ifndef __HOM_Module_h__
14 #define __HOM_Module_h__
15 
16 #include "HOM_API.h"
17 #include "HOM_BinaryString.h"
18 #include "HOM_Defines.h"
19 #include "HOM_Errors.h"
20 #include "HOM_ElemPtr.h"
21 #include "HOM_EnumModules.h"
23 #include <UT/UT_Lock.h>
24 #include <UT/UT_NonCopyable.h>
25 #include <UT/UT_Notifier.h>
26 #include <UT/UT_TaskLock.h>
27 #include <UT/UT_Thread.h>
28 #include <UT/UT_UniquePtr.h>
29 #include <UT/UT_OptionEntry.h>
30 #include <SYS/SYS_Types.h>
31 #include <typeinfo>
32 #include <string>
33 #include <vector>
34 #include <map>
35 #include <hboost/any.hpp>
36 
37 class OP_Node;
38 class STORUI_OrboltURLHandler;
39 
41 class HOM_AgentClip;
43 class HOM_AgentLayer;
44 class HOM_AgentMetadata;
45 class HOM_AgentRig;
46 class HOM_AgentShape;
51 class HOM_AttribDataId;
52 class HOM_anonstats;
53 class HOM_audio;
55 class HOM_ChopNode;
56 class HOM_Clip;
57 class HOM_Color;
58 class HOM_crowds;
60 class HOM_SimpleDrawable;
61 class HOM_dop;
62 class HOM_DopData;
63 class HOM_DopSimulation;
64 class HOM_Edge;
65 class HOM_EnumValue;
69 class HOM_GadgetContext;
70 class HOM_GadgetDrawable;
71 class HOM_galleries;
72 class HOM_Geometry;
75 class HOM_Handle;
76 class HOM_hda;
77 class HOM_HDADefinition;
78 class HOM_HDAModule;
79 class HOM_HDAOptions;
80 class HOM_hipFile;
81 class HOM_hmath;
82 class HOM_ik;
85 class HOM_Keyframe;
87 class HOM_lop;
91 class HOM_Matrix4;
93 class HOM_NetworkBox;
94 class HOM_NetworkDot;
96 class HOM_Node;
97 class HOM_NodeBundle;
98 class HOM_NodeConnection;
99 class HOM_NodeType;
102 class HOM_Parm;
103 class HOM_ParmTemplate;
105 class HOM_ParmTuple;
106 class HOM_perfMon;
108 class HOM_pypanel;
109 class HOM_playbar;
110 class HOM_Point;
111 class HOM_Prim;
112 class HOM_properties;
113 class HOM_qt;
115 class HOM_RedrawBlock;
116 #ifndef SWIG
118 #endif
119 class HOM_SceneViewer;
121 class HOM_Selection;
123 class HOM_shelves;
124 class HOM_StickyNote;
125 class HOM_StringKeyframe;
127 class HOM_styles;
128 class HOM_StyleSheet;
130 class HOM_takes;
131 class HOM_text;
132 class HOM_TextDrawable;
134 class HOM_ui;
135 class HOM_hotkeys;
136 class HOM_UIEvent;
137 class HOM_UIEventDevice;
138 class HOM_undos;
139 class HOM_Vertex;
140 class HOM_VexContext;
141 class HOM_ViewerEvent;
143 class HOM_ViewerDragger;
149 class HOM_ViewerStateMenu;
153 class HOM_webServer;
154 
155 #define HOM_SESSION_MODULE_NAME "hou.session"
156 #define HOM_SESSION_MODULE_CPIO_NAME "." HOM_SESSION_MODULE_NAME
157 
158 // Use this function to access the HOM module from C++ in Houdini. This
159 // is equivalent to writing "hou" in python. It will only throw an exception
160 // if the python module could not be imported, which should not happen.
161 class HOM_Module;
163 
165 {
166 public:
167  static void setHOMCreator(void (*homCreator)());
168 
169  virtual ~HOM_Module() {}
170 
171  virtual std::vector<std::string> _getArgumentAutoComplete(
172  const char *method_name, const char *arguments,
173  bool meta_info_only = false) = 0;
174 
175  // This method is called by the expression editor to force autocompletion
176  // to be relative to the node containing the expression. It is not
177  // wrapped by swig.
178  virtual void setRelativeNodeForAutoComplete(OP_Node *node) = 0;
179 
180  virtual HOM_ui& ui() = 0;
181  virtual HOM_qt& qt() = 0;
182  virtual HOM_hotkeys& hotkeys() = 0;
183  virtual HOM_audio& audio() = 0;
184  virtual bool isUIAvailable() = 0;
185  virtual bool _isCurrentThreadHoldingHOMLock() = 0;
186 
187  virtual HOM_galleries& galleries() = 0;
188  virtual HOM_hda& hda() = 0;
189  virtual HOM_hipFile& hipFile() = 0;
190  virtual HOM_perfMon& perfMon() = 0;
191  virtual HOM_playbar& playbar() = 0;
192  virtual HOM_pypanel& pypanel() = 0;
193  virtual HOM_hmath& hmath() = 0;
194  virtual HOM_dop& dop() = 0;
195  virtual HOM_properties& properties() = 0;
196  virtual HOM_shelves& shelves() = 0;
197  virtual HOM_styles& styles() = 0;
198  virtual HOM_takes& takes() = 0;
199  virtual HOM_undos& undos() = 0;
200  virtual HOM_viewportVisualizers& viewportVisualizers() = 0;
201  virtual HOM_anonstats& anonstats() = 0;
202  virtual HOM_crowds& crowds() = 0;
203  virtual HOM_ik& ik() = 0;
204  virtual HOM_lop& lop() = 0;
205  virtual HOM_text& text() = 0;
206  virtual HOM_webServer& webServer() = 0;
207 
208  virtual bool _assertWrapper(
209  const char *file, int linenum, const char *function,
210  const char *condition, const char *reason) = 0;
211 
212  virtual void exit(int exit_code=0, bool suppress_save_prompt=false) = 0;
213 
214  // isExiting() will return true if the program is actually Houdini (not
215  // mplay) and the UI queue is closed. This method is wrapped by swig, but
216  // only so houdiniInterpreter can call it.
217  virtual bool isExiting() = 0;
218 
219  virtual void addPreloadIcon(const char *name, int w, int h) = 0;
220  virtual void rasterizePreloadIcons() = 0;
221 
222  virtual std::string applicationName() = 0;
223  virtual std::vector<int> applicationVersion(bool include_patch=false) = 0;
224  virtual std::string applicationVersionString() = 0;
225  virtual std::string applicationCompilationDate() = 0;
226  virtual std::string applicationPlatformInfo() = 0;
227  virtual HOM_EnumValue &licenseCategory() = 0;
228  virtual bool isApprentice() = 0;
229  virtual void releaseLicense() = 0;
230 
231  // Threading controls
232  virtual int maxThreads() = 0;
233  virtual void setMaxThreads(int max_threads) = 0;
234 
235  // These methods return a new HOM_Node object.
236  virtual HOM_Node* root() = 0;
237  virtual HOM_Node* pwd() = 0;
238  virtual HOM_Node* parent() = 0;
239 
240  virtual void setPwd(HOM_Node &newpwd) = 0;
241  virtual void cd(const char *path) = 0;
242 
243  // Calling phm() is a shortcut for calling pwd().hdaModule().
244  virtual HOM_HDAModule* phm() = 0;
245 
246  // This method returns a new HOM_DopNetNode object or None.
247  virtual HOM_Node* currentDopNet() = 0;
248  virtual void setCurrentDopNet(HOM_Node &dopnet) = 0;
249 
250  // Gets or sets the simulation enabled state.
251  virtual bool simulationEnabled() = 0;
252  virtual void setSimulationEnabled(bool enabled) = 0;
253 
254  // These methods return a new HOM_Node object or null if the node couldn't
255  // be found.
256  virtual HOM_Node *node(const char *path) = 0;
257  virtual HOM_NetworkMovableItem* item(const char *path) = 0;
258 
259  virtual std::vector<HOM_ElemPtr<HOM_Node> > nodes(const std::vector<std::string> &paths) = 0;
260  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > items(const std::vector<std::string> &paths) = 0;
261 
262  virtual HOM_Node *nodeBySessionId(int session_id) = 0;
263  virtual HOM_NetworkBox *networkBoxBySessionId(int session_id) = 0;
264  virtual HOM_StickyNote *stickyNoteBySessionId(int session_id) = 0;
265  virtual HOM_SubnetIndirectInput *subnetIndirectInputBySessionId(
266  int64 session_id) = 0;
267  virtual HOM_NetworkDot *networkDotBySessionId(int session_id) = 0;
268  virtual HOM_NetworkMovableItem *itemBySessionId(
269  HOM_EnumValue &item_type, int64 session_id) = 0;
270  virtual HOM_NodeConnection *nodeConnectionBySessionId(
271  int node_session_id, int input_index) = 0;
272 
273  // Functions for configuring default colors on network elements.
274  virtual HOM_Color defaultColor(HOM_EnumValue &color_item) = 0;
275  virtual void setDefaultColor(HOM_EnumValue &color_item, HOM_Color *color) = 0;
276 
277  // Return HOM_Nodes for all selected nodes in the session.
278  virtual std::vector<HOM_ElemPtr<HOM_Node> > selectedNodes(
279  bool include_hidden = false) = 0;
280  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > selectedItems(
281  bool include_hidden = false) = 0;
282  virtual std::vector<HOM_ElemPtr<HOM_NodeConnection> > selectedConnections() = 0;
283  virtual void clearAllSelected() = 0;
284 
285  // Copy nodes to and paste from clipboard.
286  virtual void copyNodesToClipboard(const std::vector<HOM_Node *> &nodes) = 0;
287  virtual void pasteNodesFromClipboard(HOM_Node &destination_node) = 0;
288 
289  // These methods return new HOM_Parm/HOM_ParmTuple objects or null if the
290  // parm couldn't be found.
291  virtual HOM_Parm* parm(const char *path) = 0;
292  SWIGOUT(%ignore newParm;)
293  virtual HOM_Parm* newParm(OP_Node &node, int parm_index, int vector_index) = 0;
294  virtual HOM_ParmTuple* parmTuple(const char *path) = 0;
295  virtual HOM_Parm *evaluatingParm() = 0;
296 
297  virtual HOM_ScriptEvalContext * newScriptEvalContext(HOM_Node &node) = 0;
298  virtual HOM_ScriptEvalContext * newScriptEvalContext(HOM_Parm &parm) = 0;
299 
300  // Access to the contents of the parm clipboard
301  virtual std::vector< std::map<std::string, std::string> >
302  parmClipboardContents() = 0;
303 
304  // These methods return a new HOM_NodeType object or null if it couldn't
305  // be found.
306  virtual HOM_NodeType *nodeType(
307  HOM_NodeTypeCategory &category, const char *name) = 0;
308  virtual HOM_NodeType *nodeType(const char *name) = 0;
309 
310  virtual HOM_NodeType *preferredNodeType(
311  const char *name, HOM_Node *parentNode = NULL) = 0;
312 
313  virtual HOM_NodeTypeCategory &objNodeTypeCategory() = 0;
314  virtual HOM_NodeTypeCategory &sopNodeTypeCategory() = 0;
315 #if 0
316  virtual HOM_NodeTypeCategory &popNodeTypeCategory() = 0;
317 #endif
318  virtual HOM_NodeTypeCategory &dopNodeTypeCategory() = 0;
319  virtual HOM_NodeTypeCategory &cop2NodeTypeCategory() = 0;
320  virtual HOM_NodeTypeCategory &shopNodeTypeCategory() = 0;
321  virtual HOM_NodeTypeCategory &vopNodeTypeCategory() = 0;
322  virtual HOM_NodeTypeCategory &ropNodeTypeCategory() = 0;
323  virtual HOM_NodeTypeCategory &chopNodeTypeCategory() = 0;
324  virtual HOM_NodeTypeCategory &topNodeTypeCategory() = 0;
325  virtual HOM_NodeTypeCategory &lopNodeTypeCategory() = 0;
326 #if 0
327  virtual HOM_NodeTypeCategory &popNetNodeTypeCategory() = 0;
328 #endif
329  virtual HOM_NodeTypeCategory &cop2NetNodeTypeCategory() = 0;
330  virtual HOM_NodeTypeCategory &vopNetNodeTypeCategory() = 0;
331  virtual HOM_NodeTypeCategory &chopNetNodeTypeCategory() = 0;
332  virtual HOM_NodeTypeCategory &topNetNodeTypeCategory() = 0;
333  virtual HOM_NodeTypeCategory &managerNodeTypeCategory() = 0;
334  virtual HOM_NodeTypeCategory &rootNodeTypeCategory() = 0;
335  virtual std::map<std::string, HOM_NodeTypeCategory *>
336  nodeTypeCategories() = 0;
337 
338  virtual std::vector<HOM_ElemPtr<HOM_Node> > copyNodesTo(
339  const std::vector<HOM_Node *> &nodes,
340  HOM_Node &destination_node) = 0;
341  virtual std::vector<HOM_ElemPtr<HOM_Node> > moveNodesTo(
342  const std::vector<HOM_Node *> &nodes,
343  HOM_Node &destination_node) = 0;
344 
345  virtual HOM_NodeBundle *addNodeBundle(const char *name = NULL) = 0;
346  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > nodeBundles() = 0;
347  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > selectedNodeBundles() = 0;
348  virtual HOM_NodeBundle *nodeBundle(const char *name) = 0;
349 
350  virtual HOM_HDADefinition *hdaDefinition(
351  HOM_NodeTypeCategory &category, const char *name,
352  const char *file_path) = 0;
353 
354  // Note that getTimeWithoutAddingDependency is not wrapped by swig.
355  virtual fpreal getTimeWithoutAddingDependency() = 0;
356  virtual double time() = 0;
357  virtual void setTime(double time) = 0;
358  virtual double frame() = 0;
359  virtual int intFrame() = 0;
360  virtual void setFrame(double frame) = 0;
361  virtual double fps() = 0;
362  virtual void setFps(double fps) = 0;
363  virtual double timeToFrame(double time) = 0;
364  virtual double frameToTime(double frame) = 0;
365 
366  /// Private methods for ensuring that the current eval context
367  /// (including global time) is in-sync with the main thread's eval
368  /// context.
369  virtual void _syncFromMainContext() = 0;
370  virtual void _syncToMainContext() = 0;
371 
372  // Computes a scale factor given units
373  virtual fpreal scaleFromMKS(const char *units) = 0;
374  virtual fpreal scaleToMKS(const char *units) = 0;
375 
376  virtual double bezier() = 0;
377  virtual double constant() = 0;
378  virtual double cubic() = 0;
379  virtual double cycle(double start_frame, double end_frame) = 0;
380  virtual double cyclet(double start_time, double end_time) = 0;
381  virtual double cycleoffset(double start_frame, double end_frame) = 0;
382  virtual double cycleoffsett(double start_time, double end_time) = 0;
383  virtual double ease() = 0;
384  virtual double easein() = 0;
385  virtual double easeinp(double ease_speed) = 0;
386  virtual double easeout() = 0;
387  virtual double easeoutp(double ease_speed) = 0;
388  virtual double easep(double ease_bias) = 0;
389  virtual double linear() = 0;
390  virtual double match() = 0;
391  virtual double matchin() = 0;
392  virtual double matchout() = 0;
393  virtual double qlinear() = 0;
394  virtual double quintic() = 0;
395  virtual double repeat(double start_frame, double end_frame) = 0;
396  virtual double repeatt(double start_time, double end_time) = 0;
397  virtual double spline() = 0;
398  virtual double vmatch() = 0;
399  virtual double vmatchin() = 0;
400  virtual double vmatchout() = 0;
401 
402  virtual std::string chopExportConflictResolutionPattern() = 0;
403  virtual void setChopExportConflictResolutionPattern( const char *pattern) = 0;
404 
405  virtual std::vector<HOM_ElemPtr<HOM_VexContext> >
406  vexContexts() = 0;
407 
408  virtual HOM_VexContext* vexContextForShaderType(HOM_EnumValue &shader_type) = 0;
409 
410  virtual HOM_VexContext* vexContextForNodeTypeCategory(
411  HOM_NodeTypeCategory &node_type_category) = 0;
412 
413  virtual std::string helpServerUrl() = 0;
414 
415  virtual std::string hscriptCommandHelp(const char *command_name) = 0;
416 
417  // This method returns a pair of strings: one for stdout and one for
418  // stderr.
419  virtual std::vector<std::string> hscript(const char *command) = 0;
420 
421  // Compare if two numbers are almost equal.
422  virtual bool almostEqual(double x, double y) = 0;
423 
424  virtual std::vector<std::pair<HOM_ElemPtr<HOM_Parm>, std::string> >
425  fileReferences(
426  const char *project_dir_variable="HIP", bool include_all_refs=true) = 0;
427 
428  // Find files in $HOUDINI_PATH.
429  virtual std::string findFile(const char *file_name) = 0;
430  virtual std::vector<std::string> findFiles(
431  const char *file_name) = 0;
432  virtual std::vector<std::string> findFilesWithExtension(
433  const char *file_extension, const char *subdirectory = NULL) = 0;
434 
435  // Find directories in $HOUDINI_PATH.
436  virtual std::string findDirectory(const char *directory_name) = 0;
437  virtual std::vector<std::string> findDirectories(
438  const char *directory_name) = 0;
439 
440  virtual std::vector<std::string> houdiniPath(const char *pathvar = nullptr) = 0;
441 
442  virtual std::string homeHoudiniDirectory() = 0;
443 
444 #if defined(USE_PYTHON3)
445  virtual std::string readFile(const char *file_path) = 0;
446  virtual HOM_BinaryString readBinaryFile(const char *file_path) = 0;
447 #else
448  virtual HOM_BinaryString readFile(const char *file_path) = 0;
449 #endif
450 
451  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromString(
452  const char *data, int length) = 0;
453 
454  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromFile(
455  const char *file_path) = 0;
456 
457 #if defined(USE_PYTHON3)
458  virtual HOM_BinaryString saveIndexDataToString(
459  const std::map<std::string, HOM_BinaryString> &index_data) = 0;
460 
461  virtual void saveIndexDataToFile(
462  const char *file_path,
463  const std::map<std::string, HOM_BinaryString> &index_data) = 0;
464 #else
465  virtual HOM_BinaryString saveIndexDataToString(
466  const std::map<std::string, std::string> &index_data) = 0;
467 
468  virtual void saveIndexDataToFile(
469  const char *file_path,
470  const std::map<std::string, std::string> &index_data) = 0;
471 #endif
472 
473  // Note that, when wrapped by swig, this function takes a single string
474  // parameter.
475  virtual std::vector<std::pair<std::string, HOM_BinaryString> >
476  loadCPIODataFromString(const char *data, int length) = 0;
477 
478 #if defined(USE_PYTHON3)
479  virtual HOM_BinaryString saveCPIODataToString(
480  const std::vector<std::pair<std::string, HOM_BinaryString> >
481  &data) = 0;
482 #else
483  virtual HOM_BinaryString saveCPIODataToString(
484  const std::vector<std::pair<std::string, std::string> > &data) = 0;
485 #endif
486 
487  // These 3 methods are not wrapped by swig. They are used to notify
488  // interested parties that a change to the module source code was made and
489  // that they should forcefully update to match the change. The third
490  // is used to load the session module source from a hip file, even though
491  // that source might generate an exception.
492  virtual UT_NotifierImpl<int> &getSessionModuleSourceForceUpdateNotifier()=0;
493  virtual void forceUpdateFromSessionModuleSource() = 0;
494  virtual void forceSetSessionModuleSource(const char *source) = 0;
495 
496  virtual void setSessionModuleSource(const char *source) = 0;
497  virtual void appendSessionModuleSource(const char *source) = 0;
498  virtual std::string sessionModuleSource() = 0;
499  // This method is not wrapped by swig:
500  virtual int sessionModuleSourceChangeCount() = 0;
501 
502  // This static method lets you know if the HOM implementation is set,
503  // so you can check if it's safe to call the HOM() function. This method
504  // should only be called in rare cases.
505  static bool isImplementationSet()
506  { return theImplementation != NULL; }
507 
508  // Evaluates a parameter as if it was an OPpath parameter
509  virtual std::string chsop(const char *path) = 0;
510 
511  // Evaluates a parameter as if it was an OPlist parameter
512  virtual std::string chsoplist(const char *path) = 0;
513 
514  // Sorts a list of node paths using topological order from the graph.
515  virtual std::vector<std::string>
516  sortedNodePaths(const std::vector<std::string> &paths) = 0;
517 
518  // Sorts a list of HOM_Node using topological order from the graph.
519  virtual std::vector<HOM_ElemPtr<HOM_Node> >
520  sortedNodes(const std::vector<HOM_Node*> &nodes) = 0;
521 
522  // deprecated in favour of hou.text.patternMatch
523  virtual int patternMatch(
524  const char *pattern, const char *str,
525  bool ignore_case = false,
526  bool path_match = false) = 0;
527 
528  // hscriptExpression() will return different types, according to
529  // the return value of the expression.
530  virtual hboost::any hscriptExpression(const char *expression) = 0;
531  virtual double hscriptFloatExpression(const char *expression) = 0;
532  virtual std::string hscriptStringExpression(const char *expression) = 0;
533  virtual std::vector<double>hscriptVectorExpression(
534  const char *expression) = 0;
535  virtual std::vector<std::vector<double> > hscriptMatrixExpression(
536  const char *expression) = 0;
537 
538  virtual hboost::any lvar(const char *name) = 0;
539 
540  virtual char *getenv(const char *name, const char *default_value=NULL) = 0;
541 
542  virtual void putenv(const char *name, const char *value) = 0;
543 
544  virtual void unsetenv(const char *name) = 0;
545 
546  virtual void allowEnvironmentToOverwriteVariable(
547  const char *name, bool onoff) = 0;
548 
549  virtual void *expressionGlobals() = 0;
550 
551  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
552 
553  // This method is used to interact with the global interrupt object.
554  virtual bool updateProgressAndCheckForInterrupt(int percentage=-1) = 0;
555 
556  virtual std::map<std::string, hboost::any> runVex(
557  const char *vex_file,
558  const std::map<std::string, hboost::any> &inputs,
559  const char *precision = "32") = 0;
560 
561  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
562 
563  virtual void saveImageDataToFile(
564  const std::vector<float> &color_and_alpha_data,
565  int width, int height,
566  const char *file_name) = 0;
567 
568  virtual void saveImageDataToFile(
569  const std::string &color_and_alpha_data,
570  int width, int height,
571  const char *file_name) = 0;
572 
573  virtual HOM_BinaryString loadImageDataFromFile(
574  const char *image_file_name,
575  HOM_EnumValue &image_depth = HOM_imageDepth::Int8) = 0;
576 
577  virtual std::vector<int> imageResolution(const char *image_file_name) = 0;
578 
579  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
580 
581  virtual HOM_EnumValue &updateModeSetting() = 0;
582  virtual void setUpdateMode(HOM_EnumValue &mode) = 0;
583 
584  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
585 
586  virtual HOM_OrboltURLHandler *orboltURLHandler() = 0;
587 
588  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
589 
590  virtual void *opaqueRunCallbackAndCatchCrashes(void *opaque_callback) = 0;
591 
592  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
593 
594  // These methods are used to grant functions defined in an asset's
595  // PythonModule enhanced privileges. They are not wrapped by swig.
596  virtual void pushAccessPrivilege(const char *key) = 0;
597  virtual void popAccessPrivilege(const char *key) = 0;
598 
599  virtual std::string currentPythonModuleKey() = 0;
600 
601  virtual void registerAccessPrivilegePyClient(void *opaque_python_object) = 0;
602 
603  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
604 
605  // These methods are used to instantiate HOMF objects from the HOM
606  // library level. They are not wrapped by swig.
607  virtual HOM_FloatParmTemplate *newFloatParmTemplate(
608  const char *name,
609  const char *label,
610  int num_components,
611  const std::vector<double> &default_value,
612  double min, double max,
613  bool min_is_strict, bool max_is_strict,
614  HOM_EnumValue &look,
615  HOM_EnumValue &naming_scheme,
616  const char *disable_when,
617  bool is_hidden,
618  bool is_label_hidden,
619  bool join_with_next,
620  const char *help,
621  const char *script_callback,
622  HOM_EnumValue &script_callback_language,
623  const std::map<std::string, std::string> &tags,
624  const std::map<HOM_EnumValue *, std::string> &conditionals,
625  const std::vector<std::string> &default_expression,
626  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
627 
628  virtual HOM_IntParmTemplate *newIntParmTemplate(
629  const char *name,
630  const char *label,
631  int num_components,
632  const std::vector<int> &default_value,
633  int min, int max,
634  bool min_is_strict, bool max_is_strict,
635  HOM_EnumValue &naming_scheme,
636  const std::vector<std::string> &menu_items,
637  const std::vector<std::string> &menu_labels,
638  const std::vector<std::string> &icon_names,
639  const std::string &item_generator_script,
640  HOM_EnumValue *item_generator_script_language,
641  HOM_EnumValue &menu_type,
642  bool menu_use_token,
643  const char *disable_when,
644  bool is_hidden,
645  bool is_label_hidden,
646  bool join_with_next,
647  const char *help,
648  const char *script_callback,
649  HOM_EnumValue &script_callback_language,
650  const std::map<std::string, std::string> &tags,
651  const std::map<HOM_EnumValue *, std::string> &conditionals,
652  const std::vector<std::string> &default_expression,
653  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
654 
655  virtual HOM_StringParmTemplate *newStringParmTemplate(
656  const char *name,
657  const char *label,
658  int num_components,
659  const std::vector<std::string> &default_value,
660  HOM_EnumValue &naming_scheme,
662  HOM_EnumValue &file_type,
663  const std::vector<std::string> &menu_items,
664  const std::vector<std::string> &menu_labels,
665  const std::vector<std::string> &icon_names,
666  const std::string &item_generator_script,
667  HOM_EnumValue *item_generator_script_language,
668  HOM_EnumValue &menu_type,
669  const char *disable_when,
670  bool is_hidden,
671  bool is_label_hidden,
672  bool join_with_next,
673  const char *help,
674  const char *script_callback,
675  HOM_EnumValue &script_callback_language,
676  const std::map<std::string, std::string> &tags,
677  const std::map<HOM_EnumValue *, std::string> &conditionals,
678  const std::vector<std::string> &default_expression,
679  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
680 
681  virtual HOM_DataParmTemplate *newDataParmTemplate(
682  const char *name,
683  const char *label,
684  int num_components,
685  HOM_EnumValue &look,
686  HOM_EnumValue &naming_scheme,
687  HOM_EnumValue &data_parm_type,
688  const char *disable_when,
689  bool is_hidden,
690  bool is_label_hidden,
691  bool join_with_next,
692  const char *help,
693  const char *script_callback,
694  HOM_EnumValue &script_callback_language,
695  const std::map<std::string, std::string> &tags,
696  const std::map<HOM_EnumValue *, std::string> &conditionals,
697  const std::vector<std::string> &default_expression,
698  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
699 
700  virtual HOM_ToggleParmTemplate *newToggleParmTemplate(
701  const char *name,
702  const char *label,
703  bool default_value,
704  const char *disable_when,
705  bool is_hidden,
706  bool is_label_hidden,
707  bool join_with_next,
708  const char *help,
709  const char *script_callback,
710  HOM_EnumValue &script_callback_language,
711  const std::map<std::string, std::string> &tags,
712  const std::map<HOM_EnumValue *, std::string> &conditionals,
713  const std::string &default_expression,
714  const HOM_EnumValue &default_expression_language) = 0;
715 
716  virtual HOM_MenuParmTemplate *newMenuParmTemplate(
717  const char *name,
718  const char *label,
719  const std::vector<std::string> &menu_items,
720  const std::vector<std::string> &menu_labels,
721  int default_value,
722  const std::vector<std::string> &icon_names,
723  const std::string &item_generator_script,
724  HOM_EnumValue *item_generator_script_language,
725  HOM_EnumValue &menu_type,
726  bool menu_use_token,
727  const char *disable_when,
728  bool is_hidden,
729  bool is_label_hidden,
730  bool join_with_next,
731  const char *help,
732  const char *script_callback,
733  HOM_EnumValue &script_callback_language,
734  const std::map<std::string, std::string> &tags,
735  const std::map<HOM_EnumValue *, std::string> &conditionals,
736  const std::string &default_expression,
737  const HOM_EnumValue &default_expression_language,
738  bool store_default_value_as_string,
739  bool is_button_strip,
740  bool strip_uses_icons
741  ) = 0;
742 
743  virtual HOM_ButtonParmTemplate *newButtonParmTemplate(
744  const char *name,
745  const char *label,
746  const char *disable_when,
747  bool is_hidden,
748  bool is_label_hidden,
749  bool join_with_next,
750  const char *help,
751  const char *script_callback,
752  HOM_EnumValue &script_callback_language,
753  const std::map<std::string, std::string> &tags,
754  const std::map<HOM_EnumValue *, std::string> &conditionals ) = 0;
755 
756  virtual HOM_LabelParmTemplate *newLabelParmTemplate(
757  const char *name,
758  const char *label,
759  const std::vector<std::string> &column_labels,
760  bool is_hidden,
761  bool is_label_hidden,
762  bool join_with_next,
763  const char *help,
764  const std::map<std::string, std::string> &tags,
765  const std::map<HOM_EnumValue *, std::string> &conditionals) = 0;
766 
767  virtual HOM_SeparatorParmTemplate *newSeparatorParmTemplate(
768  const char *name,
769  bool is_hidden,
770  const std::map<std::string, std::string> &tags,
771  const std::map<HOM_EnumValue *, std::string> &conditionals) = 0;
772 
773  virtual HOM_FolderSetParmTemplate *newFolderSetParmTemplate(
774  const char *name,
775  const std::vector<std::string> &folder_names,
776  HOM_EnumValue &folder_type,
777  const std::map<std::string, std::string> &tags) = 0;
778 
779  virtual HOM_FolderParmTemplate *newFolderParmTemplate(
780  const char *name,
781  const char *label,
782  const std::vector<HOM_ParmTemplate *> &parm_templates,
783  HOM_EnumValue &folder_type,
784  int default_value,
785  bool is_hidden,
786  bool ends_tab_group,
787  const char *script_callback,
788  HOM_EnumValue &script_callback_language,
789  const std::map<std::string, std::string> &tags,
790  const std::map<HOM_EnumValue *, std::string> &conditionals,
791  const std::map<HOM_EnumValue *, std::string> &tab_conditionals) = 0;
792 
793  virtual HOM_RampParmTemplate *newRampParmTemplate(
794  const char *name,
795  const char *label,
796  HOM_EnumValue &ramp_parm_type,
797  int default_value,
798  HOM_EnumValue *default_basis,
799  bool show_controls,
800  HOM_EnumValue *color_type,
801  const char *disable_when,
802  bool is_hidden,
803  const char *help,
804  const char *script_callback,
805  HOM_EnumValue &script_callback_language,
806  const std::map<std::string, std::string> &tags,
807  const std::map<HOM_EnumValue *, std::string> &conditionals,
808  const std::string &default_expression,
809  const HOM_EnumValue &default_expression_language) = 0;
810 
811  virtual HOM_ParmTemplateGroup *newParmTemplateGroup(
812  const std::vector<HOM_ParmTemplate *> &parm_templates) = 0;
813 
814  virtual HOM_PerfMonRecordOptions *newPerfMonRecordOptions(
815  bool cook_stats, bool pdg_cook_stats, bool solve_stats,
816  bool draw_stats, bool gpu_draw_stats, bool viewport_stats,
817  bool script_stats, bool render_stats, bool thread_stats,
818  bool frame_stats, bool memory_stats, bool errors,
819  bool pane_stats) = 0;
820 
821  virtual HOM_Keyframe *newKeyframe() = 0;
822  virtual HOM_Keyframe *newKeyframe(double value) = 0;
823  virtual HOM_Keyframe *newKeyframe(double value, double time) = 0;
824  virtual HOM_Keyframe *newKeyframe(const HOM_Keyframe &keyframe) = 0;
825 
826  virtual HOM_StringKeyframe *newStringKeyframe() = 0;
827  virtual HOM_StringKeyframe *newStringKeyframe(
828  const std::string &value, HOM_EnumValue &language) = 0;
829  virtual HOM_StringKeyframe *newStringKeyframe(
830  const std::string &value, double time, HOM_EnumValue &language) = 0;
831  virtual HOM_StringKeyframe *newStringKeyframe(
832  const HOM_StringKeyframe &string_keyframe) = 0;
833 
834  virtual HOM_HDAOptions *newHDAOptions() = 0;
835  virtual HOM_LopViewportLoadMasks *newLopViewportLoadMasks() = 0;
836  virtual HOM_LopInstanceIdRule *newLopInstanceIdRule() = 0;
837  virtual HOM_LopSelectionRule *newLopSelectionRule() = 0;
838 
839  virtual HOM_InterruptableOperation *newInterruptableOperation(
840  const char *operation_name, const char *long_operation_name,
841  bool open_interrupt_dialog) = 0;
842 
843  virtual HOM_RedrawBlock *newRedrawBlock() = 0;
844 #ifndef SWIG
845  virtual HOM_RedrawResumeBlock *newRedrawResumeBlock() = 0;
846 #endif
847 
848  virtual HOM_StyleSheet *newStyleSheet() = 0;
849  virtual HOM_StyleSheet *newStyleSheet(const char *json_text) = 0;
850 
851  virtual HOM_Selection *newSelection(HOM_EnumValue &selection_type,
852  HOM_Geometry *geo, const char *selection_string) = 0;
853  virtual HOM_Selection *newSelection(
854  const std::vector<HOM_EnumValue *> &selection_types,
855  HOM_Geometry *geo, const char *selection_string) = 0;
856  virtual HOM_Selection *newSelection(
857  const std::vector<HOM_Prim *> &prims) = 0;
858  virtual HOM_Selection *newSelection(
859  const std::vector<HOM_Point *> &points) = 0;
860  virtual HOM_Selection *newSelection(
861  const std::vector<HOM_Vertex *> &vertices) = 0;
862  virtual HOM_Selection *newSelection(
863  const std::vector<HOM_Edge *> &edges) = 0;
864 
865  // This method returns a new HOM_Geometry object.
866  virtual HOM_Geometry *newGeometry(HOM_Geometry *geo = nullptr,
867  bool clone_data_ids = false) = 0;
868 
869  virtual HOM_GeometryRayCache *newGeometryRayCache() = 0;
870 
871  virtual HOM_DopSimulation *newDopSimulation() = 0;
872 
873  virtual HOM_Clip *newClip() = 0;
874 
875  virtual HOM_AgentDefinition *newAgentDefinition(
876  const HOM_AgentRig &rig, const HOM_AgentShapeLibrary &shapelib) = 0;
877 
878  virtual HOM_AgentClip *newAgentClip(
879  const char *name, const char *path, const HOM_AgentRig &rig,
880  bool keep_external_ref, bool delay_load) = 0;
881 
882  virtual HOM_AgentClip *newAgentClip(
883  const char *name, HOM_ChopNode &chop, const HOM_AgentRig &rig,
884  double frame) = 0;
885 
886  virtual HOM_AgentClip *newAgentClip(
887  const char *name, const HOM_AgentRig &rig, int sample_count) = 0;
888 
889  virtual HOM_AgentClip *newAgentClip(
890  const HOM_AgentClip &clip, const HOM_AgentRig &rig,
891  const char *name) = 0;
892 
893  virtual HOM_AgentRig *newAgentRig(const char *path, bool keep_external_ref) = 0;
894 
895  virtual HOM_AgentRig *newAgentRig(
896  const char *name, const std::vector<std::string> &transform_names,
897  const std::vector<std::vector<int>> &hierarchy) = 0;
898 
899  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
900  const char *path, const HOM_AgentRig &rig,
901  bool keep_external_ref = true) = 0;
902 
903  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
904  const char *name, const std::vector<int> &transforms,
905  const HOM_AgentRig &rig, const std::vector<double> &weights,
906  const std::vector<int> &channels) = 0;
907 
908  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary() = 0;
909  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary(
910  HOM_Geometry &geometry, const char *name) = 0;
911  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary(
912  const char *path, bool keep_external_ref) = 0;
913 
914  virtual HOM_AgentShapeBinding *
915  newAgentShapeBinding(int transform, const HOM_AgentShape &shape,
916  bool deforming, double bounds_scale) = 0;
917 
918  virtual HOM_AgentShapeBinding *
919  newAgentShapeBinding(int transform, const HOM_AgentShape &shape,
920  const HOM_AgentShapeDeformer *deformer,
921  double bounds_scale) = 0;
922 
923  virtual HOM_AgentShapeDeformer *
924  newAgentShapeDeformer(const char *name) = 0;
925 
926  virtual HOM_AgentShapeDeformer *
927  newAgentShapeDeformer(const HOM_EnumValue &deformer_type) = 0;
928 
929  virtual HOM_AgentLayer *newAgentLayer(
930  const char *name, const HOM_AgentRig &rig,
931  const HOM_AgentShapeLibrary &shapelib,
932  const std::vector<HOM_AgentShapeBinding *> &shape_bindings,
933  const HOM_AgentLayer *source_layer = 0) = 0;
934 
935  virtual HOM_AgentLayer *
936  newAgentLayer(const char *path, const HOM_AgentRig &rig,
937  const HOM_AgentShapeLibrary &shapelib,
938  bool keep_external_ref = true) = 0;
939 
940  virtual HOM_AgentMetadata *newAgentMetadata(
941  const char *path,
942  bool keep_external_ref = true) = 0;
943  virtual HOM_AgentMetadata *newAgentMetadata(
944  const std::map<std::string, hboost::any> &data) = 0;
945 
946  virtual bool compareNode(const char *path, const char *dest = NULL) = 0;
947  virtual bool compareNodeBackup(const char *path, int index,
948  const char *dest = NULL) = 0;
949  virtual bool compareHDA(const char *path_left, const char *path_right,
950  const char *dest = NULL) = 0;
951  virtual bool compareHDABackup(const char *path, int index,
952  const char *dest = NULL) = 0;
953  virtual bool compareHip(const char *dest = NULL) = 0;
954  virtual bool compareHipBackup(int index, const char *dest = NULL) = 0;
955 
956  virtual bool hasContextOption(const char *opt) = 0;
957  virtual UT_OptionEntryPtr contextOption(const char *opt) = 0;
958  virtual std::vector<std::string> contextOptionNames() = 0;
959  virtual void setContextOption(const char *opt, const char *value) =0;
960  virtual void setContextOption(const char *opt, double value) = 0;
961  virtual void removeContextOption(const char *opt) = 0;
962  virtual std::string contextOptionConfig(const char *opt) = 0;
963  virtual void setContextOptionConfig(const char *opt,
964  const char *config) = 0;
965 
966  SWIGOUT(%ignore addOpaqueContextOptionChangeCallback;)
967  virtual void addOpaqueContextOptionChangeCallback(void *callback) = 0;
968  SWIGOUT(%ignore removeOpaqueContextOptionChangeCallback;)
969  virtual void removeOpaqueContextOptionChangeCallback(void *callback) = 0;
970  virtual void removeAllContextOptionChangeCallbacks() = 0;
971 
972  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
973 
974  // This method is called when orbolt_url runs. It is not wrapped by swig.
975  virtual void setOrboltURLHandler(
976  STORUI_OrboltURLHandler &orbolt_url_handler) = 0;
977 
978  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
979 
980  // These methods are used to help debug HOM to make sure no objects
981  // get allocated that don't get deallocated.
982  virtual void constructObject(void *pointer, const std::type_info &type) = 0;
983  virtual void destructObject(void *pointer, const std::type_info &type) = 0;
984  virtual std::map<std::string, int> objectCounts() = 0;
985 
986  // Preferences
987  virtual std::vector<std::string> getPreferenceNames() = 0;
988  virtual std::string getPreference(const char *name) = 0;
989  virtual bool setPreference(const char *name, const char* value) = 0;
990  virtual bool addPreference(const char *name, const char* value) = 0;
991  virtual bool removePreference(const char *name) = 0;
992 
993  virtual HOM_ViewerStateTemplate * newViewerStateTemplate(
994  std::string const & type_name,
995  std::string const & label,
996  HOM_NodeTypeCategory const & category,
997  std::vector<HOM_NodeTypeCategory*> const & contexts) = 0;
998 
999  virtual HOM_ViewerHandleTemplate * newViewerHandleTemplate(
1000  std::string const & type_name,
1001  std::string const & label,
1002  std::vector<HOM_NodeTypeCategory*> const & categories) = 0;
1003 
1004  virtual HOM_ViewerStateMenu * newViewerStateMenu(std::string const & handle, std::string const & label) = 0;
1005 
1006  virtual HOM_SimpleDrawable * newSimpleDrawable( HOM_SceneViewer& scene_viewer, HOM_EnumValue const &prim_type, std::string const &name) = 0;
1007  virtual HOM_SimpleDrawable * newSimpleDrawable( HOM_SceneViewer& scene_viewer, HOM_Geometry const &geometry, std::string const &name) = 0;
1008 
1009  virtual HOM_ViewerHandleDragger * newViewerHandleDragger(std::string const & name) = 0;
1010  virtual HOM_ViewerStateDragger * newViewerStateDragger(std::string const & name, HOM_Matrix4 const & xform, HOM_Matrix4 const & inv_xform) = 0;
1011 
1012  virtual HOM_UIEvent * newUIEvent( int64 val ) = 0;
1013  virtual HOM_ViewerEvent * newViewerEvent( HOM_SceneViewer& sceneViewer, int64 val ) = 0;
1014  virtual HOM_UIEventDevice * newUIEventDevice(int64 val, int64 val2) = 0;
1015 
1016  virtual HOM_Handle * newHandle(HOM_SceneViewer& scene_viewer, std::string const &name ) = 0;
1017  virtual HOM_ViewerHandleContext * newViewerHandleContext(int64 val) = 0;
1018 
1019  virtual HOM_ViewerStateContext * newViewerStateContext(int64 val) = 0;
1020 
1021  virtual HOM_TextDrawable * newTextDrawable(
1022  HOM_SceneViewer& scene_viewer,
1023  std::string const & name,
1024  std::map<std::string, hboost::any> const & params,
1025  std::string const & label) = 0;
1026 
1027  virtual HOM_GeometryDrawable * newGeometryDrawable(
1028  HOM_SceneViewer& scene_viewer,
1029  HOM_EnumValue const & geo_type,
1030  std::string const & name,
1031  HOM_Geometry * geometry,
1032  std::map<std::string, hboost::any> const & params,
1033  std::string const & label) = 0;
1034 
1035  virtual HOM_GeometryDrawableGroup* newGeometryDrawableGroup(std::string const & name, std::string const & label) = 0;
1036 
1037  virtual HOM_GadgetDrawable * newGadgetDrawable(int64 widget, int64 gadget_context) = 0;
1038 
1039  virtual void startHoudiniEngineDebugger(unsigned short port) = 0;
1040  virtual void startHoudiniEngineDebugger(const char *pipe_name) = 0;
1041 
1042  virtual HOM_GeometrySelection * newGeometrySelection() = 0;
1043  virtual HOM_GeometrySelection * newGeometrySelection(int64 val) = 0;
1044 
1045  virtual HOM_BinaryString convertClipData(HOM_BinaryString data,
1046  bool from_binary,
1047  bool from_blosc_compression,
1048  bool to_binary,
1049  bool to_blosc_compression) = 0;
1050 
1051  virtual HOM_BinaryString convertKeyframesToClipData(
1052  const std::map<std::string, std::vector<HOM_Keyframe *>> &keyframe_map,
1053  bool binary = true, bool use_blosc_compression = true) = 0;
1054 
1055  virtual std::string _clipInfo(HOM_BinaryString data, bool binary = true,
1056  bool blosc_compressed = true) = 0;
1057 
1058  virtual std::vector<HOM_ElemPtr<HOM_Node> > _nodesFromOPNodeList(int64 val) = 0;
1059  virtual std::vector<HOM_ElemPtr<HOM_DopData> >
1060  _dopDataList(int64 val) = 0;
1061  virtual std::vector<std::pair<HOM_ElemPtr<HOM_DopData>, HOM_ElemPtr<HOM_GeometrySelection> > >
1062  _dopDataPointList(int64 val) = 0;
1063  virtual std::vector<std::pair<HOM_ElemPtr<HOM_DopData>, HOM_ElemPtr<HOM_GeometrySelection> > >
1064  _dopDataPolyList(int64 val) = 0;
1065 
1066  virtual HOM_AttribDataId * newAttribDataId() = 0;
1067 
1068  virtual std::string userName(bool alpha=true) = 0;
1069 
1070  virtual std::string machineName(bool alpha=true) = 0;
1071 
1072  virtual HOM_GeometryDrawable * _newGeometryDrawable(int64 val) = 0;
1073 
1074  virtual HOM_Node * createAnimationLayers(const std::string &path) = 0;
1075  virtual HOM_Node * addAnimationLayer(HOM_Node &layermixer, const std::string &layername) = 0;
1076  virtual bool removeAnimationLayer(HOM_Node &layermixer, const std::string &layername, bool merge=false) = 0;
1077  virtual HOM_Node* createAnimationClip(const std::string &path, bool set_export) = 0;
1078 private:
1079  // HOMF_Module::createHOMModule() uses this to create the HOM_Module.
1080  static void (*theHOMCreator)();
1081 
1082  // A subclass of HOM_Module in the HOMF library will define the
1083  // implementation of HOM. Importing the python module will set the
1084  // implementation, so this function should only be called by HOMF_Module::
1085  // createHOMModule().
1086  friend class HOMF_Module;
1087  static void setImplementation(HOM_Module* implementation);
1088 
1089  // We could add a static method to access the implementation, but we
1090  // want to make it easy to access the HOM module from C++. So, the
1091  // global function HOM() needs access to the implementation.
1092  friend HOM_API HOM_Module& HOM();
1093  static HOM_Module *theImplementation;
1094 };
1095 
1096 
1097 // Use this function to automatically delete objects for functions that
1098 // return new objects. This lets you, for example, write code like
1099 // HOMdel(HOM().findNode("/obj/geo1"))->setName("geo2")
1100 template <typename T>
1102 { return UT_UniquePtr<T>(hom_object); }
1103 
1104 
1105 // This lock is used to synchronize HOM scripts running in a separate
1106 // thread and Houdini. Houdini's UI queue will give up the lock when it's
1107 // waiting for events and reacquire it when it handles an event.
1108 //
1109 // Note that this lock allows multiple threads in the same thread group to hold
1110 // it at the same time. By default, a thread started from Houdini is added to
1111 // the group containing the main thread. This way, since Houdini started the
1112 // thread, we can be confident that it will use other locks to synchronize
1113 // access to Houdini. This approach allows, for example, a volume SOP to
1114 // cook using multiple threads, evaluating Python in each thread while the
1115 // main thread holds the HOM lock, without deadlocking and without allowing
1116 // non-Houdini threads to acquire the HOM lock. (Note that the GIL will
1117 // synchronize access to Python's internals.)
1120 {
1121  // This is not thread-safe but should be ok because HOMgetLock() is called
1122  // pretty early on during startup when there is only one thread executing.
1123  if (!HOM_theHOMLock)
1124  HOM_theHOMLock = new UT_TaskRootLock();
1125 
1126  UT_ASSERT(HOM_theHOMLock);
1127  return *HOM_theHOMLock;
1128 }
1129 
1130 // The HOM implementation uses the HOM_AutoLock to make sure Houdini isn't busy
1131 // when they make calls into the Houdini libraries. Note that constructing
1132 // a HOM_AutoLock will release the python global interpreter lock (GIL) if
1133 // it was held before acquiring the HOM lock. This way, other python threads
1134 // can run if it needs to block waiting for the HOM lock.
1136 {
1137 public:
1139  {
1140  if (!HOMgetLock().hasLock())
1141  {
1142  HOMgetLock().lock();
1143  myLocked = true;
1144  }
1145  else
1146  myLocked = false;
1147  }
1148 
1150  {
1151  if (myLocked)
1152  HOMgetLock().unlock();
1153  }
1154 
1155 private:
1156 
1157  // It is important that we release the python global interpreter lock
1158  // (GIL) for the duration of waiting for, acquiring and holding onto
1159  // the HOM lock. This gives other threads that are either blocked
1160  // on the GIL or that will try to acquire the GIL a chance to continue
1161  // execution.
1162  //
1163  // If the current thread needs to access the Python API,
1164  // then it should explicitly acquire the GIL by creating a
1165  // PY_InterpreterAutoLock object. The PY_InterpreterAutoLock must be
1166  // constructed *after* the HOM_AutoLock or it will have no effect.
1167  //
1168  // This prevents deadlocks that occur when the current thread
1169  // spawns other threads which access the Python API and try to
1170  // acquire the GIL.
1171  //
1172  // Note that we will reacquire the GIL when the HOM auto lock is destructed.
1173  PY_InterpreterAutoUnlock myPyInterpAutoUnlock;
1174 
1175  // Boolean to determine if the auto lock actually locked the HOM lock.
1176  bool myLocked;
1177 };
1178 
1179 // The HOM implementation uses HOM_AutoUnlock to allow the main thread to
1180 // run while waiting for something to happen. Constructing a HOM_AutoUnlock
1181 // instance will release the HOM lock but not the Python GIL. When it's
1182 // destructed it will reacquire the HOM lock. Since it releases the HOM lock,
1183 // it's important that a HOM_AutoLock was already created in a containing
1184 // scope.
1185 //
1186 // Use HOM_AutoUnlock in conjunction with PY_InterpreterAutoUnlock to
1187 // also release the Python GIL. Be sure to create the HOM_AutoUnlock *after*
1188 // the PY_InterpreterAutoUnlock, so that when the auto locks are destructed
1189 // the HOM lock is reacquired before the Python GIL. Otherwise, it will grab
1190 // the GIL and then try to grab the HOM lock, and if another thread with the
1191 // HOM lock tries to run Python we'll end up with deadlock.
1193 {
1194 public:
1196  { HOMgetLock().unlock(); }
1197 
1199  { HOMgetLock().lock(); }
1200 };
1201 
1202 
1203 // These macros are used to help detect memory leaks when debugging is enabled.
1204 #ifdef HOM_DEBUG
1205 #define HOM_CONSTRUCT_OBJECT(pointer) \
1206  HOM().constructObject(pointer, typeid(*pointer));
1207 #define HOM_DESTRUCT_OBJECT(pointer) \
1208  HOM().destructObject(pointer, typeid(*pointer));
1209 #else
1210 #define HOM_CONSTRUCT_OBJECT(pointer)
1211 #define HOM_DESTRUCT_OBJECT(pointer)
1212 #endif
1213 
1214 // NOTE: These typedefs cannot actually be used in any method declaration
1215 // that SWIG needs to generate code for because it doesn't understand
1216 // them.
1217 // gcc gets a parse error if we try to give a default map value in the
1218 // signature, and the typedef avoids the error.
1219 typedef std::map<std::string, std::string> HOM_StdMapStringString;
1220 typedef std::map<HOM_EnumValue *, std::string> HOM_StdMapEnumString;
1221 
1222 
1223 // Houdini will call HOMextendLibrary() in HDK dso's so the user can install
1224 // C++ HOM extensions.
1225 extern "C" {
1227 }
1228 
1229 #endif //__HOM_Module_h__
GLbyte * weights
Definition: glew.h:7551
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
OIIO_API string_view getenv(string_view name)
GLuint const GLchar * name
Definition: glew.h:1814
GLclampf GLclampf GLclampf alpha
Definition: glew.h:1520
GLenum mode
Definition: glew.h:2163
#define SYS_VISIBILITY_EXPORT
UT_TaskRootLock & HOMgetLock()
Definition: HOM_Module.h:1119
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1252
GLuint GLenum GLenum transform
Definition: glew.h:14742
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
GLuint const GLfloat * val
Definition: glew.h:2794
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1252
UT_UniquePtr< T > HOMdel(T *hom_object)
Definition: HOM_Module.h:1101
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
Definition: HOM_ik.h:21
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
Definition: HOM_qt.h:20
GLenum condition
Definition: glew.h:12785
UT_TaskLockT< false > UT_TaskRootLock
Definition: UT_TaskLock.h:282
GLsizei GLenum * categories
Definition: glew.h:2581
HOM_API UT_TaskRootLock * HOM_theHOMLock
bool any(const vbool4 &v)
Definition: simd.h:3372
#define HOM_API
Definition: HOM_API.h:13
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
virtual ~HOM_Module()
Definition: HOM_Module.h:169
const GLuint GLenum const void * binary
Definition: glew.h:3502
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
Definition: HOM_ui.h:44
void
Definition: png.h:1083
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
GLuint color
Definition: glew.h:7902
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
GLuint GLsizei GLsizei GLchar * label
Definition: glew.h:8986
std::map< HOM_EnumValue *, std::string > HOM_StdMapEnumString
Definition: HOM_Module.h:1220
GLsizei const GLchar *const * path
Definition: glew.h:6461
GLsizei const GLchar *const * string
Definition: glew.h:1844
SYS_VISIBILITY_EXPORT void HOMextendLibrary()
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
std::string OIIO_API repeat(string_view str, int n)
Repeat a string formed by concatenating str n times.
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2579
GLsizei const void * pointer
Definition: glew.h:1523
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3446
virtual bool readFile(GA_Detail &g, const char *filename, const GA_LoadOptions *opts, UT_StringArray *errors) const
Class which defines an I/O interface to save/load geometry.
const GLfloat * params
Definition: glew.h:1531
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
SYS_VISIBILITY_EXPORT void newHandle(BM_ResourceManager *m)
void unlock()
Definition: UT_TaskLock.h:254
Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t)
Definition: ImathQuat.h:545
GLubyte * pattern
Definition: glew.h:5711
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
HOM_API HOM_Module & HOM()
GLenum GLint GLint * precision
Definition: glew.h:3500
GLsizei const GLfloat * value
Definition: glew.h:1849
static bool isImplementationSet()
Definition: HOM_Module.h:505
std::map< std::string, std::string > HOM_StdMapStringString
Definition: HOM_Module.h:1219
GLfloat units
Definition: glew.h:10289
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
GLenum const void * paths
Definition: glew.h:13589