HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGT_Utils.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  */
8 
9 #ifndef __PDGT_UTILS_H__
10 #define __PDGT_UTILS_H__
11 
12 #include "PDGT_API.h"
13 
14 #include <UT/UT_KnownPath.h>
15 
16 class UT_StringArray;
17 class UT_StringHolder;
18 class UT_WorkBuffer;
19 
20 /**
21  * Utility functions for loading PDG type definitions from Python modules
22  * and shared libraries.
23  */
25 {
26 public:
27  /// Loads a shared library containing PDG type definitions, given a path
28  /// to the dso, the name of the function to call in the library and the
29  /// argument to that function.
30  static bool loadDSO(const UT_StringHolder& dso_path,
31  const UT_StringHolder& dso_function,
32  void* dso_arg);
33 
34  static bool loadDSOFromPath(const UT_StringHolder& dso_path,
35  const UT_StringHolder& dso_function,
36  void* dso_arg);
37 
38  /// Loads shared libraries on the Houdini dso path that have the specified
39  /// dso_function and calls that function with the dso_arg.
40  static bool loadDSO(const UT_StringHolder& dso_function, void* dso_arg);
41 
42  /// Loads PDG types from all Python modules, and stores them in the module
43  /// specified by `type_module`. For example, in PDG the type_module is
44  /// set to `pdg.types`.
45  static bool loadPythonModules(const UT_StringHolder& type_module,
46  UT_WorkBuffer& errors);
47 
48  /// Loads PDG types from a Python module at a specifc path on the system.
49  static bool loadPythonPath(const UT_StringHolder& type_module,
50  const UT_StringHolder& path,
51  UT_WorkBuffer& errors);
52 
53  /// Reloads the PDG type from the specified Python module.
54  static bool reloadPythonModule(const UT_StringHolder& type_module,
55  const UT_StringHolder& python_module,
56  bool reregister,
57  UT_WorkBuffer& errors);
58 
59  /// Returns the array of search paths for finding PDG types definitions.
60  static void searchPath(UT_StringArray& path_list,
61  UT_KnownPath search_instance);
62 
63  /// Finds the specified file name on the search path, and returns the
64  /// absolute path to the file.
65  static bool findFile(const UT_StringHolder& file_name,
66  UT_StringHolder& output_file,
67  UT_KnownPath search_instance);
68 
69 
70  /// Globs all files with the specified extension on the PDG search path,
71  /// with an optional subdirectory.
72  static bool globFiles(UT_StringArray& file_list,
73  UT_KnownPath search_instance,
75  const UT_StringHolder& subdirectory,
76  bool full_path);
77 
78  /// Globs all of the directories from the search path
79  static bool globDirectories(UT_StringArray& dir_list,
80  UT_KnownPath search_instance,
81  const UT_StringHolder& search,
82  bool full_path,
83  bool unique);
84 
85  /// Globs the list of import-able Python modules from the PDG type
86  /// search path.
87  static bool globPythonModules(UT_StringArray& file_list,
88  UT_KnownPath search_instance,
89  const UT_StringHolder& subdir,
90  bool full_path,
91  bool unique);
92 
93  /// Returns a list of directories/files to skip when globbing python
94  /// modules
95  static bool moduleSkipList(UT_StringArray& skip_list);
96 };
97 
98 #endif
#define PDGT_API
Definition: PDGT_API.h:23
UT_KnownPath
Definition: UT_KnownPath.h:14
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
auto search(const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
A search function.
Definition: CLI11.h:3170
PUGI__FN I unique(I begin, I end)
Definition: pugixml.cpp:7464
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept