Go to the documentation of this file.
38 #ifndef TTA_APPLICATION_HH
39 #define TTA_APPLICATION_HH
49 typedef int siginfo_t;
58 #define UNKNOWN_FUNCTION "[?]"
63 #if __STDC_VERSION__ < 199901L
65 # define __func__ __PRETTY_FUNCTION__
67 # define __func__ UNKNOWN_FUNCTION
72 #define abortWithError(message) \
73 Application::writeToErrorLog(__FILE__, __LINE__, __func__, message); \
74 Application::abortProgram();
78 # define assert(condition)
84 #define assert(condition)
86 #define assert(condition) \
88 abortWithError("Assertion failed: " #condition); \
95 #define debugLog(text) \
96 Application::writeToErrorLog(__FILE__, __LINE__, __func__, \
97 std::string("DEBUG: ") + std::string(text))
100 #define CATCH_ANY(XXX__) \
102 catch (const Exception& e) { \
103 debugLog(e.errorMessage() + " in " + \
104 e.fileName() + ":" + \
105 e.procedureName() + ":" + \
106 Conversion::toString(e.lineNum())); } \
107 catch ( ... ) { debugLog("Unknown exception"); }
110 #define verboseLogC(text, neededVerbosity) \
111 if (Application::verboseLevel() >= neededVerbosity) { \
112 Application::logStream() << text << std::endl; }
115 #define verboseLog(text) verboseLogC(text, 1)
118 #define PRINT_VAR(VARIABLE__) \
119 Application::logStream() << #VARIABLE__ << " == " \
120 << VARIABLE__ << std::endl
151 const std::string fileName,
152 const int lineNumber,
153 const std::string functionName,
154 const std::string message,
155 const int neededVerbosity = 0);
157 static void exitProgram(
const int status = EXIT_SUCCESS);
163 const std::string& commands);
165 const std::string& command);
167 const std::string& command,
168 std::vector<std::string>& outputLines,
170 bool includeStdErr =
false);
210 virtual void execute(
int data, siginfo_t *info) = 0;
static std::string installationRoot_
Path to the TCE installation root.
static std::ostream * errorStream_
The stream for user error notifications.
static UnixSignalHandler * getSignalHandler(int signalNum)
static void restoreSignalHandler(int signalNum)
static int runShellCommandAndGetOutput(const std::string &command, std::vector< std::string > &outputLines, std::size_t maxOutputLines=DEFAULT_MAX_OUTPUT_LINES, bool includeStdErr=false)
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
static void exitProgram(const int status=EXIT_SUCCESS)
static const int VERBOSE_LEVEL_DEFAULT
Default verbose level - do not print anything unnecessary.
static void setVerboseLevel(const int level=VERBOSE_LEVEL_DEFAULT)
static void setCmdLineOptions(CmdLineOptions *options_)
static int verboseLevel()
static std::ostream & logStream()
static void setSignalHandler(int signalNum, UnixSignalHandler &handler)
static std::ostream * logStream_
The stream for debug logging.
virtual ~UnixSignalHandler()
static bool increasedVerbose()
static bool spamVerbose()
static const bool LOOP_OPT_DEFAULT
Use Loop Optimizations.
static bool initialized_
True when initialize() is called. Ensures that initialization is done only once.
static CmdLineOptions * cmdLineOptions()
const int MAX_OUTPUT_LINE_LENGTH
maximum length of an output line saved from popen() output in runShellCommandAndGetOutput()
static std::ostream * warningStream_
The stream for user error notifications.
static const int VERBOSE_LEVEL_INCREASED
Increased verbose level - print information about modules etc.
static int runShellCommandSilently(const std::string &command)
static CmdLineOptions * cmdLineOptions_
Holds command line options passed to program.
static std::map< int, UnixSignalHandler * > signalHandlers_
Signal handlers in a map associated by their signal numbers.
static bool isInstalled()
static std::ostream & errorStream()
static std::string installationDir()
static int argc_
The original argc and argv given to the main program, if applicable.
static const int VERBOSE_LEVEL_SPAM
More Increased verbose level - spam about ddg heights of loops.
static std::ostream & warningStream()
const int DEFAULT_MAX_OUTPUT_LINES
default value of maximum amount of output lines saved from popen() output in runShellCommandAndGetOut...
static void unexpectedExceptionHandler()
virtual void execute(int data, siginfo_t *info)=0
static int verboseLevel_
Verbose level directs how much output will be printed to console.
static void abortProgram() __attribute__((noreturn))
static std::string TCEVersionString()
static void signalRedirector(int data, siginfo_t *info, void *context)
static bool shellCommandsExists(const std::string &commands)