Base class for managing resources and interfaces common across all carma programs.
More...
#include <carma/util/Program.h>
|
::std::string | getArg0 () |
| Get the first argument passed to main() More...
|
|
::std::string | getConfDir () |
| Get the configuration directory - assumes standard carma tree. More...
|
|
::std::string | getConfFile (const ::std::string &filename) |
| Get the absolute path of a configuration file. More...
|
|
::std::string | getCwd () |
| Get the current working directory. More...
|
|
::std::string | getExecutable () |
| Get absolute full path of executable. More...
|
|
::std::string | getExecutableDir () |
| Get the directory where this program binary lives. More...
|
|
static int | getExtraArgc () |
| Obtain the length of the array of command line arguments with all CARMA arguments removed. More...
|
|
static char ** | getExtraArgv () |
| Obtain the array of command line arguments with all CARMA arguments removed. More...
|
|
::std::string | getHostname (bool shorten) |
| Get hostname of the machine this program is running on. More...
|
|
static log4cpp::Category & | getLogger () |
| Returns a reference to the process-wide default logger. More...
|
|
static log4cpp::Category * | getLoggerIfAvailable () |
|
static pid_t | getPid () |
| Get pid of this program. More...
|
|
::std::string | getRootDir () |
| Get the root build or install directory - assumes standard carma tree. More...
|
|
static carma::util::Trace * | getTraceObject () |
|
static carma::util::Trace * | getTraceObjectIfAvailable () |
|
static bool | getUseDBMS () |
| Returns value of system keyword "useDBMS". More...
|
|
Base class for managing resources and interfaces common across all carma programs.
Definition at line 93 of file Program.h.
carma::util::ProgramBase::ProgramBase |
( |
| ) |
|
|
protected |
carma::util::ProgramBase::~ProgramBase |
( |
| ) |
|
|
protected |
bool carma::util::ProgramBase::DebugLevel |
( |
int |
level = 0 | ) |
const |
has a debug level exceeded the set value?
- Returns
- debug level high enough?
::std::string carma::util::ProgramBase::getArg0 |
( |
| ) |
|
|
static |
Get the first argument passed to main()
This is usually the program name.
bool carma::util::ProgramBase::getBoolParameter |
( |
const ::std::string & |
key | ) |
|
get value of a bool parameter
- Returns
- value of a bool parameter
::std::string carma::util::ProgramBase::getConfDir |
( |
| ) |
|
|
static |
Get the configuration directory - assumes standard carma tree.
The conf directory is assumed to be /carmaRoot/conf/. See the documentation for the RuntimeDirs class for the definition of the carma tree and how it is used. The returned string is an absolute path that ends with a slash character (/).
- See Also
- getConfFile
-
getRootDir
-
RuntimeDirs
- Exceptions
-
::std::string carma::util::ProgramBase::getConfFile |
( |
const ::std::string & |
filename | ) |
|
|
static |
Get the absolute path of a configuration file.
If the filename begins with a slash then it is assumed to be an absolute path and is left untouched. If the filename begins with a dash then it is assumed to be a path local to the current working directory and the dash is removed. All other filenames are appended to the conf directory. See the documentation for the RuntimeDirs class for the definition of the carma tree and how it is used.
- Parameters
-
- See Also
- getConfDir
-
getRootDir
-
RuntimeDirs
- Exceptions
-
::std::string carma::util::ProgramBase::getCwd |
( |
| ) |
|
|
static |
Get the current working directory.
Unless changed by the application itself, this is generally the directory the program was invoked from.
int carma::util::ProgramBase::getDebugLevel |
( |
| ) |
const |
debug level of the program environment
- Returns
- debug level
double carma::util::ProgramBase::getDoubleParameter |
( |
const ::std::string & |
key | ) |
|
get value of a double parameter
- Returns
- value of a double parameter
::std::string carma::util::ProgramBase::getExecutable |
( |
| ) |
|
|
static |
Get absolute full path of executable.
::std::string carma::util::ProgramBase::getExecutableDir |
( |
| ) |
|
|
static |
Get the directory where this program binary lives.
This string is an absolute path that ends with a slash character (/).
static int carma::util::ProgramBase::getExtraArgc |
( |
| ) |
|
|
static |
Obtain the length of the array of command line arguments with all CARMA arguments removed.
This can only legitimately be called after the command line has been parsed which is certainly true by the time the Program::main is entered.
- Returns
- length of the array of command line arguments with all CARMA arguments removed.
static char** carma::util::ProgramBase::getExtraArgv |
( |
| ) |
|
|
static |
Obtain the array of command line arguments with all CARMA arguments removed.
This can only legitimately be called after the command line has been parsed which is certainly true by the time the Program::main is entered.
- Returns
- array of command line arguments with all CARMA arguments removed.
::std::string carma::util::ProgramBase::getHostname |
( |
bool |
shorten | ) |
|
|
static |
Get hostname of the machine this program is running on.
- Parameters
-
shorten | Retrieve short hostname only, otherwise return hostname as reported by gethostname. |
::std::string carma::util::ProgramBase::getImrHostname |
( |
| ) |
const |
Retrieve the imr hostname.
Make sure the imr hostname was specified prior to calling this.
- See Also
- haveImrHostname
int carma::util::ProgramBase::getIntParameter |
( |
const ::std::string & |
key | ) |
|
get value of an int parameter
- Returns
- value of an int parameter
static log4cpp::Category& carma::util::ProgramBase::getLogger |
( |
| ) |
|
|
static |
Returns a reference to the process-wide default logger.
Class global method that returns a reference to the process-wide default logger. The logger will not produce any output if it has been configured incorrectly. For example, if the carma default logger is the syslog (using a syslogd), then syslogd must be configured to log carma messages using syslog.conf. No output will be produced by the logger if its configured incorrectly.
- Returns
- log4cpp::Category& - reference to the carma default logger - usually syslogd.
- See Also
- carma/util/Logger.h, log4cpp
::std::string carma::util::ProgramBase::getLogHostname |
( |
| ) |
const |
Gets hostname of machine that stores the log file.
Class method that returns the hostname of the machine hosting the log file. Default value is "localhost", that is, the machine on which the process is executing.
- Returns
- string - name of the log host machine, default is "localhost".
- Todo:
- Consider deprecation of this routine and removal of the logHost command line option.
- See Also
- carma/util/Logger.h, log4cpp
::std::string carma::util::ProgramBase::getLogname |
( |
| ) |
const |
int carma::util::ProgramBase::getNiceLevel |
( |
| ) |
const |
- Returns
- the nice value this program was started with
::std::string carma::util::ProgramBase::getParameterRawValueString |
( |
const ::std::string & |
key | ) |
|
get the raw value string of a parameter
- Returns
- raw value string of a parameter
static pid_t carma::util::ProgramBase::getPid |
( |
| ) |
|
|
static |
::std::string carma::util::ProgramBase::getRootDir |
( |
| ) |
|
|
static |
Get the root build or install directory - assumes standard carma tree.
See the documentation for the RuntimeDirs class for the definition of the carma tree and how it is used. The returned string is an absolute path that ends with a slash character (/).
- See Also
- getConfDir
-
getConfFile
-
RuntimeDirs
- Exceptions
-
::std::string carma::util::ProgramBase::getStringParameter |
( |
const ::std::string & |
key | ) |
|
get value of a string parameter
- Returns
- value of a string parameter
::std::string carma::util::ProgramBase::getUsageString |
( |
| ) |
const |
Get the usage string for this program.
- Returns
- Usage string for this program
static bool carma::util::ProgramBase::getUseDBMS |
( |
| ) |
|
|
static |
Returns value of system keyword "useDBMS".
If useDBMS is true, then monitor points are assigned tagID's from the database, or from a proxy conf file if the database isn't reachable. If useDBMS is false, tagID's are assigned on the fly.
- Returns
- bool value of boolean system keyword "useDBMS"
bool carma::util::ProgramBase::getUseGMT |
( |
| ) |
const |
- Returns
- the value of useGMT that program was started with
bool carma::util::ProgramBase::haveImrHostname |
( |
| ) |
const |
Was imr hostname specified on the commmand line?
bool carma::util::ProgramBase::imrTerminationRequested |
( |
| ) |
|
Check for an IMR instructed termination request.
Indicates if this application has been instructed to shutdown by the IMR. This should be called as part of a main event loop.
bool carma::util::ProgramBase::orbInit |
( |
Orb * |
orb | ) |
|
Set ORB parameters.
This function should be used instead of the CorbaUtils::setOrb commands. With no arguments, it simplifies what the programmer needs to know.
- Returns
- bool value if everything is set okay.
bool carma::util::ProgramBase::parameterWasSpecified |
( |
const ::std::string & |
key | ) |
|
Query whether the value of the parameter was specified on the command line.
- Returns
- true if and only if the value of the parameter was specified on the command line.
void carma::util::ProgramBase::setInstanceLogname |
( |
const ::std::string & |
logname | ) |
|
set the logger logname for this instance of a Program
This method is useful if you will have multiple instances of the same Program which differ only by keyword values given on the command line. For example, maybe you have six instances of a program "pod" that take different command line arguments of podNo=1, podNo=2, etc. The @logger tag for the program might have "@logger DEFAULT_FACILITY carma.pod.foo" and using this method each instance could, in it's Program::main implementation refine this logname by calling setInstanceLogname( "carma.pod" + podNoString + ".foo" )
- Parameters
-
logname | The hierarchical namespace for this Category, e.g. "carma.monitor". The root logger will be "carma", all other loggers should be "carma.something[.somethingelse]" to make use of:
- log4cpp's automatic heirarchical logging.
- for sorting in e.g. database queries.
|
- See Also
- Logger::getSyslogger
The documentation for this class was generated from the following files: