ccutil/varable.h

Go to the documentation of this file.
00001 
00020 #ifndef           VARABLE_H
00021 #define           VARABLE_H
00022 
00023 #include          <stdio.h>
00024 #include          "clst.h"
00025 #include          "strngs.h"
00026 
00027 class DLLSYM INT_VARIABLE;
00028 
00029                                  //read the file
00030 extern DLLSYM BOOL8 read_variables_file(const char *file  //name to read
00031                                        );
00032                                  //print all vars
00033 extern DLLSYM void print_variables(FILE *fp  //file to print on
00034                                   );
00035 
00036 CLISTIZEH (INT_VARIABLE)
00037 
00038 
00042 class DLLSYM INT_VAR_FROM
00043 {
00044   friend class INT_VAR_TO;
00045   public:
00046     INT_VAR_FROM();  //constructor
00047   private:
00048     INT_VARIABLE_CLIST list;     //copy of list
00049 };
00050 
00055 class DLLSYM INT_VAR_TO
00056 {
00057   public:
00058     INT_VAR_TO();  //constructor
00059   private:
00060     INT_VARIABLE_CLIST dummy;
00061 };
00062 
00067 class DLLSYM INT_VARIABLE
00068 {
00069   friend class INT_VAR_TO;
00070   friend class INT_VAR_FROM;
00071                                  //for setting values
00072   friend DLLSYM BOOL8 read_variables_file(const char *file);  //file to read
00073 
00074   public:
00075     INT_VARIABLE(                       //constructor
00076                  INT32 v,               //initial value
00077                  const char *vname,     //name of variable
00078                  const char *comment);  //info on variable
00079 
00080     INT_VARIABLE() {  //for elist only
00081       value = 0;
00082       name = "NONAME";
00083       info = "Uninitialized";
00084     }
00085     ~INT_VARIABLE ();            //for elist only
00086 
00087     operator INT32() {  //conversion
00088       return value;              //access as int
00089     }
00090 
00091     void set_value(            //assign to value
00092                    INT32 v) {  //value to set
00093       value = v;
00094     }
00095 
00096     const char *name_str() {  //access name
00097       return name;
00098     }
00099 
00100     const char *info_str() {  //access name
00101       return info;
00102     }
00103 
00104                                  //access list head
00105     static INT_VARIABLE_CLIST *get_head(); 
00106 
00107     static void print(            //print whole list
00108                       FILE *fp);  //file to print on
00109 
00110   private:
00111     INT32 value;                 //the variable
00112     const char *name;            //name of variable
00113     const char *info;            //for menus
00114     static INT_VAR_FROM copy;    //pre constructor
00115                                  //start  of list
00116     static INT_VARIABLE_CLIST head;
00117     static INT_VAR_TO replace;   //post constructor
00118 };
00119 
00120 class DLLSYM BOOL_VARIABLE;
00121 
00122 CLISTIZEH (BOOL_VARIABLE)
00127 class DLLSYM BOOL_VAR_FROM
00128 {
00129   friend class BOOL_VAR_TO;
00130   public:
00131     BOOL_VAR_FROM();  //constructor
00132   private:
00133     BOOL_VARIABLE_CLIST list;    //copy of list
00134 };
00135 
00140 class DLLSYM BOOL_VAR_TO
00141 {
00142   public:
00143     BOOL_VAR_TO();  //constructor
00144   private:
00145     BOOL_VARIABLE_CLIST dummy;
00146 };
00147 
00152 class DLLSYM BOOL_VARIABLE
00153 {
00154   friend class BOOL_VAR_FROM;
00155   friend class BOOL_VAR_TO;
00156                                  //for setting values
00157   friend DLLSYM BOOL8 read_variables_file(const char *file);  //file to read
00158 
00159   public:
00160     BOOL_VARIABLE(                       //constructor
00161                   BOOL8 v,               //initial value
00162                   const char *vname,     //name of variable
00163                   const char *comment);  //info on variable
00164 
00165     BOOL_VARIABLE() {  //for elist only
00166       value = FALSE;
00167       name = "NONAME";
00168       info = "Uninitialized";
00169     }
00170     ~BOOL_VARIABLE ();           //for elist only
00171 
00172     operator BOOL8() {  //conversion
00173       return value;              //access as int
00174     }
00175 
00176     void set_value(            //assign to value
00177                    BOOL8 v) {  //value to set
00178       value = v;
00179     }
00180 
00181     const char *name_str() {  //access name
00182       return name;
00183     }
00184 
00185     const char *info_str() {  //access name
00186       return info;
00187     }
00188 
00189                                  //access list head
00190     static BOOL_VARIABLE_CLIST *get_head(); 
00191 
00192     static void print(            //print whole list
00193                       FILE *fp);  //file to print on
00194 
00195   private:
00196     BOOL8 value;                 //the variable
00197     const char *name;            //name of variable
00198     const char *info;            //for menus
00199     static BOOL_VAR_FROM copy;   //pre constructor
00200                                  //start  of list
00201     static BOOL_VARIABLE_CLIST head;
00202     static BOOL_VAR_TO replace;  //post constructor
00203 };
00204 
00205 class DLLSYM STRING_VARIABLE;
00206 
00207 CLISTIZEH (STRING_VARIABLE)
00212 class DLLSYM STRING_VAR_FROM
00213 {
00214   friend class STRING_VAR_TO;
00215   public:
00216     STRING_VAR_FROM();  //constructor
00217   private:
00218     STRING_VARIABLE_CLIST list;  //copy of list
00219 };
00220 
00225 class DLLSYM STRING_VAR_TO
00226 {
00227   public:
00228     STRING_VAR_TO();  //constructor
00229   private:
00230     STRING_VARIABLE_CLIST dummy;
00231 };
00232 
00237 class DLLSYM STRING_VARIABLE
00238 {
00239   friend class STRING_VAR_TO;
00240   friend class STRING_VAR_FROM;
00241                                  //for setting values
00242   friend DLLSYM BOOL8 read_variables_file(const char *file);  //file to read
00243 
00244   public:
00245     STRING_VARIABLE(                       //constructor
00246                     const char *v,         //initial value
00247                     const char *vname,     //name of variable
00248                     const char *comment);  //info on variable
00249 
00250     STRING_VARIABLE() {  //for elist only
00251       name = "NONAME";
00252       info = "Uninitialized";
00253     }
00254     ~STRING_VARIABLE ();         //for elist only
00255 
00256                                  //conversion
00257     operator const STRING &() { 
00258       return value;              //access as int
00259     }
00260 
00261     void set_value(             //assign to value
00262                    STRING v) {  //value to set
00263       value = v;
00264     }
00265 
00266     const char *string() const {  //get string
00267       return value.string ();
00268     }
00269 
00270     const char *name_str() {  //access name
00271       return name;
00272     }
00273 
00274     const char *info_str() {  //access name
00275       return info;
00276     }
00277 
00278                                  //access list head
00279     static STRING_VARIABLE_CLIST *get_head(); 
00280 
00281     static void print(            //print whole list
00282                       FILE *fp);  //file to print on
00283 
00284   private:
00285     STRING value;                //the variable
00286     const char *name;            //name of variable
00287     const char *info;            //for menus
00288     static STRING_VAR_FROM copy; //pre constructor
00289                                  //start  of list
00290     static STRING_VARIABLE_CLIST head;
00291     static STRING_VAR_TO replace;//post constructor
00292 };
00293 
00294 class DLLSYM double_VARIABLE;
00295 
00296 CLISTIZEH (double_VARIABLE)
00301 class DLLSYM double_VAR_FROM
00302 {
00303   friend class double_VAR_TO;
00304   public:
00305     double_VAR_FROM();  
00306   private:
00307     double_VARIABLE_CLIST list;  
00308 };
00309 
00314 class DLLSYM double_VAR_TO
00315 {
00316   public:
00317     double_VAR_TO();  
00318   private:
00319     double_VARIABLE_CLIST dummy;
00320 };
00321 
00326 class DLLSYM double_VARIABLE
00327 {
00328   friend class double_VAR_TO;
00329   friend class double_VAR_FROM;
00330                                  //for setting values
00331   friend DLLSYM BOOL8 read_variables_file(const char *file);  //file to read
00332 
00333   public:
00334     double_VARIABLE(                       //constructor
00335                     double v,              //initial value
00336                     const char *vname,     //name of variable
00337                     const char *comment);  //info on variable
00338 
00339     double_VARIABLE() {  //for elist only
00340       value = 0.0;
00341       name = "NONAME";
00342       info = "Uninitialized";
00343     }
00344     ~double_VARIABLE ();         //for elist only
00345 
00346     operator double() {  //conversion
00347       return value;              //access as int
00348     }
00349 
00350     void set_value(             //assign to value
00351                    double v) {  //value to set
00352       value = v;
00353     }
00354 
00355     const char *name_str() {  //access name
00356       return name;
00357     }
00358 
00359     const char *info_str() {  //access name
00360       return info;
00361     }
00362 
00363                                  //access list head
00364     static double_VARIABLE_CLIST *get_head(); 
00365 
00366     static void print(            //print whole list
00367                       FILE *fp);  //file to print on
00368 
00369   private:
00370     double value;                //the variable
00371     const char *name;            //name of variable
00372     const char *info;            //for menus
00373     static double_VAR_FROM copy; //pre constructor
00374                                  //start  of list
00375     static double_VARIABLE_CLIST head;
00376     static double_VAR_TO replace;//post constructor
00377 };
00378 
00379 /*
00380 NOTE ON DEFINING VARIABLES
00381 
00382 For our normal code, the ***_VAR and ***_EVAR macros for variable
00383 definitions are identical.  HOWEVER, for the code version to ship to NEVADA
00384 (or anywhere else where we want to hide the majority of variables) the
00385 **_VAR macros are changed so that the "#name" and "comment" parameters
00386 to the variable constructor are changed to empty strings.  This prevents the
00387 variable name or comment string appearing in the object code file (after it
00388 has gone through strip).
00389 
00390 Certain variables can remain EXPOSED and hence be used in config files given
00391 to UNLV. These are variable which have been declared with the ***_EVAR
00392 macros.
00393 */
00394 
00395 /* SECURE_NAMES is defined in senames.h when necessary */
00396 #ifdef SECURE_NAMES
00397 
00398 #define INT_VAR(name,val,comment)                  /*make INT_VARIABLE*/\
00399    INT_VARIABLE         name(val,"","")
00400 
00401 #define BOOL_VAR(name,val,comment)                 /*make BOOL_VARIABLE*/\
00402    BOOL_VARIABLE        name(val,"","")
00403 
00404 #define STRING_VAR(name,val,comment)            /*make STRING_VARIABLE*/\
00405    STRING_VARIABLE         name(val,"","")
00406 
00407 #define double_VAR(name,val,comment)            /*make double_VARIABLE*/\
00408    double_VARIABLE         name(val,"","")
00409 
00410 #else /* ================= SECURE_NAMES ============================ */
00411 
00412 #define INT_VAR(name,val,comment)                  /*make INT_VARIABLE*/\
00413    INT_VARIABLE         name(val,#name,comment)
00414 
00415 #define BOOL_VAR(name,val,comment)                 /*make BOOL_VARIABLE*/\
00416    BOOL_VARIABLE        name(val,#name,comment)
00417 
00418 #define STRING_VAR(name,val,comment)            /*make STRING_VARIABLE*/\
00419    STRING_VARIABLE         name(val,#name,comment)
00420 
00421 #define double_VAR(name,val,comment)            /*make double_VARIABLE*/\
00422    double_VARIABLE         name(val,#name,comment)
00423 #endif
00424 
00425 #define INT_VAR_H(name,val,comment)                /*declare one*/\
00426    INT_VARIABLE         name
00427 
00428 #define BOOL_VAR_H(name,val,comment)               /*declare one*/\
00429    BOOL_VARIABLE        name
00430 
00431 #define STRING_VAR_H(name,val,comment)             /*declare one*/\
00432    STRING_VARIABLE         name
00433 
00434 #define double_VAR_H(name,val,comment)             /*declare one*/\
00435    double_VARIABLE         name
00436 
00437 #define INT_EVAR(name,val,comment)                 /*make INT_VARIABLE*/\
00438    INT_VARIABLE         name(val,#name,comment)
00439 
00440 #define INT_EVAR_H(name,val,comment)               /*declare one*/\
00441    INT_VARIABLE         name
00442 
00443 #define BOOL_EVAR(name,val,comment)                /*make BOOL_VARIABLE*/\
00444    BOOL_VARIABLE        name(val,#name,comment)
00445 
00446 #define BOOL_EVAR_H(name,val,comment)              /*declare one*/\
00447    BOOL_VARIABLE        name
00448 
00449 #define STRING_EVAR(name,val,comment)           /*make STRING_VARIABLE*/\
00450    STRING_VARIABLE         name(val,#name,comment)
00451 
00452 #define STRING_EVAR_H(name,val,comment)               /*declare one*/\
00453    STRING_VARIABLE         name
00454 
00455 #define double_EVAR(name,val,comment)           /*make double_VARIABLE*/\
00456    double_VARIABLE         name(val,#name,comment)
00457 
00458 #define double_EVAR_H(name,val,comment)               /*declare one*/\
00459    double_VARIABLE         name
00460 #endif

Generated on Wed Feb 28 19:49:09 2007 for Tesseract by  doxygen 1.5.1