2007-03-08 04:03:40 +08:00
|
|
|
/**********************************************************************
|
|
|
|
* File: varable.h (Formerly variable.h)
|
|
|
|
* Description: Class definitions of the *_VAR classes for tunable constants.
|
2008-12-31 02:20:15 +08:00
|
|
|
* Author: Ray Smith
|
|
|
|
* Created: Fri Feb 22 11:26:25 GMT 1991
|
2007-03-08 04:03:40 +08:00
|
|
|
*
|
|
|
|
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef VARABLE_H
|
|
|
|
#define VARABLE_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-07-11 10:50:24 +08:00
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "clst.h"
|
|
|
|
#include "strngs.h"
|
|
|
|
|
|
|
|
class DLLSYM INT_VARIABLE;
|
|
|
|
|
2009-07-11 10:50:24 +08:00
|
|
|
// Read config file.
|
|
|
|
extern DLLSYM BOOL8 read_variables_file(
|
|
|
|
const char *file, // filename to read
|
|
|
|
bool global_only); // only set variables starting with "global_"
|
|
|
|
|
|
|
|
// Read variables from the given file pointer (stop at end_offset).
|
|
|
|
bool read_variables_from_fp(FILE *fp, inT64 end_offset, bool global_only);
|
|
|
|
|
|
|
|
// Set a variable to have the given value.
|
|
|
|
bool set_variable(const char *variable, const char* value);
|
|
|
|
|
|
|
|
// Print variables to a file.
|
|
|
|
extern DLLSYM void print_variables(FILE *fp);
|
|
|
|
|
|
|
|
const char kGlobalVariablePrefix[] = "global_";
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
CLISTIZEH (INT_VARIABLE)
|
|
|
|
class DLLSYM INT_VAR_FROM
|
|
|
|
{
|
|
|
|
friend class INT_VAR_TO;
|
|
|
|
public:
|
|
|
|
INT_VAR_FROM(); //constructor
|
|
|
|
private:
|
|
|
|
INT_VARIABLE_CLIST list; //copy of list
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM INT_VAR_TO
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
INT_VAR_TO(); //constructor
|
|
|
|
private:
|
|
|
|
INT_VARIABLE_CLIST dummy;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM INT_VARIABLE
|
|
|
|
{
|
|
|
|
friend class INT_VAR_TO;
|
|
|
|
friend class INT_VAR_FROM;
|
|
|
|
//for setting values
|
2009-07-11 10:50:24 +08:00
|
|
|
friend bool set_variable(const char *variable, const char* value);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
public:
|
2008-04-22 08:23:41 +08:00
|
|
|
INT_VARIABLE(inT32 v, // initial value
|
2008-02-01 08:18:33 +08:00
|
|
|
const char *vname, // name of variable
|
|
|
|
const char *comment); // info on variable
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
INT_VARIABLE() { // for elist only
|
2007-03-08 04:03:40 +08:00
|
|
|
value = 0;
|
|
|
|
name = "NONAME";
|
|
|
|
info = "Uninitialized";
|
|
|
|
}
|
2008-02-01 08:18:33 +08:00
|
|
|
~INT_VARIABLE(); // for elist only
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-04-22 08:23:41 +08:00
|
|
|
operator inT32() { // conversion
|
2008-02-01 08:18:33 +08:00
|
|
|
return value; // access as int
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
2008-04-22 08:23:41 +08:00
|
|
|
void set_value(inT32 v) { // value to set
|
2007-03-08 04:03:40 +08:00
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
const char *name_str() { // access name
|
2007-03-08 04:03:40 +08:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
const char *info_str() { // access name
|
2007-03-08 04:03:40 +08:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
// access list head
|
|
|
|
static INT_VARIABLE_CLIST *get_head();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
static void print(FILE *fp); // file to print on
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
private:
|
2008-04-22 08:23:41 +08:00
|
|
|
inT32 value; // the variable
|
2008-02-01 08:18:33 +08:00
|
|
|
const char *name; // name of variable
|
|
|
|
const char *info; // for menus
|
|
|
|
static INT_VAR_FROM copy; // pre constructor
|
|
|
|
// start of list
|
2007-03-08 04:03:40 +08:00
|
|
|
static INT_VARIABLE_CLIST head;
|
2008-02-01 08:18:33 +08:00
|
|
|
static INT_VAR_TO replace; // post constructor
|
2007-03-08 04:03:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM BOOL_VARIABLE;
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
CLISTIZEH(BOOL_VARIABLE)
|
|
|
|
class DLLSYM BOOL_VAR_FROM {
|
2007-03-08 04:03:40 +08:00
|
|
|
friend class BOOL_VAR_TO;
|
|
|
|
public:
|
2008-02-01 08:18:33 +08:00
|
|
|
BOOL_VAR_FROM(); // constructor
|
2007-03-08 04:03:40 +08:00
|
|
|
private:
|
2008-02-01 08:18:33 +08:00
|
|
|
BOOL_VARIABLE_CLIST list; // copy of list
|
2007-03-08 04:03:40 +08:00
|
|
|
};
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
class DLLSYM BOOL_VAR_TO {
|
2007-03-08 04:03:40 +08:00
|
|
|
public:
|
2008-02-01 08:18:33 +08:00
|
|
|
BOOL_VAR_TO(); // constructor
|
2007-03-08 04:03:40 +08:00
|
|
|
private:
|
|
|
|
BOOL_VARIABLE_CLIST dummy;
|
|
|
|
};
|
|
|
|
|
2008-02-01 08:18:33 +08:00
|
|
|
class DLLSYM BOOL_VARIABLE {
|
2007-03-08 04:03:40 +08:00
|
|
|
friend class BOOL_VAR_FROM;
|
|
|
|
friend class BOOL_VAR_TO;
|
|
|
|
//for setting values
|
2009-07-11 10:50:24 +08:00
|
|
|
friend bool set_variable(const char *variable, const char* value);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
BOOL_VARIABLE( //constructor
|
|
|
|
BOOL8 v, //initial value
|
|
|
|
const char *vname, //name of variable
|
|
|
|
const char *comment); //info on variable
|
|
|
|
|
|
|
|
BOOL_VARIABLE() { //for elist only
|
|
|
|
value = FALSE;
|
|
|
|
name = "NONAME";
|
|
|
|
info = "Uninitialized";
|
|
|
|
}
|
|
|
|
~BOOL_VARIABLE (); //for elist only
|
|
|
|
|
|
|
|
operator BOOL8() { //conversion
|
|
|
|
return value; //access as int
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value( //assign to value
|
|
|
|
BOOL8 v) { //value to set
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name_str() { //access name
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *info_str() { //access name
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
//access list head
|
2008-02-01 08:18:33 +08:00
|
|
|
static BOOL_VARIABLE_CLIST *get_head();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
static void print( //print whole list
|
|
|
|
FILE *fp); //file to print on
|
|
|
|
|
|
|
|
private:
|
|
|
|
BOOL8 value; //the variable
|
|
|
|
const char *name; //name of variable
|
|
|
|
const char *info; //for menus
|
|
|
|
static BOOL_VAR_FROM copy; //pre constructor
|
|
|
|
//start of list
|
|
|
|
static BOOL_VARIABLE_CLIST head;
|
|
|
|
static BOOL_VAR_TO replace; //post constructor
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM STRING_VARIABLE;
|
|
|
|
|
|
|
|
CLISTIZEH (STRING_VARIABLE)
|
|
|
|
class DLLSYM STRING_VAR_FROM
|
|
|
|
{
|
|
|
|
friend class STRING_VAR_TO;
|
|
|
|
public:
|
|
|
|
STRING_VAR_FROM(); //constructor
|
|
|
|
private:
|
|
|
|
STRING_VARIABLE_CLIST list; //copy of list
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM STRING_VAR_TO
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
STRING_VAR_TO(); //constructor
|
|
|
|
private:
|
|
|
|
STRING_VARIABLE_CLIST dummy;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM STRING_VARIABLE
|
|
|
|
{
|
|
|
|
friend class STRING_VAR_TO;
|
|
|
|
friend class STRING_VAR_FROM;
|
|
|
|
//for setting values
|
2009-07-11 10:50:24 +08:00
|
|
|
friend bool set_variable(const char *variable, const char* value);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
STRING_VARIABLE( //constructor
|
|
|
|
const char *v, //initial value
|
|
|
|
const char *vname, //name of variable
|
|
|
|
const char *comment); //info on variable
|
|
|
|
|
|
|
|
STRING_VARIABLE() { //for elist only
|
|
|
|
name = "NONAME";
|
|
|
|
info = "Uninitialized";
|
|
|
|
}
|
|
|
|
~STRING_VARIABLE (); //for elist only
|
|
|
|
|
|
|
|
//conversion
|
2008-02-01 08:18:33 +08:00
|
|
|
operator const STRING &() {
|
2007-03-08 04:03:40 +08:00
|
|
|
return value; //access as int
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value( //assign to value
|
|
|
|
STRING v) { //value to set
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *string() const { //get string
|
|
|
|
return value.string ();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name_str() { //access name
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *info_str() { //access name
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
//access list head
|
2008-02-01 08:18:33 +08:00
|
|
|
static STRING_VARIABLE_CLIST *get_head();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
static void print( //print whole list
|
|
|
|
FILE *fp); //file to print on
|
|
|
|
|
|
|
|
private:
|
|
|
|
STRING value; //the variable
|
|
|
|
const char *name; //name of variable
|
|
|
|
const char *info; //for menus
|
|
|
|
static STRING_VAR_FROM copy; //pre constructor
|
|
|
|
//start of list
|
|
|
|
static STRING_VARIABLE_CLIST head;
|
|
|
|
static STRING_VAR_TO replace;//post constructor
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM double_VARIABLE;
|
|
|
|
|
|
|
|
CLISTIZEH (double_VARIABLE)
|
|
|
|
class DLLSYM double_VAR_FROM
|
|
|
|
{
|
|
|
|
friend class double_VAR_TO;
|
|
|
|
public:
|
|
|
|
double_VAR_FROM(); //constructor
|
|
|
|
private:
|
|
|
|
double_VARIABLE_CLIST list; //copy of list
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM double_VAR_TO
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
double_VAR_TO(); //constructor
|
|
|
|
private:
|
|
|
|
double_VARIABLE_CLIST dummy;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLLSYM double_VARIABLE
|
|
|
|
{
|
|
|
|
friend class double_VAR_TO;
|
|
|
|
friend class double_VAR_FROM;
|
|
|
|
//for setting values
|
2009-07-11 10:50:24 +08:00
|
|
|
friend bool set_variable(const char *variable, const char* value);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
double_VARIABLE( //constructor
|
|
|
|
double v, //initial value
|
|
|
|
const char *vname, //name of variable
|
|
|
|
const char *comment); //info on variable
|
|
|
|
|
|
|
|
double_VARIABLE() { //for elist only
|
|
|
|
value = 0.0;
|
|
|
|
name = "NONAME";
|
|
|
|
info = "Uninitialized";
|
|
|
|
}
|
|
|
|
~double_VARIABLE (); //for elist only
|
|
|
|
|
|
|
|
operator double() { //conversion
|
|
|
|
return value; //access as int
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value( //assign to value
|
|
|
|
double v) { //value to set
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name_str() { //access name
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *info_str() { //access name
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
//access list head
|
2008-02-01 08:18:33 +08:00
|
|
|
static double_VARIABLE_CLIST *get_head();
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
static void print( //print whole list
|
|
|
|
FILE *fp); //file to print on
|
|
|
|
|
|
|
|
private:
|
|
|
|
double value; //the variable
|
|
|
|
const char *name; //name of variable
|
|
|
|
const char *info; //for menus
|
|
|
|
static double_VAR_FROM copy; //pre constructor
|
|
|
|
//start of list
|
|
|
|
static double_VARIABLE_CLIST head;
|
|
|
|
static double_VAR_TO replace;//post constructor
|
|
|
|
};
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* NOTE ON DEFINING VARIABLES
|
|
|
|
*
|
|
|
|
* For our normal code, the ***_VAR and ***_EVAR macros for variable
|
|
|
|
* definitions are identical. HOWEVER, for the code version to ship to NEVADA
|
|
|
|
* (or anywhere else where we want to hide the majority of variables) the
|
|
|
|
* **_VAR macros are changed so that the "#name" and "comment" parameters
|
|
|
|
* to the variable constructor are changed to empty strings. This prevents the
|
|
|
|
* variable name or comment string appearing in the object code file (after it
|
|
|
|
* has gone through strip).
|
|
|
|
*
|
|
|
|
* Certain variables can remain EXPOSED and hence be used in config files given
|
|
|
|
* to UNLV. These are variable which have been declared with the ***_EVAR
|
|
|
|
* macros.
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/* SECURE_NAMES is defined in senames.h when necessary */
|
|
|
|
#ifdef SECURE_NAMES
|
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_VAR(name,val,comment) /*make INT_VARIABLE*/\
|
|
|
|
INT_VARIABLE name(val,"","")
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_VAR(name,val,comment) /*make BOOL_VARIABLE*/\
|
|
|
|
BOOL_VARIABLE name(val,"","")
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define STRING_VAR(name,val,comment) /*make STRING_VARIABLE*/\
|
|
|
|
STRING_VARIABLE name(val,"","")
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define double_VAR(name,val,comment) /*make double_VARIABLE*/\
|
|
|
|
double_VARIABLE name(val,"","")
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_VAR(name,val,comment) /*make INT_VARIABLE*/\
|
|
|
|
INT_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_VAR(name,val,comment) /*make BOOL_VARIABLE*/\
|
|
|
|
BOOL_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define STRING_VAR(name,val,comment) /*make STRING_VARIABLE*/\
|
|
|
|
STRING_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define double_VAR(name,val,comment) /*make double_VARIABLE*/\
|
|
|
|
double_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_VAR_H(name,val,comment) /*declare one*/\
|
|
|
|
INT_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_VAR_H(name,val,comment) /*declare one*/\
|
|
|
|
BOOL_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define STRING_VAR_H(name,val,comment) /*declare one*/\
|
|
|
|
STRING_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define double_VAR_H(name,val,comment) /*declare one*/\
|
|
|
|
double_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_MEMBER(name, val, comment) /*make INT_VARIABLE*/\
|
|
|
|
name(val, #name, comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_MEMBER(name, val, comment) /*make BOOL_VARIABLE*/\
|
|
|
|
name(val, #name, comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define STRING_MEMBER(name, val, comment) /*make STRING_VARIABLE*/\
|
|
|
|
name(val, #name, comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define double_MEMBER(name, val, comment) /*make double_VARIABLE*/\
|
|
|
|
name(val, #name, comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_EVAR(name,val,comment) /*make INT_VARIABLE*/\
|
|
|
|
INT_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define INT_EVAR_H(name,val,comment) /*declare one*/\
|
|
|
|
INT_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_EVAR(name,val,comment) /*make BOOL_VARIABLE*/\
|
|
|
|
BOOL_VARIABLE name(val,#name,comment)
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2008-12-31 02:20:15 +08:00
|
|
|
#define BOOL_EVAR_H(name,val,comment) /*declare one*/\
|
|
|
|
BOOL_VARIABLE name
|
|
|
|
|
|
|
|
#define STRING_EVAR(name,val,comment) /*make STRING_VARIABLE*/\
|
|
|
|
STRING_VARIABLE name(val,#name,comment)
|
|
|
|
|
|
|
|
#define STRING_EVAR_H(name,val,comment) /*declare one*/\
|
|
|
|
STRING_VARIABLE name
|
|
|
|
|
|
|
|
#define double_EVAR(name,val,comment) /*make double_VARIABLE*/\
|
|
|
|
double_VARIABLE name(val,#name,comment)
|
|
|
|
|
|
|
|
#define double_EVAR_H(name,val,comment) /*declare one*/\
|
|
|
|
double_VARIABLE name
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|