Ice 3.7 C++11 API Reference
CtrlCHandler.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_UTIL_CTRL_C_HANDLER_H
6 #define ICE_UTIL_CTRL_C_HANDLER_H
7 
8 #include <IceUtil/Config.h>
9 #include <IceUtil/Exception.h>
10 
11 namespace IceUtil
12 {
13 
20 #ifdef ICE_CPP11_MAPPING
21 using CtrlCHandlerCallback = std::function<void(int sig)>;
22 #else
23 typedef void (*CtrlCHandlerCallback)(int sig);
24 #endif
25 
34 {
35 public:
36 
47 
58 
65 
71 };
72 
78 class ICE_API CtrlCHandlerException : public ExceptionHelper<CtrlCHandlerException>
79 {
80 public:
81 
82  CtrlCHandlerException(const char*, int);
83  virtual std::string ice_id() const;
84 
85 #ifndef ICE_CPP11_MAPPING
86  virtual CtrlCHandlerException* ice_clone() const;
87 #endif
88 };
89 
90 }
91 
92 #endif
IceUtil::CtrlCHandler
Provides a portable way to handle Ctrl-C and Ctrl-C like signals.
Definition: CtrlCHandler.h:34
IceUtil::CtrlCHandlerCallback
std::function< void(int sig)> CtrlCHandlerCallback
Invoked when a signal occurs.
Definition: CtrlCHandler.h:21
IceUtil::CtrlCHandler::getCallback
CtrlCHandlerCallback getCallback() const
Obtains the signal callback.
IceUtil::CtrlCHandler::CtrlCHandler
CtrlCHandler(CtrlCHandlerCallback cb=nullptr)
Registers a callback function that handles Ctrl-C like signals.
IceUtil::CtrlCHandlerException::ice_id
virtual std::string ice_id() const
Returns the type ID of this exception.
IceUtil::CtrlCHandlerException
Raised by the CtrlCHandler constructor if another CtrlCHandler already exists.
Definition: CtrlCHandler.h:79
IceUtil
Definition: Optional.h:1095
ICE_API
#define ICE_API
Definition: Config.h:197
ICE_NULLPTR
#define ICE_NULLPTR
Definition: Config.h:362
IceUtil::CtrlCHandlerException::CtrlCHandlerException
CtrlCHandlerException(const char *, int)
Exception.h
Config.h
IceUtil::CtrlCHandler::setCallback
CtrlCHandlerCallback setCallback(CtrlCHandlerCallback cb)
Replaces the signal callback.
IceUtil::CtrlCHandler::~CtrlCHandler
~CtrlCHandler()
Unregisters the callback function.
IceUtil::ExceptionHelper
Helper template for the implementation of Ice::Exception.
Definition: Exception.h:128