NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Environment Class Reference

#include <Environment.h>

Inherited by AppEnvironment.

Public Member Functions

PrintUsage

Prints out all environment variable names

Parameters
ostream&- Stream to output
Returns
None
virtual void PrintUsage (ostream &s) const
 
SetStaticOptions

Gets global option values

Parameters
None
Returns
None
virtual void SetStaticOptions ()
 
RegisterOption

Method for registering new option. Using this method is possible to register new option with it's name, type, abbreviation and default value.

Parameters
nameName of the option.
typeThe type of the variable.
abbrevIf not NULL, alias usable as a command line option.
defValueImplicit value used if not specified explicitly.
Returns
None
void RegisterOption (const char *name, const OptionType type, const char *abbrev, const char *defValue=NULL)
 
SetInt

Method for setting new Int.

Parameters
nameName of the option.
valueValue of the option
Returns
None
void SetInt (const char *name, const int value)
 
SetFloat

Method for setting new Float.

Parameters
nameName of the option.
valueValue of the option
Returns
None
void SetFloat (const char *name, const float value)
 
SetBool

Method for setting new Bool.

Parameters
nameName of the option.
valueValue of the option
Returns
None
void SetBool (const char *name, const bool value)
 
SetString

Method for setting new String.

Parameters
nameName of the option.
valueValue of the option
Returns
None
void SetString (const char *name, const char *value)
 
GetBool

Method for getting Bool

Parameters
constchar* - Name of the option.
constbool - whether is this value critical
Returns
the Bool
bool GetBool (const char *name, const bool isFatal=false) const
 
GetInt

Method for getting Int

Parameters
constchar* - Name of the option.
constbool - whether is this value critical
Returns
the Int
int GetInt (const char *name, const bool isFatal=false) const
 
GetFloat

Method for getting Float

Parameters
constchar* - Name of the option.
constbool - whether is this value critical
Returns
the Float
float GetFloat (const char *name, const bool isFatal=false) const
 
GetDouble

Method for getting Double

Parameters
constchar* - Name of the option.
constbool - whether is this value critical
Returns
the Double
double GetDouble (const char *name, const bool isFatal=false) const
 
GetIntValue

Get Integer value

Parameters
constchar* - Value name
int&- Place to store variable
constbool - Whether value is critical
Returns
bool - Whether succeeded
bool GetIntValue (const char *name, int &value, const bool isFatal=false) const
 
GetDoubleValue

Get Double value

Parameters
constchar* - Value name
double&- Place to store variable
constbool - Whether value is critical
Returns
bool - Whether succeeded
bool GetDoubleValue (const char *name, double &value, const bool isFatal=false) const
 
GetFloatValue

Get Float value

Parameters
constchar* - Value name
float&- Place to store variable
constbool - Whether value is critical
Returns
bool - Whether succeeded
bool GetFloatValue (const char *name, float &value, const bool isFatal=false) const
 
GetBoolValue

Get Bool value

Parameters
constchar* - Value name
bool&- Place to store variable
constbool - Whether value is critical
Returns
bool - Whether succeeded
bool GetBoolValue (const char *name, bool &value, const bool isFatal=false) const
 
GetStringValue

Get String value

Parameters
constchar* - Value name
string&- Place to store variable
constbool - Whether value is critical
Returns
bool - Whether succeeded
bool GetStringValue (const char *name, char *value, const bool isFatal=false) const
 
bool GetStringValue (const char *name, string &value, const bool isFatal=false) const
 
CheckForSwitch

Check if the specified switch is present in the command line. Primary use of this function is to check for presence of some special switch, e.g. -h for help. It can be used anytime.

Parameters
argcNumber of command line arguments.
argvArray of command line arguments.
swtchSwitch we are checking for.
Returns
true if found, false elsewhere.
bool CheckForSwitch (const int argc, char **argv, const char swtch) const
 
ReadCmdlineParams

First pass of parsing command line. This function parses command line and gets from there all non-optional parameters (i.e. not prefixed by the dash) and builds a table of parameters. According to param optParams, it also writes some optional parameters to this table and pair them with corresponding non-optional parameters.

Parameters
argcNumber of command line arguments.
argvArray of command line arguments.
optParamsString consisting of prefixes to non-optional parameters. All prefixes must be only one character wide !
Returns
None
void ReadCmdlineParams (const int argc, char **argv, const char *optParams)
 
ReadEnvFile

Reading of the environment file. This function reads the environment file.

Parameters
filenameThe name of the environment file to read.
Returns
true if OK, false in case of error.
bool ReadEnvFile (const char *filename)
 
void ParseCmdline (const int argc, char **argv, const int index)
 
int GetParamNum () const
 
bool GetParam (const char name, const int index, char *value) const
 
Environment
 Environment ()
 
virtual ~Environment ()
 

Static Public Member Functions

SetSingleton

Sets singleton pointer to one passed by argument

Parameters
Environment*- new singleton pointer
Returns
None
static EnvironmentGetSingleton ()
 
GetSingleton

Gets singleton pointer, if NULL - then exit

