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 <SYS/SYS_Types.h>
27 #include "UT_StringArray.h"
28 
29 namespace UT_Package
30 {
31  class Loader;
32  class Package;
33 }
34 
35 // This define declares a fixed size of array for holding our cached
36 // environment variable values. It should be larger than any of our actual
37 // requirements so that we can add new enum values to the end of these
38 // tables without breaking ABI compatibility (as long as we don't actually
39 // exceed this value and need to increase it).
40 #define MAX_CONTROLS_WITH_BUFFER 512
41 
43 {
44  // UT library: Public interface
62 
63  // UT: Internal controls
74 
75  // Houdini Environment File Control
78 
79  // FS: Public interface
87 
88  // GA: Public interface
90 
91  // IMG3D: Public interface
93 
94  // IMG: Public interface
121  // IMG: Private interface
129 
130  // MV: Public interface
132 
133  // VEX: Public interface
144 
145  // VEX: Private interface
147 
148  // RE: Public interface
158 
159  // CMD
162 
163  // OP
167 
168  // GEO
172 
173  // GU
175 
176  // RAY
187 
189 
200 
201  // COP
204 
205  // IFD
209 
210  // MAT
212 
213  // UI
230 
231  // FP
233 
234  // OPUI
240 
241  // DM
244 
245  // MATUI
247 
248  // Custom
253 
254  // LM
264 
265  // CHOP
267 
268  // SHOP
271 
272  // VOP
274 
275  // SHLF
278 
279  // Other
285 
286  // Backwards Compatability
295 
307 
309  // Have houdini check process fallback to the old deprecated API
313 
315 
316  // hscript
320 
322 
323  // This is for "internal use" only. It turns on features that are not
324  // ready for prime-time.
326 
327  // Maximum number of files to keep in the backup directory
329 
331 
333 
335 
338 
341 
343 
344  // Controls the number of complete FBX scenes to
345  // keep cached in memory after import. Defaults to 1.
347 
348  // Controls whether to transform the results of evaluating a MotionClip
349  // by the intrinsic matrix of the packed primitive.
351 
356 
358 
361 
362  // OpenGL
365 
366  // OpenCL
371  // Can be used to force disable the use of images for advection by the Gas
372  // Advect CL 2.0 DOP.
374 
378 
380 
381  // Maximum megabytes in write buffer.
383 
385 
389 
392 
394 
396 
398 
400 
402 
405 
407 
409 
410  // Used to force regular LM checks on Steam builds
412 
413  // OptiX
415 
417 
418  // Package
421 
422  // Viewer state
424 
426 
428 
430 
431  // TOP
441 
442  // LOP
444 
446 
447  // HDA plugin for USD geometry cache size
449 
451 
453 
455 
456  // Send python panel erros to the console
458 
460 
462 };
463 
465 {
466  // UT: Public interface
470 
471  // UT: Internal variables
473 
474  // IMG: Public interface
477 
478  // RE
480 
481  // UI
484 
485  // GR
487 
488  // Custom
490 
491  // ROP: Internal variables
493 
494  // OpenCL: Memory pool size, as percentage of GPU memory.
496 
498 };
499 
501 {
502  // UT: Public interface
521 
522  // UT: Internal variables
526 
527  // external tools
529 
530  // IMG: Public interface
532 
533  // VEX(VMAT)
542 
543  // HOM
545 
546  // OP
547  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
550 
551  // VOP
553 
554  // GEO
556 
557  // COP
564 
565  // CHOP
567 
568  // IFD
574 
575  // UI
586 
587  // FUI
590 
591  // CHUI
593 
594  // OPUI
598 
599  // VEX(VCC)
601 
602  // Custom
610  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
611 
612  // Path variables
641 
645 
647 
649 
651 
656 
658 
661 
668 
670 
671  // These are here so we can have them show up in hconfig and provide
672  // help. They should only be used implicitly.
673  ENV_HSITE, // Between HFS and HOME.
674  ENV_JOB, // We should not use JOB!
675 
677 
680 
682 
683  // OPENGL
689 
690  // OPENCL
695 
696  // Orbolt
698 
699  // Anonymous Usage Statistics
701 
703 
705 
707 
708  // Optix
710 
712 
713  // BGEO plugin for USD default load arguments
715 
716  // LM
732 
733  // Python
735 
736  // Logging
738 
739  // Asset gallery database
741 
742  // Networking
745 
747 };
748 
749 // If these constraints are ever violated in a HEAD branch, it's time to
750 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
751 // a released build, get rid of the "+50" part, and if they are exceeded
752 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
753 // break ABI compatiblity. But hopefully that won't happen...
757 
759 {
760 public:
761  UT_EnvControl();
762  ~UT_EnvControl();
763 
764  void init();
765 
766  static int getInt(UT_IntControl i)
767  { return getControl().myIValues[i]; }
769  { return getControl().myFValues[i]; }
770  static const char *getString(UT_StrControl i)
771  { return getControl().mySValues[i]; }
772 
773  // Look up the appropriate variable name for the token
774  static const char *getIntVar(UT_IntControl i);
775  static const char *getFloatVar(UT_FltControl i);
776  static const char *getStringVar(UT_StrControl i);
777 
778  static void setStringVar(UT_StrControl i, const char *value);
779 
780  // Look up the appropriate old style variable name for the token. This can
781  // be used to check for old environment variables.
782  static const char *getOldIntVar(UT_IntControl i);
783  static const char *getOldFloatVar(UT_FltControl i);
784  static const char *getOldStringVar(UT_StrControl i);
785 
786  /// Indicate that the given variable changed and update our cached values.
787  /// If varname is NULL, then all variables are updated.
788  static void varChanged(const char *varname)
789  { varChanged(varname, nullptr); }
790 
791  /// Update the cached varname value with the given value so that we can
792  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
793  /// @code
794  /// HoudiniSetenv(name, value);
795  /// UT_EnvControl::varChanged(name);
796  /// @endcode
797  /// @return true if name was found and value is non-null, in which case the
798  /// HoudiniSetenv() was called, else false is returned.
799  static bool varChanged(const char *varname, const char *value);
800 
801  static void changeExistLookupDefault(UT_IntControl i, int new_def);
802 
803  /// Set all additional .env files to be parsed for env variable values.
804  /// It is best to call getAdditionalEnvironmentFiles() first and then
805  /// append to the list because this function will overwrite all the
806  /// additional paths that were previously set.
807  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
808  /// overwrites, knowing that these files get applied AFTER the default
809  /// houdini.env file in the user's home directory.
810  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
811  /// If additional files are set, they will be used, regardless of the
812  /// value of HOUDINI_NO_ENV_FILE.
813  static void setAdditionalEnvironmentFiles(
814  const UT_StringArray &files);
815 
816  /// Return the current list of additional environment files.
817  static const UT_StringArray&
818  getAdditionalEnvironmentFiles();
819 
820  // Print messages collected during init phase to console
821  static void logMessages()
822  {
823  getControl().logMessagesToConsole();
824  }
825 
826  // Package loader management
827  // Load the pakages located in the folders specified by pkg_paths.
828  // Use this method for loading package dynamically
829  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
830  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
831 
832  // Returns the main package loader, this loader contains all
833  // packages loaded at runtime.
834  static UT_Package::Loader& packageLoader();
835 
836 private:
837  void doInit(bool init_defaults);
838  void setDefaults();
839  bool loadEnvironmentFile(const char *path,
840  bool allow_overrides);
841  void loadDefaultEnvironmentFile();
842  void loadEnvironmentFiles();
843  void loadEnvironment(bool init_defaults);
844 
845  void updateExistLookup(int i, const char *value = nullptr);
846  void updateIntLookup(int i, const char *value = nullptr);
847  void updateFltLookup(int i, const char *value = nullptr);
848  void updateStrLookup(int i, bool fix_path,
849  const char *value = nullptr);
850 
851  void updateVarTables(UT_Package::Loader const& pkg_loader);
852 
853  void loadPackageConfig();
854  void logMessagesToConsole() const;
855 
856  int myIValues[MAX_CONTROLS_WITH_BUFFER];
857  float myFValues[MAX_CONTROLS_WITH_BUFFER];
858  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
859 
860  static UT_EnvControl &getControl()
861  {
862  if (!theControl)
863  {
864  theControl = new UT_EnvControl();
865  theControl->init();
866 
867  }
868  return *theControl;
869  }
870  static UT_EnvControl *theControl;
871 
872  static UT_StringArray theAdditionalEnvironmentFiles;
873  UT_String myLogMessages;
874 };
875 
876 #endif
static void varChanged(const char *varname)
static const char * getString(UT_StrControl i)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
#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
GLsizei const GLfloat * value
Definition: glcorearb.h:823
SYS_STATIC_ASSERT(ENV_MAX_INT_CONTROLS+50< MAX_CONTROLS_WITH_BUFFER)
UT_FltControl
#define MAX_CONTROLS_WITH_BUFFER
Definition: UT_EnvControl.h:40
UT_IntControl
Definition: UT_EnvControl.h:42