Augustus 3.4.0
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
Properties Class Reference

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)
 

Detailed Description

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
     
Author
Emmanouil Stafilarakis

Member Function Documentation

◆ addProperty()

void Properties::addProperty ( string  name,
string  value 
)
static

@doc Add a new property to the Properties object.

Parameters
nameThe name of the property.
valueThe string value of the property.

◆ init()

void Properties::init ( int  argc,
char *  argv[] 
)
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.

Parameters
argcThe count of the arguments.
argvA NULL terminated field with the arguments.

◆ readFile()

void Properties::readFile ( string  file)
static
Author
Emmanouil Stafilarakis
Version
0.1 Read all properties from the given file.
Parameters
fileThe file with the programm properties
Exceptions
PropertiesError

The documentation for this class was generated from the following files: