5#ifndef ICE_APPLICATION_H
6#define ICE_APPLICATION_H
16using IceUtil::CtrlCHandler;
19#ifdef ICE_CPP11_MAPPING
50#ifdef ICE_CPP11_MAPPING
166 virtual int run(
int argc,
char* argv[]) = 0;
309 static void holdInterruptCallback(
int);
310 static void destroyOnInterruptCallback(
int);
311 static void shutdownOnInterruptCallback(
int);
312 static void callbackOnInterruptCallback(
int);
314#ifndef ICE_CPP11_MAPPING
#define ICE_API
Definition Config.h:197
#define ICE_INT_VERSION
Definition Config.h:272
#define ICE_ENUM(CLASS, ENUMERATOR)
Definition Config.h:360
#define ICE_CONFIG_FILE_STRING
Definition Initialize.h:22
virtual int doMain(int, char *[], const InitializationData &, Int)
Helper function that implements the application logic.
static void destroyOnInterrupt()
Configures the application to destroy the communicator when one of the monitored signals is raised.
static CommunicatorPtr _communicator
The application's communicator.
Definition Application.h:289
int main(const StringSeq &args, const InitializationData &initData=InitializationData(), int version=30711)
Call this main() from the global main().
virtual void interruptCallback(int signal)
Override this method to provide a custom application interrupt hook.
static Application * _application
The singleton instance.
Definition Application.h:305
static void callbackOnInterrupt()
Configures the application to invoke interruptCallback when a signal occurs, thereby giving the subcl...
virtual int run(int argc, char *argv[])=0
run is given a copy of the remaining argc/argv arguments, after the communicator initialization in th...
static bool _interrupted
True if an interrupt signal was received.
Definition Application.h:273
int main(const StringSeq &args, const std::string &configFile, int version=30711)
Call this main() from the global main().
static CommunicatorPtr communicator()
Obtains the application's Communicator instance.
static IceUtil::Cond _condVar
Used to synchronize the main thread and the CtrlCHandler thread.
Definition Application.h:255
static void releaseInterrupt()
Processes a stored signal (if any) using the current signal handling configuration.
static bool _callbackInProgress
True if a signal handling callback is currently executing.
Definition Application.h:261
int main(int argc, const char *const argv[], const InitializationData &initData=InitializationData(), int version=30711)
Call this main() from the global main().
Application(SignalPolicy policy=SignalPolicy::HandleSignals)
The constructor configures the signal handling behavior.
static void holdInterrupt()
Configures the application to ignore (but remember) a signal.
static bool interrupted()
Indicates whether a signal handler was triggered.
static const char * appName()
Obtains the application name, i.e., argv[0].
static void ignoreInterrupt()
Configures the application to ignore signals.
static IceUtil::Mutex _mutex
Used to synchronize the main thread and the CtrlCHandler thread.
Definition Application.h:250
static void shutdownOnInterrupt()
Configures the application to shut down the communicator when one of the monitored signals is raised.
static bool _destroyed
True if the communicator has been destroyed.
Definition Application.h:267
static std::string _appName
The application's name.
Definition Application.h:281
int main(int argc, const char *const argv[], const std::string &configFile, int version=30711)
Call this main() from the global main().
static SignalPolicy _signalPolicy
The signal-handling policy specified at construction.
Definition Application.h:297
std::function< void(int sig)> CtrlCHandlerCallback
Invoked when a signal occurs.
Definition CtrlCHandler.h:25
Definition BuiltinSequences.h:56
int Int
The mapping for the Slice int type.
Definition Config.h:54
::std::vector<::std::string > StringSeq
A sequence of strings.
Definition BuiltinSequences.h:96
SignalPolicy
Determines how the Application class handles signals.
Definition Application.h:27
@ NoSignalHandling
Disables signal handling, meaning signals retain their default behavior.
Definition Application.h:31
@ HandleSignals
Enables signal handling.
Definition Application.h:29
Encapsulates data to initialize a communicator.
Definition Initialize.h:279