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 USE_COMPAT_CONST
#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 154 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 141 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 285 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 312 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 272 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 298 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 353 of file ParseOptions.C.

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

Definition at line 926 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 604 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 625 of file ParseOptions.C.

#define USE_COMPAT_CONST

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

Definition at line 21 of file ParseOptions.C.


Function Documentation

BigReal convert ( Units  to,
Units  from 
)

Definition at line 90 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.

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

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 49 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().

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

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 928 of file ParseOptions.C.

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

Referenced by ParseOptions::getfromptr().

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

const char* rstring ( Range  r  ) 

Definition at line 26 of file ParseOptions.C.

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

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

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 115 of file ParseOptions.C.

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

const char* ustring ( Units  u  ) 

Definition at line 43 of file ParseOptions.C.

References unit_string_array.

Referenced by ParseOptions::units().

00044 {
00045    return unit_string_array[u];
00046 }


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 83 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 38 of file ParseOptions.C.

Referenced by ustring().


Generated on Fri Sep 22 01:17:16 2017 for NAMD by  doxygen 1.4.7