Parameters
None
Returns
Environment*
static void SetSingleton (Environment *e)
 
DeleteSingleton

Deletes singleton pointer

Parameters
None
Returns
None
static void DeleteSingleton ()
 

OptionPresent

Determine whether option is present.

const char* - Specifies name of option

Returns
True if present, otherwise false
static EnvironmentmEnvironment = NULL
 
bool OptionPresent (const char *name) const
 

Detailed Description

Definition at line 160 of file Environment.h.

Constructor & Destructor Documentation

Environment::Environment ( )

Definition at line 1128 of file Environment.cpp.

Environment::~Environment ( )
virtual

Definition at line 1157 of file Environment.cpp.

Member Function Documentation

bool Environment::CheckForSwitch ( const int  argc,
char **  argv,
const char  swtch 
) const

Definition at line 641 of file Environment.cpp.

void Environment::DeleteSingleton ( )
static

Definition at line 220 of file Environment.cpp.

bool Environment::GetBool ( const char *  name,
const bool  isFatal = false 
) const

Definition at line 431 of file Environment.cpp.

bool Environment::GetBoolValue ( const char *  name,
bool &  value,
const bool  isFatal = false 
) const

Definition at line 579 of file Environment.cpp.

double Environment::GetDouble ( const char *  name,
const bool  isFatal = false 
) const

Definition at line 482 of file Environment.cpp.

bool Environment::GetDoubleValue ( const char *  name,
double &  value,
const bool  isFatal = false 
) const

Definition at line 527 of file Environment.cpp.

float Environment::GetFloat ( const char *  name,
const bool  isFatal = false 
) const

Definition at line 464 of file Environment.cpp.

bool Environment::GetFloatValue ( const char *  name,
float &  value,
const bool  isFatal = false 
) const

Definition at line 553 of file Environment.cpp.

int Environment::GetInt ( const char *  name,
const bool  isFatal = false 
) const

Definition at line 446 of file Environment.cpp.

bool Environment::GetIntValue ( const char *  name,
int &  value,
const bool  isFatal = false 
) const

Definition at line 501 of file Environment.cpp.

bool Environment::GetParam ( const char  name,
const int  index,
char *  value 
) const

Returns the indexed parameter or corresponding optional parameter. This function is used for queries on individual non-optional parameters. The table must be constructed to allow this function to operate (i.e. the first pass of command line parsing must be done).

Parameters
nameIf space (' '), returns the non-optional parameter, else returns the corresponding optional parameter.
indexIndex of the non-optional parameter to which all other options corresponds.
valueReturn value of the queried parameter.
Returns
true if OK, false in case of error or if the parameter wasn't specified.

Definition at line 1064 of file Environment.cpp.

int Environment::GetParamNum ( ) const
inline

Parameters number query function. This function returns number of non-optional parameters specified on the command line.

Definition at line 436 of file Environment.h.

Environment * Environment::GetSingleton ( )
static

Definition at line 203 of file Environment.cpp.

bool Environment::GetStringValue ( const char *  name,
char *  value,
const bool  isFatal = false 
) const

Definition at line 601 of file Environment.cpp.

bool Environment::GetStringValue ( const char *  name,
string &  value,
const bool  isFatal = false 
) const

Definition at line 623 of file Environment.cpp.

bool Environment::OptionPresent ( const char *  name) const

Definition at line 1096 of file Environment.cpp.

void Environment::ParseCmdline ( const int  argc,
char **  argv,
const int  index 
)

Second pass of the command line parsing. Performs parsing of the command line ignoring all parameters and options read in the first pass. Builds table of options.

Parameters
argcNumber of command line arguments.
argvArray of command line arguments.
indexIndex of non-optional parameter, of which options should be read in.

Definition at line 951 of file Environment.cpp.

void Environment::PrintUsage ( ostream &  s) const
virtual

Definition at line 232 of file Environment.cpp.

void Environment::ReadCmdlineParams ( const int  argc,
char **  argv,
const char *  optParams 
)

Definition at line 662 of file Environment.cpp.

bool Environment::ReadEnvFile ( const char *  filename)

Definition at line 743 of file Environment.cpp.

void Environment::RegisterOption ( const char *  name,
const OptionType  type,
const char *  abbrev,
const char *  defValue = NULL 
)

Definition at line 264 of file Environment.cpp.

void Environment::SetBool ( const char *  name,
const bool  value 
)

Definition at line 375 of file Environment.cpp.

void Environment::SetFloat ( const char *  name,
const float  value 
)

Definition at line 349 of file Environment.cpp.

void Environment::SetInt ( const char *  name,
const int  value 
)

Definition at line 323 of file Environment.cpp.

void Environment::SetSingleton ( Environment e)
static

Definition at line 192 of file Environment.cpp.

void Environment::SetStaticOptions ( )
virtual

Definition at line 246 of file Environment.cpp.

void Environment::SetString ( const char *  name,
const char *  value 
)

Definition at line 406 of file Environment.cpp.

Member Data Documentation

Environment * Environment::mEnvironment = NULL
static

Definition at line 459 of file Environment.h.


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