Augustus 3.4.0
|
The Properties class. More...
#include <properties.hh>
Static Public Member Functions | |
static void | readFile (string file) |
static void | init (int argc, char *argv[]) |
static Boolean | hasProperty (string name) |
static void | addProperty (string name, string value) |
static Integer | getIntProperty (string name) |
static Double | getDoubleProperty (string name) |
static double | getdoubleProperty (string name) |
static Boolean | getBoolProperty (string name) |
static const char * | getProperty (string name) |
static const char * | getProperty (string name, int index) |
static string | getConfigFilename (string name) |
static bool | assignProperty (string name, Integer &target) |
static bool | assignProperty (string name, unsigned &target) |
static bool | assignProperty (string name, Double &target) |
static bool | assignProperty (string name, double &target) |
static bool | assignProperty (string name, Boolean &target) |
static bool | assignProperty (string name, string &target) |
static bool | assignProperty (string name, const char *&target) |
The Properties class.
This class is provided to pass several properties to all objects in the running programm.
The properties can be given to the Properties object by the programm with the addProperty method.
The Properties object can also parse a file with the readFile method and also parse the commandline arguments with the init method.
If an adding property already exists, the old value will be overwriten with the new value. Therefore, if the commandline arguments should be prefered, the method init should be called after the method readFile!
Example:
int main( int argc, char* argv[] ){ string configfile; Properties props; .... try{ props.readFile( configfile ); // first parse the config file props.init( argc, argv ); // then the commandline options .... } catch( PropertiesError& err ){ .... }
A class can get the properties with the getTYPEProperty methods, where TYPE is one of Int, Double, Bool or String.
The format of the properties file is line based. Each line contains the property name and the property value, separated by whitespaces. Comments begin with a '#' and end an the end of line.
Example: Listing of a properties file
# For the GBProcessor object #--------------------------- /GBProcessor/file fly.txt # The db file. # For the EHMMTraining class #---------------------------- /EHMMTraining/statecount 3 /EHMMTraining/state00 igenicmodel.so /EHMMTraining/state01 exonmodel.so /EHMMTraining/state02 intronmodel.so # For the IGenicModel class #--------------------------- /IGenicModel/outfile igenic_out.pbl /IGenicModel/c 1 /IGenicModel/k 5 # For the ExonModel class #--------------------------- /ExonModel/outfile exon_out.pbl /ExonModel/c 1 /ExonModel/k 5 # For the IntronModel class #--------------------------- /IntronModel/outfile intron_out.pbl /IntronModel/c 1 /IntronModel/d 350 /IntronModel/e 20 /IntronModel/k 5 /IntronModel/h 5
|
static |
@doc Add a new property to the Properties object.
name | The name of the property. |
value | The string value of the property. |
|
static |
@memo Parse the commandline arguments.
@doc The format of the commandline arguments should be –/CLASS/PROPERTY=VALUE.
So, the class CLASS can set the value VALUE to its property PROPERTY.
argc | The count of the arguments. |
argv | A NULL terminated field with the arguments. |
|
static |
file | The file with the programm properties |
PropertiesError |