HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_EnvControl.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  * NAME: UT_EnvControl.h ( UT Library, C++)
7  *
8  * COMMENTS: In Houdini applications, there are many environment variables
9  * which control the behaviour of certain features/capabilities.
10  * This class provides a centralized place to efficiently query
11  * these variables. The reason for the centralization is so that
12  * we can easily get a list of these control variables. As well,
13  * this mechanism provides ways of changing the control settings
14  * from environment variables to disk file to registry entry.
15  * Currently only environment variable control is supported.
16  *
17  *
18  * When adding a new environment variable, please document the variable in
19  * $SHD/ref/env.txt
20  */
21 
22 #ifndef __UT_EnvControl__
23 #define __UT_EnvControl__
24 
25 #include "UT_API.h"
26 #include <UT/UT_StringHolder.h>
27 #include <SYS/SYS_StaticAssert.h>
28 #include <SYS/SYS_Types.h>
29 
30 class UT_StringArray;
31 
32 namespace UT_Package
33 {
34  class Loader;
35  class Package;
36 }
37 
38 // This define declares a fixed size of array for holding our cached
39 // environment variable values. It should be larger than any of our actual
40 // requirements so that we can add new enum values to the end of these
41 // tables without breaking ABI compatibility (as long as we don't actually
42 // exceed this value and need to increase it).
43 #define MAX_CONTROLS_WITH_BUFFER 512
44 
46 {
47  // UT library: Public interface
65 
66  // UT: Internal controls
78 
79  // Houdini Environment File Control
82 
83  // FS: Public interface
91 
92  // GA: Public interface
94 
95  // IMG3D: Public interface
97 
98  // IMG: Public interface
126  // IMG: Private interface
134 
135  // MV: Public interface
137 
138  // VEX: Public interface
149 
150  // VEX: Private interface
152 
153  // RE: Public interface
163 
164  // CMD
167 
168  // OP
172 
173  // GEO
177 
178  // GU
180 
181  // RAY
193 
196 
217 
218  // COP2
221 
222  // IFD
226 
227  // MAT
229 
230  // UI
250 
251  // OPUI
257 
258  // DM
261 
262  // MATUI
264 
265  // Custom
270 
271  // LM
282 
283  // CHOP
285 
286  // SHOP
289 
290  // VOP
292 
293  // SHLF
296 
297  // Other
303 
304  // Backwards Compatability
313 
325 
327  // Have houdini check process fallback to the old deprecated API
331 
333 
334  // hscript
338 
340 
341  // This is for "internal use" only. It turns on features that are not
342  // ready for prime-time.
344 
345  // Maximum number of files to keep in the backup directory
347 
349 
351 
353 
356 
359 
361 
362  // Controls the number of complete FBX scenes to
363  // keep cached in memory after import. Defaults to 1.
365 
366  // Controls whether to transform the results of evaluating a MotionClip
367  // by the intrinsic matrix of the packed primitive.
369 
374 
376 
379 
380  // OpenGL
384 
385  // OpenCL
390  // Can be used to force disable the use of images for advection by the Gas
391  // Advect CL 2.0 DOP.
393 
397 
399 
400  // Maximum megabytes in write buffer.
402 
404 
408 
411 
413 
415 
417 
419 
421 
424 
426 
428 
429  // Used to force regular LM checks on Steam builds
431 
432  // OptiX
434 
436 
437  // Package
440 
441  // Viewer state
443 
445 
447 
449 
450  // TOP
462 
463  // HAPI
465 
466  // LOP
469 
471 
472  // HDA plugin for USD geometry cache size
474 
476 
478 
480 
481  // Send python panel erros to the console
483 
485 
487 
489 
490  // Specify whether or not Houdini GL should use Mtlx materials
492 
493  // New op viewer, defaults to on.
495 
497 
499 
501 
502  // Karma legacy dicing behaviour
504 
505  // Save HDA internal sections alphabetically (where it makes sens)
507 
509 
510  // MV
512 
514 
516 };
517 
519 {
520  // UT: Public interface
524 
525  // UT: Internal variables
527 
528  // IMG: Public interface
531 
532  // RE
534 
535  // UI
538 
539  // GR
541 
542  // Custom
544 
545  // ROP: Internal variables
547 
548  // OpenCL: Memory pool size, as percentage of GPU memory.
550 
551  // CH
553 
555 };
556 
558 {
559  // UT: Public interface
578 
579  // UT: Internal variables
583 
584  // external tools
586 
587  // IMG: Public interface
590 
591  // VEX(VMAT)
600 
601  // HOM
603 
604  // OP
605  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
608 
609  // VOP
611 
612  // GEO
614 
615  // COP
622 
623  // CHOP
625 
626  // TOP
628 
629  // IFD
635 
636  // UI
647 
648  // FUI
651 
652  // CHUI
654 
655  // OPUI
659 
660  // VEX(VCC)
662 
663  // Custom
671  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
672 
673  // Path variables
705 
709 
711 
713 
715 
721 
723 
728 
735 
737 
739 
740  // These are here so we can have them show up in hconfig and provide
741  // help. They should only be used implicitly.
742  ENV_HSITE, // Between HFS and HOME.
743  ENV_JOB, // We should not use JOB!
744 
746 
749 
751 
752  // OPENGL
759 
760  // OPENCL
765 
766  // Orbolt
768 
769  // Anonymous Usage Statistics
771 
773 
775 
777 
778  // Optix
780 
782 
783  // BGEO plugin for USD default load arguments
785 
786  // LM
802 
803  // Python
805 
806  // Logging
808 
809  // Default asset/material gallery databases
812 
813  // Networking
816 
817  // HQueue
823 
825 };
826 
827 // If these constraints are ever violated in a HEAD branch, it's time to
828 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
829 // a released build, get rid of the "+50" part, and if they are exceeded
830 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
831 // break ABI compatiblity. But hopefully that won't happen...
835 
837 {
838 public:
839  UT_EnvControl();
840  ~UT_EnvControl();
841 
842  UT_EnvControl(const UT_EnvControl &) = delete;
843  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
844 
845  void init();
846 
847  static int getInt(UT_IntControl i)
848  { return getControl().myIValues[i]; }
850  { return getControl().myFValues[i]; }
851  static const char *getString(UT_StrControl i)
852  { return getControl().mySValues[i]; }
853 
854  // Look up the appropriate variable name for the token
855  static const char *getIntVar(UT_IntControl i);
856  static const char *getFloatVar(UT_FltControl i);
857  static const char *getStringVar(UT_StrControl i);
858 
859  static void setStringVar(UT_StrControl i, const char *value);
860 
861  // Look up the appropriate old style variable name for the token. This can
862  // be used to check for old environment variables.
863  static const char *getOldIntVar(UT_IntControl i);
864  static const char *getOldFloatVar(UT_FltControl i);
865  static const char *getOldStringVar(UT_StrControl i);
866 
867  /// Indicate that the given variable changed and update our cached values.
868  /// If varname is NULL, then all variables are updated.
869  static void varChanged(const char *varname)
870  { varChanged(varname, nullptr); }
871 
872  /// Update the cached varname value with the given value so that we can
873  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
874  /// @code
875  /// HoudiniSetenv(name, value);
876  /// UT_EnvControl::varChanged(name);
877  /// @endcode
878  /// @return true if name was found and value is non-null, in which case the
879  /// HoudiniSetenv() was called, else false is returned.
880  static bool varChanged(const char *varname, const char *value);
881 
882  static void changeExistLookupDefault(UT_IntControl i, int new_def);
883 
884  /// Set all additional .env files to be parsed for env variable values.
885  /// It is best to call getAdditionalEnvironmentFiles() first and then
886  /// append to the list because this function will overwrite all the
887  /// additional paths that were previously set.
888  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
889  /// overwrites, knowing that these files get applied AFTER the default
890  /// houdini.env file in the user's home directory.
891  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
892  /// If additional files are set, they will be used, regardless of the
893  /// value of HOUDINI_NO_ENV_FILE.
894  static void setAdditionalEnvironmentFiles(
895  const UT_StringArray &files);
896 
897  /// Return the current list of additional environment files.
898  static const UT_StringArray&
899  getAdditionalEnvironmentFiles();
900 
901  // Print messages collected during init phase to console
902  static void logMessages()
903  {
904  getControl().logMessagesToConsole();
905  }
906 
907  // Package loader management
908  // Load the pakages located in the folders specified by pkg_paths.
909  // Use this method for loading package dynamically
910  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
911  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
912 
913  // Returns the main package loader, this loader contains all
914  // packages loaded at runtime.
915  static UT_Package::Loader& packageLoader();
916 
917 private:
918  void doInit(bool init_defaults);
919  void setDefaults();
920  bool loadEnvironmentFile(const char *path,
921  bool allow_overrides);
922  void loadDefaultEnvironmentFile();
923  void loadEnvironmentFiles();
924  void loadEnvironment(bool init_defaults);
925 
926  void updateExistLookup(int i, const char *value = nullptr);
927  void updateIntLookup(int i, const char *value = nullptr);
928  void updateFltLookup(int i, const char *value = nullptr);
929  void updateStrLookup(int i, bool fix_path,
930  const char *value = nullptr);
931 
932  void updateVarTables(UT_Package::Loader const& pkg_loader);
933 
934  void loadPackageConfig();
935  void logMessagesToConsole() const;
936 
937  int myIValues[MAX_CONTROLS_WITH_BUFFER];
938  float myFValues[MAX_CONTROLS_WITH_BUFFER];
939  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
940 
941  static UT_EnvControl &getControl()
942  {
943  if (!theControl)
944  {
945  theControl = new UT_EnvControl();
946  theControl->init();
947 
948  }
949  return *theControl;
950  }
951  static UT_EnvControl *theControl;
952 
953  UT_StringHolder myLogMessages;
954 };
955 
956 #endif
static void varChanged(const char *varname)
static const char * getString(UT_StrControl i)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define UT_API
Definition: UT_API.h:14
static void logMessages()
UT_StrControl
static int getInt(UT_IntControl i)
static fpreal getFloat(UT_FltControl i)
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_STATIC_ASSERT(ENV_MAX_INT_CONTROLS+50< MAX_CONTROLS_WITH_BUFFER)
Definition: core.h:1131
UT_FltControl
#define MAX_CONTROLS_WITH_BUFFER
Definition: UT_EnvControl.h:43
UT_IntControl
Definition: UT_EnvControl.h:45