ultimatepp/bazaar/Signals/Signals.h
micio b0342fe8d3 updated Signals package
git-svn-id: svn://ultimatepp.org/upp/trunk@588 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2008-11-01 15:59:09 +00:00

62 lines
1.3 KiB
C++

#ifndef _Signals_Signals_h_
#define _Signals_Signals_h_
#include <CtrlCore/CtrlCore.h>
using namespace Upp;
class TSignals
{
friend TSignals &Signals(void);
friend void ::_SignalHandler(int, siginfo_t *, void *);
private:
// flag indicating that the process instance has been stored on file
bool StoredInstance;
String LockName;
// signal/handlers map
ArrayMap<int, Callback> CallbackMap;
// costruttore
TSignals();
// dispatch signals
void Dispatch(int sig, siginfo_t *info, void *v);
// creates lock file name based on user name, app name and display
String CreateLockName(void);
public:
// distruttore
~TSignals();
// add a signal handler
bool Handle(int sig, Callback const &cb);
// removes a signal handler
bool Unhandle(int sig);
// stores process info on filesystem
// allowing other process to communicate with it
bool StoreInstance(void);
// checks whether another instance of this process is running
bool IsOtherInstanceRunning(void);
// sends a signal to another process
bool Send(int sig, int procId);
// sends a signal to another running instance of this app
bool Send(int sig);
}; // END Class TSignals
////////////////////////////////////////////////////////////////////////////////////
// Global signals access
TSignals &Signals(void);
#endif