BALL::ParameterSection Class Reference
[General Purpose File Formats]

#include <BALL/FORMAT/parameterSection.h>

Inheritance diagram for BALL::ParameterSection:
BALL::AtomTypes BALL::CharmmEEF1 BALL::ClaverieParameter BALL::CosineTorsion BALL::GeneralizedBornModel::GBParameters BALL::LennardJones BALL::Potential1210 BALL::QuadraticAngleBend BALL::QuadraticBondStretch BALL::QuadraticImproperTorsion BALL::RDFParameter BALL::RDFSection BALL::ResidueTorsions BALL::SolventParameter BALL::Templates

List of all members.


Public Types

Enums
enum  { MAX_FIELDS = 20 }

Public Member Functions

Constructors and Destructors
 ParameterSection ()
 ParameterSection (const ParameterSection &parameter_section)
virtual ~ParameterSection ()
Extracting Data from the Section
bool extractSection (Parameters &parameters, const String &section_name)
const StringgetSectionName () const
const StringgetValue (const String &key, const String &variable) const
bool has (const String &key, const String &variable) const
bool has (const String &key) const
bool hasVariable (const String &variable) const
Position getColumnIndex (const String &variable) const
Size getNumberOfVariables () const
Size getNumberOfKeys () const
const StringgetValue (Position key_index, Position variable_index) const
const StringgetKey (Position key_index) const
Assignment
virtual void clear ()
const ParameterSectionoperator= (const ParameterSection &section)
Predicates
virtual bool isValid () const
bool operator== (const ParameterSection &parameter_section) const

Public Attributes

Public Members
Options options

Static Public Attributes

static const String UNDEFINED

Protected Attributes

String section_name_
String format_line_
StringHashMap< Indexsection_entries_
StringHashMap< Indexvariable_names_
std::vector< Stringentries_
std::vector< Stringkeys_
Size number_of_variables_
std::vector< floatversion_
bool valid_

Detailed Description

General Parameter Section Class. It is similar to INIFile , but a little bit more sophisticated. Just as in a INIFile there can be comment lines starting with either "<b>;</b>", "<b>!</b>" or "<b>\#</b>" and it is divided in sections. A section-line looks like "<b>[ElectricFieldEffect]</b>". The first non-comment line in a section is the format-line. It defines the sort of values stored in the section and their order:

"<b>key:residue key:atom value:charge </b>"
Option lines start with a "<b>@ </b>":
"<b>@exclude_residue_field=true </b>"
The values are stored in fields seperated by whitespaces in the order given by their format-line:
"<b> Ca Ca 9.6 </b>"

Each value line may contain version information, indicated by a variable definition named "ver"; thus only the latest version will be version will be accessed.


Member Enumeration Documentation

anonymous enum
Enumerator:
MAX_FIELDS 

Constructor & Destructor Documentation

BALL::ParameterSection::ParameterSection (  ) 

Default constructor.

BALL::ParameterSection::ParameterSection ( const ParameterSection parameter_section  ) 

Copy constructor

virtual BALL::ParameterSection::~ParameterSection (  )  [virtual]

Destructor.


Member Function Documentation

bool BALL::ParameterSection::extractSection ( Parameters parameters,
const String section_name 
)

Reads a parameter section from an INI file. This method reads the section given in section_name from ini_file, interprets (if given) a format line, reads the data from this section according to the format, and builds some datastructures for fast and easy acces to the data.

Parameters:
parameters the parameters defining the inifile to be read from
section_name the name of the section to be read (without the squared brackets)
Returns:
bool - true if the section could be read, false otherwise

Reimplemented in BALL::AtomTypes, BALL::CharmmEEF1, BALL::CosineTorsion, BALL::LennardJones, BALL::Potential1210, BALL::QuadraticAngleBend, BALL::QuadraticBondStretch, BALL::QuadraticImproperTorsion, BALL::ResidueTorsions, BALL::Templates, BALL::GeneralizedBornModel::GBParameters, BALL::SolventParameter, and BALL::RDFSection.

Position BALL::ParameterSection::getColumnIndex ( const String variable  )  const

Return the column index of a variable. If section doesn't have the variable, INVALID_POSITION is returned.

const String& BALL::ParameterSection::getKey ( Position  key_index  )  const

Fast access to the key array. The first key has the index 0. If the key is undefined, UNDEFINED is returned.

Size BALL::ParameterSection::getNumberOfKeys (  )  const

Returns the number of different keys defined.

Size BALL::ParameterSection::getNumberOfVariables (  )  const

Returns the number of defined variables.

const String& BALL::ParameterSection::getSectionName (  )  const

Return the name of the section read. The section name is empty before extractSection was called.

Returns:
the name of the section extracted
const String& BALL::ParameterSection::getValue ( Position  key_index,
Position  variable_index 
) const

Fast access to the value array. If the value is undefined, UNDEFINED is returned.

const String& BALL::ParameterSection::getValue ( const String key,
const String variable 
) const

Returns the value associated with the key and returns the value of the given variable. If the requested variable is not defined in the format line, an empty string is returned.

bool BALL::ParameterSection::has ( const String key  )  const

Query for a key. False is returned if the key could not be found.

Parameters:
key the key to serch in the hash table

Reimplemented in BALL::Templates.

bool BALL::ParameterSection::has ( const String key,
const String variable 
) const

Query for a pair of key and variable. False is returned if

  • the key could not be found
  • the the key was found but the variable name was not specified in the format line
bool BALL::ParameterSection::hasVariable ( const String variable  )  const

Query whether a specified variable was defined in the format line.

virtual bool BALL::ParameterSection::isValid (  )  const [virtual]

Validity predicate

const ParameterSection& BALL::ParameterSection::operator= ( const ParameterSection section  ) 

Assignment operator

bool BALL::ParameterSection::operator== ( const ParameterSection parameter_section  )  const

Equality operator


Member Data Documentation

std::vector<String> BALL::ParameterSection::entries_ [protected]
std::vector<String> BALL::ParameterSection::keys_ [protected]

The options read in from options lines contained in this section. Remember: options lines start with "@" as the first character and must be of the form "@name=value".

Result Type for unknown items.

std::vector<float> BALL::ParameterSection::version_ [protected]