Ice 3.7 C++11 API Reference
|
Singleton helper class that simplifies Ice initialization, finalization and signal handling. More...
#include <Ice/Ice.h>
Public Member Functions | |
Application (SignalPolicy policy=SignalPolicy ::HandleSignals) | |
The constructor configures the signal handling behavior. More... | |
virtual void | interruptCallback (int signal) |
Override this method to provide a custom application interrupt hook. More... | |
int | main (const StringSeq &args, const InitializationData &initData=InitializationData(), int version=30710) |
Call this main() from the global main(). More... | |
int | main (const StringSeq &args, const std::string &configFile, int version=30710) |
Call this main() from the global main(). More... | |
int | main (int argc, const char *const argv[], const InitializationData &initData=InitializationData(), int version=30710) |
Call this main() from the global main(). More... | |
int | main (int argc, const char *const argv[], const std::string &configFile, int version=30710) |
Call this main() from the global main(). More... | |
virtual int | run (int argc, char *argv[])=0 |
run is given a copy of the remaining argc/argv arguments, after the communicator initialization in the caller (main) has removed all Ice-related arguments. More... | |
virtual | ~Application () |
Static Public Member Functions | |
static const char * | appName () |
Obtains the application name, i.e., argv[0]. More... | |
static void | callbackOnInterrupt () |
Configures the application to invoke interruptCallback when a signal occurs, thereby giving the subclass responsibility for handling the signal. More... | |
static CommunicatorPtr | communicator () |
Obtains the application's Communicator instance. More... | |
static void | destroyOnInterrupt () |
Configures the application to destroy the communicator when one of the monitored signals is raised. More... | |
static void | holdInterrupt () |
Configures the application to ignore (but remember) a signal. More... | |
static void | ignoreInterrupt () |
Configures the application to ignore signals. More... | |
static bool | interrupted () |
Indicates whether a signal handler was triggered. More... | |
static void | releaseInterrupt () |
Processes a stored signal (if any) using the current signal handling configuration. More... | |
static void | shutdownOnInterrupt () |
Configures the application to shut down the communicator when one of the monitored signals is raised. More... | |
Protected Member Functions | |
virtual int | doMain (int, char *[], const InitializationData &, Int) |
Helper function that implements the application logic. More... | |
Static Protected Attributes | |
static Application * | _application |
The singleton instance. More... | |
static std::string | _appName |
The application's name. More... | |
static bool | _callbackInProgress |
True if a signal handling callback is currently executing. More... | |
static CommunicatorPtr | _communicator |
The application's communicator. More... | |
static IceUtil::Cond | _condVar |
Used to synchronize the main thread and the CtrlCHandler thread. More... | |
static bool | _destroyed |
True if the communicator has been destroyed. More... | |
static bool | _interrupted |
True if an interrupt signal was received. More... | |
static IceUtil::Mutex | _mutex |
Used to synchronize the main thread and the CtrlCHandler thread. More... | |
static SignalPolicy | _signalPolicy |
The signal-handling policy specified at construction. More... | |
Singleton helper class that simplifies Ice initialization, finalization and signal handling.
An application uses this class by writing a subclass and implementing the run method.
Ice::Application::Application | ( | SignalPolicy | policy = SignalPolicy ::HandleSignals | ) |
The constructor configures the signal handling behavior.
policy | Specifies whether to handle signals. If not specified, the default behavior is to handle signals. |
|
virtual |
|
static |
Obtains the application name, i.e., argv[0].
|
static |
Configures the application to invoke interruptCallback when a signal occurs, thereby giving the subclass responsibility for handling the signal.
|
static |
Obtains the application's Communicator instance.
One limitation of this class is that there can only be one Application instance, with one global Communicator, accessible with this communicator() operation. This limitation is due to how the signal handling functions below operate. If you require multiple Communicators, then you cannot use this Application framework class.
|
static |
Configures the application to destroy the communicator when one of the monitored signals is raised.
This is the default behavior.
|
protectedvirtual |
Helper function that implements the application logic.
Reimplemented in Glacier2::Application.
|
static |
Configures the application to ignore (but remember) a signal.
A stored signal (if any) can be handled later by calling releaseInterrupt.
|
static |
Configures the application to ignore signals.
|
virtual |
Override this method to provide a custom application interrupt hook.
You must call callbackOnInterrupt for this method to be called. Note that the interruptCallback can be called concurrently with any other thread (including main) in your application and thus must take appropriate concurrency precautions.
signal | The signal identifier. |
|
static |
Indicates whether a signal handler was triggered.
This can be used once Communicator::waitForShutdown() returns to test whether the shutdown was due to an interrupt (returns true) or because Communicator::shutdown() was called (returns false).
int Ice::Application::main | ( | const StringSeq & | args, |
const InitializationData & | initData = InitializationData() , |
||
int | version = 30710 |
||
) |
Call this main() from the global main().
main() initializes the Communicator, calls run() and destroys the the Communicator upon return from run(). It handles all exceptions properly, i.e., error message are printed if exceptions propagate to main(), and the Communicator is always destroyed, regardless of exceptions.
args | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
int Ice::Application::main | ( | const StringSeq & | args, |
const std::string & | configFile, | ||
int | version = 30710 |
||
) |
Call this main() from the global main().
main() initializes the Communicator, calls run() and destroys the the Communicator upon return from run(). It handles all exceptions properly, i.e., error message are printed if exceptions propagate to main(), and the Communicator is always destroyed, regardless of exceptions.
args | The command-line arguments. |
configFile | The name of an Ice configuration file. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
int Ice::Application::main | ( | int | argc, |
const char *const | argv[], | ||
const InitializationData & | initData = InitializationData() , |
||
int | version = 30710 |
||
) |
Call this main() from the global main().
main() initializes the Communicator, calls run() and destroys the the Communicator upon return from run(). It handles all exceptions properly, i.e., error message are printed if exceptions propagate to main(), and the Communicator is always destroyed, regardless of exceptions.
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
initData | Configuration data for the new Communicator. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
int Ice::Application::main | ( | int | argc, |
const char *const | argv[], | ||
const std::string & | configFile, | ||
int | version = 30710 |
||
) |
Call this main() from the global main().
main() initializes the Communicator, calls run() and destroys the the Communicator upon return from run(). It handles all exceptions properly, i.e., error message are printed if exceptions propagate to main(), and the Communicator is always destroyed, regardless of exceptions.
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
configFile | The name of an Ice configuration file. |
version | Indicates the Ice version with which the application is compatible. If not specified, the version of the Ice installation is used. |
|
static |
Processes a stored signal (if any) using the current signal handling configuration.
|
pure virtual |
run is given a copy of the remaining argc/argv arguments, after the communicator initialization in the caller (main) has removed all Ice-related arguments.
argc | Specifies the number of arguments in argv. |
argv | The command-line arguments. |
|
static |
Configures the application to shut down the communicator when one of the monitored signals is raised.
|
staticprotected |
|
staticprotected |
|
staticprotected |
True if a signal handling callback is currently executing.
Can change while run() and communicator->destroy() are running!
|
staticprotected |
|
staticprotected |
Used to synchronize the main thread and the CtrlCHandler thread.
|
staticprotected |
True if the communicator has been destroyed.
Can change while run() and communicator->destroy() are running!
|
staticprotected |
True if an interrupt signal was received.
Can change while run() and communicator->destroy() are running!
|
staticprotected |
Used to synchronize the main thread and the CtrlCHandler thread.
|
staticprotected |