ParseOptions.C File Reference

#include <stdlib.h>
#include <string.h>
#include "ParseOptions.h"
#include "ConfigList.h"
#include "InfoStream.h"
#include "strlib.h"
#include <tcl.h>

Go to the source code of this file.

Defines

#define dataelement_cons_macro_default(Mtype, MType, Mptr, Mdef)
#define dataelement_cons_macro(Mtype, MType, Mptr)
#define parse_input_macro_default(fctnname, type, optional)
 routines to add dependencies to the array
#define parse_input_macro(fctnname, type, optional)
#define parse_input_macro_default_b(fctnname, type, optional, extra)
#define parse_input_macro_b(fctnname, type, optional, extra)
#define parse_stringlist_macro(fctn, xxx)
#define set_macro(type, field, fieldptr)
#define simple_set_macro(type, field, fieldptr)
#define PRINT_DOUBLE(BUF, VAL)   Tcl_PrintDouble(0,VAL,BUF)

Functions

const char * rstring (Range r)
const char * ustring (Units u)
static Units next (Units u)
BigReal convert (Units to, Units from)
static char * Strdup (const char *newname)
 dataelement_cons_macro_default (BigReal, FLOAT, fptr, fdef)
 dataelement_cons_macro_default (int, INT, iptr, idef)
 dataelement_cons_macro_default (unsigned int, UINT, uiptr, uidef)
 dataelement_cons_macro_default (Vector, VECTOR, vptr, vdef)
 dataelement_cons_macro (BigReal, FLOAT, fptr)
 dataelement_cons_macro (Vector, VECTOR, vptr)
 dataelement_cons_macro (int, INT, iptr)
 dataelement_cons_macro (unsigned int, UINT, uiptr)
 dataelement_cons_macro (char, STRING, sptr)
 parse_input_macro (require, BigReal, FALSE)
 parse_input_macro (require, Vector, FALSE)
 parse_input_macro (require, int, FALSE)
 parse_input_macro (require, unsigned int, FALSE)
 parse_input_macro_b (requireB, int, FALSE, tmp->type=DataElement::BOOL)
 parse_input_macro (require, char, FALSE)
 parse_input_macro (optional, BigReal, TRUE)
 parse_input_macro (optional, Vector, TRUE)
 parse_input_macro (optional, int, TRUE)
 parse_input_macro (optional, unsigned int, TRUE)
 parse_input_macro_b (optionalB, int, TRUE, tmp->type=DataElement::BOOL)
 parse_input_macro (optional, char, TRUE)
 parse_input_macro_default (require, BigReal, FALSE)
 parse_input_macro_default (require, Vector, FALSE)
 parse_input_macro_default (require, int, FALSE)
 parse_input_macro_default (require, unsigned int, FALSE)
 parse_input_macro_default_b (requireB, int, FALSE, tmp->type=DataElement::BOOL)
 parse_input_macro_default (optional, BigReal, TRUE)
 parse_input_macro_default (optional, Vector, TRUE)
 parse_input_macro_default (optional, int, TRUE)
 parse_input_macro_default (optional, unsigned int, TRUE)
 parse_input_macro_default_b (optionalB, int, TRUE, tmp->type=DataElement::BOOL)
 parse_stringlist_macro (require, FALSE)
 parse_stringlist_macro (optional, TRUE)
 set_macro (float, fdata, fptr)
 set_macro (int, idata, iptr)
 set_macro (uint, uidata, uiptr)
 simple_set_macro (bool, idata, iptr)
 simple_set_macro (vector, vdata, vptr)
 simple_set_macro (stringlist, sldata, slptr)
static void PRINT_VECTOR (char *buf, Vector val)

Variables

static const char * unit_string_array [N_UNITS_UNDEFINED+1]
static BigReal scaling_factors [N_UNITS_UNDEFINED+1]


Define Documentation

#define dataelement_cons_macro ( Mtype,
MType,
Mptr   ) 

Value:

ParseOptions::DataElement::DataElement(const char *newname,      \
     const char *newparent, int optional, const char *err,       \
     Mtype *ptr)                                                 \
{                                                                \
   init(newname, newparent, optional, err);                      \
   type = MType;                                                 \
   Mptr = ptr;                                                   \
}

Definition at line 153 of file ParseOptions.C.

#define dataelement_cons_macro_default ( Mtype,
MType,
Mptr,
Mdef   ) 

Value:

