1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* This code licensed under the                                        */
4 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
5 /***********************************************************************/
6 
7 /*
8  * DXEnvironment is a class that sets up the environment for running DX.
9  * It provides the command line argument processing and sets appropriate
10  * environment variables used by the main dx code.
11  */
12 
13 	/* Because there is so much that can be done with environment variables and
14 	 * command line arguments with dx, I created a class that can subdivide
15 	 * needed arguments between UI and exec and setup any extra needed environment
16 	 * varaibles. The user can then use the class to retrieve either UI or
17 	 * exec command line options.
18 	 */
19 
20 #ifndef _TMAINUTIL_H_
21 #define _TMAINUTIL_H_
22 
23 #pragma unmanaged
24 
25 #include <windows.h>
26 #include <string>
27 using std::string;
28 
29 #define MAXPARMS 200
30 #define MAXENV  24576
31 
32 
33 int ShortHelp(); // Print out short help and exit
34 int LongHelp();  // Print out long help and exit
35 
36 
37 class __declspec(dllexport) DXEnvironment {
38 public:
39 	// Setup is the function that must be run first with main's argc, argv
40 	// startup. This will populate the structure.
41 	int Setup(const int, char **);
42 
43 	string getExFlags(); // return a single string of all flags listed
44 	string getUiFlags(); // together.
45 
isExecOnly()46 	bool isExecOnly() { return exonly; }
47 
48 	int getExArgs(char**&); // return argc and argv versions of args
49 	int getUiArgs(char**&); // return value is same as argc, does alloc
50 						   // char ** (must be freed)
51 
52 	// Default constructor for initialization.
DXEnvironment()53 	DXEnvironment() : dxroot(""), dxargs(""),
54 		dxdata(""), dxmacros(""), dxmodules(""),
55 		dxmdf(""), dxinclude(""), dxcolors(""),
56 		magickhome(""), curdir(""), exhost(""),
57 		cdto(""), exflags(NULL), exnumflags(0), uiflags(NULL),
58 		uinumflags(0), filename(""),
59 		port(""), numparams(0), exonly(false), uionly(false),
60 		showversion(false) {}
61 
62 	~DXEnvironment(); // Destructor to free memory.
63 
64 private:
65 	string dxroot;		// root of the dx app
66 	string dxargs;		// any args set as an env var
67 	string dxdata;		// path to the dxdata - set by both cl and env var
68 	string dxmacros;	// path to dxmacros - set by both cl and env var
69 	string dxmodules;	// path to dxmodules - set by env var
70 	string dxmdf;		// path to dxmdf - set by env var
71 	string dxinclude;	// path to dxinclude - set by env var
72 	string dxcolors;	// path to dxcolors - set by env var
73 	string magickhome;  // path to ImageMagick home - set by env var
74 	string curdir;		// call to getcwd
75 	string params[MAXPARMS]; // all the params
76 	string exhost;		// executive host - set on command line
77 	int numparams;		// total number of parameters in params.
78 	string cdto;		// directory where app should be run from.
79 	string uimode;		// what mode flags to send to the ui
80 	string *exflags;		// flags for executive.
81 	int exnumflags;		// number of exargs
82 	string *uiflags;		// flags specific to the ui
83 	int uinumflags;		// number of uiargs
84 	bool exonly;		// Run executive only;
85 	bool uionly;		// Run ui only;
86 	string filename;    // Filename of network to load/run
87 	bool showversion;	// Show version
88 	string port;		// Port to share socket over
89 
90 	void addExFlag(string);
91 	void addUiFlag(string);
92 
93 
94 };
95 
96 #pragma managed
97 
98 #endif /* _TMAINUTIL_H_ */