Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

agwsCMD_HANDLER.h

Go to the documentation of this file.
00001 #ifndef agwsCMD_HANDLER_H
00002 #define agwsCMD_HANDLER_H
00003 /******************************************************************************
00004 * E.S.O. - VLT project
00005 *
00006 * "@(#) $Id: agwsCMD_HANDLER.h,v 1.182 2003/11/12 08:34:11 vltsccm Exp $"
00007 *
00008 * who       when      what
00009 * --------  --------  --------------------------------------------------------
00010 * rkarban  01/07/98  add attribute replyInternally
00011 * rkarban  01/07/98  add to SendInternal loopSafe parameter
00012 * rkarban  01/07/98  remove method Revert2ExternalCall
00013 * rkarban  24/06/98  add method+attribute OriginIsExtern
00014 * rkarban  24/06/98  add member orgExtMsg+access methods+method Revert2ExternalCall
00015 * gchiozzi  14/11/97  Added CmdMsg() method.
00016 * gchiozzi  13/10/97  Renamed PUSH_MODE as CMD_MODE
00017 * gchiozzi  03/10/97  Implemented agwsCMD_DICT and static SendInternal()
00018 * gchiozzi  01/10/97  made RegResetHandler a stati method.
00019 * gchiozzi  05/08/97  Restructured
00020 * nfiebig   28/06/96  created
00021 */
00022 
00023 /******************************************************************************
00024  * Declaration of the agwsCMD_HANDLER class.
00025  *-----------------------------------------------------------------------------
00026  */
00027 
00028 #ifndef __cplusplus
00029 #error This is a C++ include file and cannot be used from plain C
00030 #endif
00031 
00032 /*
00033  * module includes
00034  */
00035 #include "agws.h"
00036 #include "agwsSTATE.h"
00037 
00038 /*
00039  * evh toolkit includes
00040  */
00041 #include "evhTASK.h"
00042 #include "evhSTD_COMMANDS.h"
00043 
00044 enum agwsCMD_MODE
00045 {
00046     agwsCMD_NONE,            // command not active
00047     agwsCMD_ACCEPTED,        // command accepted, possibly in parallel with others
00048     agwsCMD_REJECTED,        // command rejected
00049     agwsCMD_PREV_ABORTED,    // command accepted aborting a previous one
00050     agwsCMD_PREV_OVERRIDDEN  // command accepted overriding a previous one
00051 };
00052 
00053 class agwsCMD_HANDLER;
00054 
00055 class agwsCMD_DICT: public fndDICTIONARY, virtual public eccsERROR_CLASS
00056 {
00057   public:
00058 
00059     agwsCMD_DICT(const unsigned sz = fndDEFAULT_DICT_SIZE ):
00060   fndDICTIONARY(sz) { DelItemsOnDelete(); }
00061 
00062     virtual ccsCOMPL_STAT    AddCmdHandler(const char *cmd,
00063            agwsCMD_HANDLER &handler);
00064     virtual ccsCOMPL_STAT    DelCmdHandler(const char *cmd);
00065     virtual agwsCMD_HANDLER &Lookup(const char *cmd);
00066 
00067     fndStdObjectDef(agwsCMD_DICT, fndDICTIONARY);
00068 
00069   protected:
00070 
00071 }; /* end class evhCALLBACK_DICT */
00072 
00073 
00074 typedef evhCB_COMPL_STAT 
00075               (fndOBJECT::*agwsCMD_METHOD)(msgMESSAGE &, agwsCMD_HANDLER &);
00076 
00077 class agwsCMD_HANDLER : public evhSIMPLE_TASK
00078 {
00079   public:
00080     agwsCMD_HANDLER(const msgCMD command, 
00081         const evhCALLBACK &cb);
00082     agwsCMD_HANDLER(const msgCMD         command,
00083                     fndOBJECT           *obj,
00084         const agwsCMD_METHOD procedure);
00085 
00086     virtual ~agwsCMD_HANDLER();
00087 
00088     vltLOGICAL       CmdActive()    const;
00089     char *           CmdBuffer()    const;
00090     agwsCMD_MODE     CmdMode()      const;
00091     msgMESSAGE      &CmdMsg();             // originator command message
00092     msgMESSAGE      &CmdExtMsg();
00093     vltLOGICAL       OriginIsExtern(void);
00094 
00095     virtual evhCB_COMPL_STAT CommandCB(msgMESSAGE &msg, void *);
00096 
00097     vltLOGICAL               InternalCall() const;
00098 
00099     virtual ccsCOMPL_STAT    SendReply(const char *buffer, 
00100                msgLENGTH size = 0,
00101                vltLOGICAL last = ccsTRUE);
00102     virtual ccsCOMPL_STAT    SendReply(const ccsERROR &errMsg);
00103     virtual ccsCOMPL_STAT    SendReply(ccsMODULEID moduleId, 
00104                vltINT16 errorNumber, 
00105                ccsLOC_ID  location, ...);
00106 
00107     
00108     static ccsCOMPL_STAT    RegResetHandler(const evhCALLBACK &cb);
00109 
00110     static ccsCOMPL_STAT    SendInternal(msgMESSAGE &msg,
00111            const evhCALLBACK &reply, 
00112            const evhCALLBACK &errReply,
00113            vltLOGICAL loopSafe = ccsFALSE);
00114     ccsCOMPL_STAT           Reset();
00115 
00116   protected:
00117     virtual ccsCOMPL_STAT    AcceptCommand(msgMESSAGE &msg);
00118     virtual ccsCOMPL_STAT    CheckState(const char *cmd);
00119 
00120     virtual ccsCOMPL_STAT    IntCommand(msgMESSAGE &msg,
00121           const evhCALLBACK &reply, 
00122           const evhCALLBACK &errReply,
00123           vltLOGICAL loopSafe);
00124 
00125     ccsCOMPL_STAT RegCommandCB(const evhCALLBACK &cb);
00126     ccsCOMPL_STAT RegReplyHandlers(const evhCALLBACK &reply, 
00127            const evhCALLBACK &errReply);
00128 
00129   private:
00130     msgCMD        command;         // name of command handled by this instance
00131     msgMESSAGE    orgMsg;          // originator command message
00132     msgMESSAGE    orgExtMsg;       // originator external command message
00133     evhCALLBACK  *applCmdCB;       // application command call-back
00134     evhCALLBACK  *applReplyCB;     // reply handler for internal calls
00135     evhCALLBACK  *applErrorCB;     // error reply handler for internal calls
00136     vltLOGICAL    internalCall;    // flag if called from internally
00137     vltLOGICAL    replyInternally; // flag if we have to reply internally
00138     vltLOGICAL    cmdActive;       // flag if a command is active
00139     agwsSTATE     state;           // state handling object
00140     agwsCMD_MODE  cmdMode;         // mode of successive command handling
00141     vltLOGICAL    originIsExtern;
00142 
00143     // the following static members are defined in agwsCMD_HANDLER.C
00144     static vltLOGICAL       parActive;   // flag if a parallel command is active
00145     static agwsCMD_HANDLER *parCmd;      // currently active parallel command
00146 
00147     static vltLOGICAL       exclActive;  // flag if an exclusive command is active
00148     static agwsCMD_HANDLER *exclCmd;     // currently active exclusive command
00149 
00150     static evhCALLBACK     *resetHandler; // general reset handler
00151 
00152     static agwsCMD_DICT     intCommands;    // Dictionary of registered commands
00153 };
00154 
00155 #endif 

Generated on Wed Dec 3 14:52:05 2003 for ATCS API by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001