1 #ifndef CARMA_UTIL_PROGRAM_H
2 #define CARMA_UTIL_PROGRAM_H
27 #include <sys/types.h>
29 #include "carma/util/FacilityType.h"
32 int carma_main(
int argc,
char ** argv );
53 class ProcessMonitorClient;
64 const char *
const key;
69 const char *
const val;
94 friend int ::carma_main(
int argc,
char ** argv );
231 static log4cpp::Category * getLoggerIfAvailable( );
252 static ::std::string
getArg0( );
310 static ::std::string
getConfFile( const ::std::string & filename );
355 static ::std::string
getCwd( );
357 int getTraceLevel( )
const;
359 void adjustTraceLevel(
int newTraceLevel );
388 BEING_CONSTRUCTED_STATE,
391 ADDING_KEY_DEFINITIONS_STATE,
392 KEY_DEFINITIONS_ADDED_STATE,
394 PARSING_COMMAND_LINE_STATE,
395 COMMAND_LINE_PARSED_STATE,
397 INITIALISING_SYSTEM_KEYWORD_MEMBERS_STATE,
398 SYSTEM_KEYWORD_MEMBERS_INITIALISED_STATE,
400 LOGGER_AVAILABLE_STATE,
401 TRACE_OBJECT_AVAILABLE_STATE,
403 FULLY_INITIALISED_STATE,
407 BEING_DESTRUCTED_STATE,
419 NORMAL_PARAM_SPECIFY_TYPE,
420 MANDATORY_PARAM_SPECIFY_TYPE,
421 NO_DEFAULT_PARAM_SPECIFY_TYPE
430 ::std::string defaultValueString;
432 ::std::string usageValue;
434 ParamSpecifyType specifyType;
437 ::std::string valueString;
440 bool valueSpecifiedWasChecked;
444 typedef ::std::map< ::std::string, ParameterInfo > ParameterInfoMap;
446 void verifyStateIsInRange( StateType rangeBegin,
447 StateType rangeEnd )
const;
449 void verifyStateIsInitializingSystemKeywordMembers( )
const;
451 void verifyStateIsNormal( )
const;
461 static int run(
Program & program );
468 int initializeCarma( );
475 void terminateCarma( );
481 ::
size_t declIndex );
483 void docKeys(
bool system,
bool declOrder )
const;
485 ::std::string getDescriptionString( )
const;
488 ::std::string getParameterValueString( const ::std::string & key,
511 static void docKey( const ::std::string & name,
512 const ParameterInfo & parameterInfo );
563 log4cpp::Category & getDefaultLogger( )
const;
566 static ParamType convertParameterType( const ::std::string & s );
568 void advanceState( StateType newState );
582 static const char *
const kUsage_;
585 static const char *
const kVersion_;
586 static const char *
const kDescription_;
588 static const bool kHaveInitialLoggerInfo_;
589 static const char *
const kInitialFacilityName_;
590 static const char *
const kInitialLogname_;
595 ::std::string progname_;
597 ParameterInfoMap parameterInfoMap_;
600 log4cpp::Category * logger_;
602 ::std::string logFileName_;
603 ::std::string logHostName_;
607 bool imrHostnameWasSpecified_;
608 ::std::string imrHostnameSpecified_;
610 ::std::auto_ptr<carma::corba::Server> corbaServer_;
611 ::std::auto_ptr<carma::util::ProcessMonitorClient> processMonitorClient_;
628 ::std::string traceFile_;
634 ::std::string logname_;
635 bool instanceLognameSet_;
647 friend int ::carma_main(
int argc,
char ** argv );
bool DebugLevel(int level=0) const
has a debug level exceeded the set value?
static int getExtraArgc()
Obtain the length of the array of command line arguments with all CARMA arguments removed...
static bool getUseDBMS()
Returns value of system keyword "useDBMS".
Base class for managing resources and interfaces common across all carma programs.
static pid_t getPid()
Get pid of this program.
bool orbInit(Orb *orb)
Set ORB parameters.
::std::string getExecutable()
Get absolute full path of executable.
const char *const usageValue
Usage value shown on the usage line.
const char *const type
Name of the type of the value.
::std::string getRootDir()
Get the root build or install directory - assumes standard carma tree.
static Program & getProgram()
Class static method to get the process-wide singleton instance of Program.
::std::string getStringParameter(const ::std::string &key)
get value of a string parameter
bool haveImrHostname() const
Was imr hostname specified on the commmand line?
const char *const val
default value for keyword
ProgramBase()
Default constructor.
static char ** getExtraArgv()
Obtain the array of command line arguments with all CARMA arguments removed.
int getIntParameter(const ::std::string &key)
get value of an int parameter
::std::string getParameterRawValueString(const ::std::string &key)
get the raw value string of a parameter
::std::string getHostname(bool shorten)
Get hostname of the machine this program is running on.
Class to encapsulate CORBA client functionality in CARMA.
::std::string getArg0()
Get the first argument passed to main()
~ProgramBase()
Destructor.
::std::string getImrHostname() const
Retrieve the imr hostname.
double getDoubleParameter(const ::std::string &key)
get value of a double parameter
const char *const help
Help string.
static log4cpp::Category & getLogger()
Returns a reference to the process-wide default logger.
int getDebugLevel() const
debug level of the program environment
bool parameterWasSpecified(const ::std::string &key)
Query whether the value of the parameter was specified on the command line.
::std::string getLogname() const
get the log name of for the logger of this Progam
Convenience structure to hold the key=value/type/usage/help-string information.
facilityType
A type for syslog facilities.
Class for creating, managing and serving requests to CORBA servants.
const char *const key
keyword (name used on commad line)
::std::string getUsageString() const
Get the usage string for this program.
bool getBoolParameter(const ::std::string &key)
get value of a bool parameter
::std::string getConfDir()
Get the configuration directory - assumes standard carma tree.
::std::string getCwd()
Get the current working directory.
::std::string getConfFile(const ::std::string &filename)
Get the absolute path of a configuration file.
::std::string getExecutableDir()
Get the directory where this program binary lives.
void setInstanceLogname(const ::std::string &logname)
set the logger logname for this instance of a Program
::std::string getLogHostname() const
Gets hostname of machine that stores the log file.
bool imrTerminationRequested()
Check for an IMR instructed termination request.
Class for managing resources and interfaces common across all carma programs.
The Trace class provides an efficient means for managing debug statements throughout CARMA code...