ParseOptions::DataElement::DataElement(const char *newname,      \
     const char *newparent, int optional, const char *err,       \
     Mtype *ptr, Mtype defalt)                                   \
{                                                                \
   init(newname, newparent, optional, err);                      \
   type = MType;                                                 \
   Mptr = ptr;                                                   \
   Mdef = defalt;                                                \
   has_default = TRUE;                                           \
   if ( ptr ) *ptr = defalt;                                     \
}

Definition at line 140 of file ParseOptions.C.

#define parse_input_macro ( fctnname,
type,
optional   ) 

Value:

int ParseOptions::fctnname(const char *parent, const char *newname,   \
                          const char *msg, type *ptr)                 \
{                                                                     \
   DataElement *tmp = new DataElement(newname, parent, optional, msg, \
                                      ptr);                           \
   if (!make_dependencies(tmp)) {                                     \
      iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
      return FALSE;                                                   \
   }                                                                  \
   add_element(tmp);                                                  \
   return TRUE;                                                       \
}

Definition at line 284 of file ParseOptions.C.

#define parse_input_macro_b ( fctnname,
type,
optional,
extra   ) 

Value:

int ParseOptions::fctnname(const char *parent, const char *newname,   \
                          const char *msg, type *ptr)                 \
{                                                                     \
   DataElement *tmp = new DataElement(newname, parent, optional, msg, \
                                      ptr);                           \
   if (!make_dependencies(tmp)) {                                     \
      iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
      return FALSE;                                                   \
   }                                                                  \
   add_element(tmp);                                                  \
   extra;                                                             \
   return TRUE;                                                       \
}

Definition at line 311 of file ParseOptions.C.

#define parse_input_macro_default ( fctnname,
type,
optional   ) 

Value:

int ParseOptions::fctnname(const char *parent, const char *newname,   \
                          const char *msg, type *ptr, type defalt)    \
{                                                                     \
   DataElement *tmp = new DataElement(newname, parent, optional, msg, \
                                      ptr, defalt);                   \
   if (!make_dependencies(tmp)) {                                     \
      iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
      return FALSE;                                                   \
   }                                                                  \
   add_element(tmp);                                                  \
   return TRUE;                                                       \
}
routines to add dependencies to the array

Definition at line 271 of file ParseOptions.C.

#define parse_input_macro_default_b ( fctnname,
type,
optional,
extra   ) 

Value:

int ParseOptions::fctnname(const char *parent, const char *newname,   \
                          const char *msg, type *ptr, type defalt)    \
{                                                                     \
   DataElement *tmp = new DataElement(newname, parent, optional, msg, \
                                      ptr, defalt);                   \
   if (!make_dependencies(tmp)) {                                     \
      iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
      return FALSE;                                                   \
   }                                                                  \
   add_element(tmp);                                                  \
   extra;                                                             \
   return TRUE;                                                       \
}

Definition at line 297 of file ParseOptions.C.

#define parse_stringlist_macro ( fctn,
xxx   ) 

Value:

int ParseOptions::fctn(const char *parent, const char *newname, \
                          const char *msg, StringList **ptr, int many_allowed)\
{                                                                            \
   DataElement *tmp = new DataElement(newname, parent, xxx, msg,             \
                                      ptr, many_allowed);                    \
   if (!make_dependencies(tmp)) {                                            \
      iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi;\
      return FALSE;                                                          \
   }                                                                         \
   add_element(tmp);                                                         \
   return TRUE;                                                              \
}

Definition at line 352 of file ParseOptions.C.

#define PRINT_DOUBLE ( BUF,
VAL   )     Tcl_PrintDouble(0,VAL,BUF)

Definition at line 925 of file ParseOptions.C.

Referenced by ParseOptions::getfromptr(), and PRINT_VECTOR().

#define set_macro ( type,
field,
fieldptr   ) 

Value:

int ParseOptions::set_##type(DataElement *el)            \
{                                                        \
   if (el->range == FREE_RANGE ||                        \
       (el->range == POSITIVE && el->field > 0) ||       \
       (el->range == NOT_NEGATIVE && el->field >= 0) ||  \
       (el->range == NEGATIVE && el->field < 0) ||       \
       (el->range == NOT_POSITIVE && el->field <= 0)) {  \
      if (el->fieldptr) *(el->fieldptr) = el->field;     \
      return 1;                                          \
   }                                                     \
   iout << iERROR << "'" << el->name << "' was set to " << el->field << " but it " \
           << "should be " << rstring(el->range)          \
           << "\n" << endi;      \
   return 0;                \
}

Definition at line 603 of file ParseOptions.C.

#define simple_set_macro ( type,
field,
fieldptr   ) 

Value:

void ParseOptions::set_##type(DataElement *el)     \
{                                                   \
   if (el->fieldptr) *(el->fieldptr) = el->field;    \
}

Definition at line 624 of file ParseOptions.C.


Function Documentation

BigReal convert ( Units  to,
Units  from 
)

Definition at line 89 of file ParseOptions.C.

References N_ANGSTROM, N_EV, N_FSEC, N_HOUR, N_KCAL, N_KELVIN, N_KJOULE, N_METER, N_MIN, N_NANOMETER, N_NSEC, N_SEC, and N_UNIT.

00090 {
00091 // cout << "Converting from " << string(from) << " to " << string(to) << std::endl;
00092 // cout << scaling_factors[from] << " <--> " << scaling_factors[to] << std::endl;
00093    if (from == N_UNIT && to == N_UNIT) { return 1.0; }
00094    if ((from == N_NSEC || from == N_FSEC || from == N_SEC || from == N_MIN || 
00095         from == N_HOUR) &&
00096        (to   == N_NSEC || to   == N_FSEC || to   == N_SEC || to   == N_MIN || 
00097         to   == N_HOUR)) {
00098       return scaling_factors[from]/scaling_factors[to];
00099    }
00100    if ((from == N_METER || from == N_NANOMETER || from == N_ANGSTROM) &&
00101        (to   == N_METER || to   == N_NANOMETER || to   == N_ANGSTROM)) {
00102       return scaling_factors[from]/scaling_factors[to];
00103    }
00104    if ((from == N_KCAL || from == N_KJOULE || from == N_EV) &&
00105        (to   == N_KCAL || to   == N_KJOULE || to   == N_EV)) {
00106       return scaling_factors[from]/scaling_factors[to];
00107    }
00108    if (from == N_KELVIN && to == N_KELVIN) {
00109       return scaling_factors[from]/scaling_factors[to];
00110    }
00111    return 0.0;
00112 }

dataelement_cons_macro ( char  ,
STRING  ,
sptr   
)

dataelement_cons_macro ( unsigned  int,
UINT  ,
uiptr   
)

dataelement_cons_macro ( int  ,
INT  ,
iptr   
)

dataelement_cons_macro ( Vector  ,
VECTOR  ,
vptr   
)

dataelement_cons_macro ( BigReal  ,
FLOAT  ,
fptr   
)

dataelement_cons_macro_default ( Vector  ,
VECTOR  ,
vptr  ,
vdef   
)

dataelement_cons_macro_default ( unsigned  int,
UINT  ,
uiptr  ,
uidef   
)

dataelement_cons_macro_default ( int  ,
INT  ,
iptr  ,
idef   
)

dataelement_cons_macro_default ( BigReal  ,
FLOAT  ,
fptr  ,
fdef   
)

static Units next ( Units  u  )  [static]

Definition at line 48 of file ParseOptions.C.

References N_ANGSTROM, N_EV, N_FSEC, N_HOUR, N_KCAL, N_KELVIN, N_KJOULE, N_METER, N_MIN, N_NANOMETER, N_NSEC, N_SEC, N_UNIT, and N_UNITS_UNDEFINED.

Referenced by ConfigList::add_element(), bin_evaluation_1away(), PDB::PDB(), Rebalancer::refine(), spatial_hashing(), ConfigList::~ConfigList(), and ReductionSet::~ReductionSet().

00048                            {
00049   switch (u) {
00050    case N_UNIT: return N_FSEC;
00051    case N_FSEC: return N_NSEC;
00052    case N_NSEC: return N_SEC;
00053    case N_SEC: return N_MIN;
00054    case N_MIN: return N_HOUR;
00055    case N_HOUR:  return N_ANGSTROM;
00056    case N_ANGSTROM: return N_NANOMETER;
00057    case N_NANOMETER: return N_METER;
00058    case N_METER: return N_KCAL;
00059    case N_KCAL: return N_KJOULE;
00060    case N_KJOULE: return N_EV;
00061    case N_EV: return N_KELVIN;
00062    case N_KELVIN: return N_UNITS_UNDEFINED;
00063    default: return N_UNITS_UNDEFINED;
00064   }
00065 }

parse_input_macro ( optional  ,
char  ,
TRUE   
)

parse_input_macro ( optional  ,
unsigned  int,
TRUE   
)

parse_input_macro ( optional  ,
int  ,
TRUE   
)

parse_input_macro ( optional  ,
Vector  ,
TRUE   
)

parse_input_macro ( optional  ,
BigReal  ,
TRUE   
)

