You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.0 KiB
C++

/***************************************************************************
* Copyright (C) 2015 by gempa GmbH *
* *
* All Rights Reserved. *
* *
* NOTICE: All information contained herein is, and remains *
* the property of gempa GmbH and its suppliers, if any. The intellectual *
* and technical concepts contained herein are proprietary to gempa GmbH *
* and its suppliers. *
* Dissemination of this information or reproduction of this material *
* is strictly forbidden unless prior written permission is obtained *
* from gempa GmbH. *
***************************************************************************/
#ifndef GEMPA_CAPS_APPLICATION_H
#define GEMPA_CAPS_APPLICATION_H
#include <gempa/caps/api.h>
namespace Gempa {
namespace CAPS {
class SC_GEMPA_CAPS_API Application {
public:
Application(int argc, char **argv);
virtual ~Application() {}
/**
* Exit the application and set the returnCode.
* @param returnCode The value returned from exec()
*/
virtual void exit(int returnCode);
/**
* @brief Conventient function to simplify usage
* @return The value returned from exec()
*/
int operator()() { return exec(); }
/**
* @brief In case of an interrupt this method can be used to
* forward the signal to the internal signal handling.
* @param signal
*/
static void Interrupt(int signal);
protected:
/**
* @brief Cleanup method called before exec() returns.
*/
virtual void done();
/**
* Execs the mainloop and waits until exit() is called
* or a appropriate signal has been fired (e.g. SIGTERM).
* @return The value that was set with to exit()
*/
int exec();
/**
* @brief This method can be used to implement custom
* signal handling.
* @param signal The emitted signal
*/
virtual void handleInterrupt(int signal);
/**
* @brief Initialization method. This method calls the initCommandLine
* initConfiguration and validateParameters function
*/
virtual bool init();
/**
* @brief Handles commandline arguments
*/
virtual bool initCommandLine();
/**
* @brief Handles configuration files
*/
virtual bool initConfiguration();
/**
* @brief This method must be implemented in the inherited class to
* execute the plugin specific code.
*/
virtual bool run();
/**
* @brief This method can be used to verify custom configuration or
commandline parameters
*/
virtual bool validateParameters();
protected:
bool _exitRequested;
int _argc;
char **_argv;
private:
int _returnCode;
static Application *_app;
};
}
}
#endif