// $Id: RtclSignalAction.hpp 521 2013-05-20 22:16:45Z mueller $
|
// $Id: RtclSignalAction.hpp 521 2013-05-20 22:16:45Z mueller $
|
//
|
//
|
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
//
|
//
|
// This program is free software; you may redistribute and/or modify it under
|
// This program is free software; you may redistribute and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
// Software Foundation, either version 2, or at your option any later version.
|
// Software Foundation, either version 2, or at your option any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but
|
// This program is distributed in the hope that it will be useful, but
|
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for complete details.
|
// for complete details.
|
//
|
//
|
// Revision History:
|
// Revision History:
|
// Date Rev Version Comment
|
// Date Rev Version Comment
|
// 2013-05-17 521 1.0 Initial version
|
// 2013-05-17 521 1.0 Initial version
|
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
|
|
/*!
|
/*!
|
\file
|
\file
|
\version $Id: RtclSignalAction.hpp 521 2013-05-20 22:16:45Z mueller $
|
\version $Id: RtclSignalAction.hpp 521 2013-05-20 22:16:45Z mueller $
|
\brief Declaration of class RtclSignalAction.
|
\brief Declaration of class RtclSignalAction.
|
*/
|
*/
|
|
|
#ifndef included_Retro_RtclSignalAction
|
#ifndef included_Retro_RtclSignalAction
|
#define included_Retro_RtclSignalAction 1
|
#define included_Retro_RtclSignalAction 1
|
|
|
// Note: on cpp environment _POSIX_C_SOURCE is already defined !!
|
// Note: on cpp environment _POSIX_C_SOURCE is already defined !!
|
#include <signal.h>
|
#include <signal.h>
|
|
|
#include "tcl.h"
|
#include "tcl.h"
|
|
|
#include "librtools/RerrMsg.hpp"
|
#include "librtools/RerrMsg.hpp"
|
#include "librtools/Rexception.hpp"
|
#include "librtools/Rexception.hpp"
|
#include "librtcltools/RtclOPtr.hpp"
|
#include "librtcltools/RtclOPtr.hpp"
|
|
|
namespace Retro {
|
namespace Retro {
|
|
|
class RtclSignalAction {
|
class RtclSignalAction {
|
public:
|
public:
|
|
|
static bool Init(Tcl_Interp* interp, RerrMsg& emsg);
|
static bool Init(Tcl_Interp* interp, RerrMsg& emsg);
|
static RtclSignalAction* Obj();
|
static RtclSignalAction* Obj();
|
|
|
bool SetAction(int signum, Tcl_Obj* pobj, RerrMsg& emsg);
|
bool SetAction(int signum, Tcl_Obj* pobj, RerrMsg& emsg);
|
bool GetAction(int signum, Tcl_Obj*& pobj, RerrMsg& emsg);
|
bool GetAction(int signum, Tcl_Obj*& pobj, RerrMsg& emsg);
|
bool ClearAction(int signum, RerrMsg& emsg);
|
bool ClearAction(int signum, RerrMsg& emsg);
|
|
|
protected:
|
protected:
|
bool ValidSignal(int signum, RerrMsg& emsg);
|
bool ValidSignal(int signum, RerrMsg& emsg);
|
void TclChannelHandler(int mask);
|
void TclChannelHandler(int mask);
|
static void SignalHandler(int signum);
|
static void SignalHandler(int signum);
|
static void ThunkTclChannelHandler(ClientData cdata, int mask);
|
static void ThunkTclChannelHandler(ClientData cdata, int mask);
|
static void ThunkTclExitProc(ClientData cdata);
|
static void ThunkTclExitProc(ClientData cdata);
|
|
|
private:
|
private:
|
RtclSignalAction(Tcl_Interp* interp);
|
RtclSignalAction(Tcl_Interp* interp);
|
~RtclSignalAction();
|
~RtclSignalAction();
|
|
|
protected:
|
protected:
|
Tcl_Interp* fpInterp; //!< Tcl interpreter used
|
Tcl_Interp* fpInterp; //!< Tcl interpreter used
|
int fFdPipeRead; //!< attn pipe read fd
|
int fFdPipeRead; //!< attn pipe read fd
|
int fFdPipeWrite; //!< attn pipe write fd
|
int fFdPipeWrite; //!< attn pipe write fd
|
Tcl_Channel fShuttleChn; //!< Tcl channel
|
Tcl_Channel fShuttleChn; //!< Tcl channel
|
bool fActionSet[32]; //!< true if SetAction() done
|
bool fActionSet[32]; //!< true if SetAction() done
|
RtclOPtr fpScript[32]; //!< action scripts
|
RtclOPtr fpScript[32]; //!< action scripts
|
struct sigaction fOldAction[32]; //!< original sigaction
|
struct sigaction fOldAction[32]; //!< original sigaction
|
|
|
private:
|
private:
|
static RtclSignalAction* fpObj; //!< pointer to singleton
|
static RtclSignalAction* fpObj; //!< pointer to singleton
|
};
|
};
|
|
|
} // end namespace Retro
|
} // end namespace Retro
|
|
|
//#include "RtclSignalAction.ipp"
|
//#include "RtclSignalAction.ipp"
|
|
|
#endif
|
#endif
|
|
|