parse_input_macro ( require  ,
char  ,
FALSE   
)

parse_input_macro ( require  ,
unsigned  int,
FALSE   
)

parse_input_macro ( require  ,
int  ,
FALSE   
)

parse_input_macro ( require  ,
Vector  ,
FALSE   
)

parse_input_macro ( require  ,
BigReal  ,
FALSE   
)

parse_input_macro_b ( optionalB  ,
int  ,
TRUE  ,
tmp->  type = DataElement::BOOL 
)

parse_input_macro_b ( requireB  ,
int  ,
FALSE  ,
tmp->  type = DataElement::BOOL 
)

parse_input_macro_default ( optional  ,
unsigned  int,
TRUE   
)

parse_input_macro_default ( optional  ,
int  ,
TRUE   
)

parse_input_macro_default ( optional  ,
Vector  ,
TRUE   
)

parse_input_macro_default ( optional  ,
BigReal  ,
TRUE   
)

parse_input_macro_default ( require  ,
unsigned  int,
FALSE   
)

parse_input_macro_default ( require  ,
int  ,
FALSE   
)

parse_input_macro_default ( require  ,
Vector  ,
FALSE   
)

parse_input_macro_default ( require  ,
BigReal  ,
FALSE   
)

parse_input_macro_default_b ( optionalB  ,
int  ,
TRUE  ,
tmp->  type = DataElement::BOOL 
)

parse_input_macro_default_b ( requireB  ,
int  ,
FALSE  ,
tmp->  type = DataElement::BOOL 
)

parse_stringlist_macro ( optional  ,
TRUE   
)

parse_stringlist_macro ( require  ,
FALSE   
)

static void PRINT_VECTOR ( char *  buf,
Vector  val 
) [static]

Definition at line 927 of file ParseOptions.C.

References PRINT_DOUBLE, Vector::x, Vector::y, and Vector::z.

Referenced by ParseOptions::getfromptr().

00927                                                 {
00928   PRINT_DOUBLE(buf, val.x);
00929   buf += strlen(buf); buf[0] = ' '; ++buf;
00930   PRINT_DOUBLE(buf, val.y);
00931   buf += strlen(buf); buf[0] = ' '; ++buf;
00932   PRINT_DOUBLE(buf, val.z);
00933   buf += strlen(buf); buf[0] = ' '; buf[1] = 0;
00934 }

const char* rstring ( Range  r  ) 

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 25 of file ParseOptions.C.

References FREE_RANGE, NEGATIVE, NOT_NEGATIVE, NOT_POSITIVE, and POSITIVE.

00026 {
00027    switch (r) {
00028     case FREE_RANGE: return "unconstrained";
00029     case POSITIVE: return "positive";
00030     case NOT_NEGATIVE: return "non-negative";
00031     case NEGATIVE: return "negative";
00032     case NOT_POSITIVE: return "non-positive";
00033     default: return "error in rstring(Range )";
00034    }
00035 }

set_macro ( uint  ,
uidata  ,
uiptr   
)

set_macro ( int  ,
idata  ,
iptr   
)

set_macro ( float  ,
fdata  ,
fptr   
)

simple_set_macro ( stringlist  ,
sldata  ,
slptr   
)

simple_set_macro ( vector  ,
vdata  ,
vptr   
)

simple_set_macro ( bool  ,
idata  ,
iptr   
)

static char* Strdup ( const char *  newname  )  [static]

Definition at line 114 of file ParseOptions.C.

00115 {
00116   char *tmp = new char[strlen(newname)+1];
00117   strcpy(tmp, newname);
00118   return tmp;
00119 }

const char* ustring ( Units  u  ) 

Definition at line 42 of file ParseOptions.C.

References unit_string_array.

Referenced by ParseOptions::units().

00043 {
00044    return unit_string_array[u];
00045 }


Variable Documentation

BigReal scaling_factors[N_UNITS_UNDEFINED+1] [static]

Initial value:

 {
   1, 1, 1000, 1E15, 60E15, 3600E15, 1, 10, 1E10, 1, 1/4.1855, 1/23.052,
   1, 0
}

Definition at line 82 of file ParseOptions.C.

const char* unit_string_array[N_UNITS_UNDEFINED+1] [static]

Initial value:

  {
  "", "fs", "ns", "sec", "min", "hr", "A", "nm", "m", 
  "kcal", "kJ", "eV", "K", "undefined units"
}

Definition at line 37 of file ParseOptions.C.

Referenced by ustring().


Generated on Tue May 22 01:17:17 2018 for NAMD by  doxygen 1.4.7