Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_Scenario.hpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #ifndef _C_SCENARIO_H
00021 #define _C_SCENARIO_H
00022 
00023 #include "iostream_t.hpp"
00024 #include "list_t.hpp"
00025 #include "map_t.hpp"
00026 #include "string_t.hpp"
00027 
00028 #include "C_MessageFrame.hpp"
00029 
00030 #include "C_CallContext.hpp"
00031 
00032 #include "C_ProtocolFrame.hpp"
00033 
00034 #include "C_GeneratorStats.hpp"
00035 #include "C_DataLogControl.hpp"
00036 
00037 #include "C_GeneratorConfig.hpp"
00038 
00039 #include "C_ChannelControl.hpp"
00040 
00041 #include "C_ExternalDataControl.hpp"
00042 #include "C_ScenarioStats.hpp"
00043 
00044 #include "C_RegExp.hpp"
00045 #include "ExternalMethod.h"
00046 
00047 
00048 
00049 // STRING related types
00050 typedef enum _enum_exe_code {
00051   E_EXE_NOERROR = 0,
00052 
00053   E_EXE_TRAFFIC_END,
00054   E_EXE_DEFAULT_END,
00055   E_EXE_ABORT_END,
00056 
00057   E_EXE_INIT_END,
00058   E_EXE_ERROR_MSG,
00059   E_EXE_ERROR_SEND,
00060   E_EXE_ERROR_CHECK,
00061   E_EXE_SUSPEND,
00062   E_EXE_IGNORE,
00063   E_EXE_ABORT_CHECK,
00064   E_EXE_ERROR
00065 } T_exeCode ;
00066 
00067 typedef enum _action_scenario_type {
00068    E_ACTION_SCEN_OPEN= 0,
00069    E_ACTION_SCEN_CLOSE,
00070    E_ACTION_SCEN_MEMORY_STORE,
00071    E_ACTION_SCEN_MEMORY_RESTORE,
00072    E_ACTION_SCEN_START_TIMER,
00073    E_ACTION_SCEN_STOP_TIMER,
00074    E_ACTION_SCEN_SET_VALUE,
00075    E_ACTION_SCEN_INC_COUNTER,
00076    E_ACTION_SCEN_CHECK_PRESENCE,
00077    E_ACTION_SCEN_GET_EXTERNAL_DATA,
00078    E_ACTION_SCEN_INC_VAR,
00079    E_ACTION_SCEN_CHECK_VALUE,
00080    E_ACTION_SCEN_CHECK_ORDER,
00081    E_ACTION_SCEN_SET_NEW_SESSION_ID,
00082    E_ACTION_SCEN_TRANSPORT_OPTION,
00083    E_ACTION_SCEN_SET_BIT,
00084    E_ACTION_SCEN_SET_VALUE_BIT,
00085 
00086    E_NB_ACTION_SCEN,  // internal actions after this value
00087    E_ACTION_SCEN_INTERNAL_INIT_DONE,
00088    E_ACTION_SCEN_CHECK_ALL_MSG,
00089    E_ACTION_SCEN_ADD_IN_CALL_MAP,
00090    E_ACTION_SCEN_SELECT_EXTERNAL_DATA_LINE,
00091    E_ACTION_SCEN_GET_EXTERNAL_DATA_TO_MEM,
00092    E_ACTION_SCEN_SET_VALUE_METHOD_EXTERN
00093 
00094 }  T_action_type,
00095   *T_pAction_type ;
00096 
00097 typedef enum _enum_string_type {
00098   E_STR_STATIC,
00099   E_STR_COUNTER,
00100   E_STR_MEMORY
00101 } T_ValueStringType ;
00102 
00103 typedef struct _union_string_data {
00104   int   m_id ;
00105   char *m_value ;
00106 } T_ValueStringData, *T_pValueStringData ;
00107 
00108 typedef struct _struct_string_portion {
00109   T_ValueStringType m_type ;
00110   T_ValueStringData m_data ;
00111 } T_StringValue, *T_pStringValue ;
00112 
00113 typedef struct _struct_string_express {
00114   int            m_nb_portion ;
00115   T_pStringValue m_portions ;
00116 } T_StringExpression, *T_pStringExpression ;
00117 
00118 typedef struct _xml_cmd_action {
00119   T_action_type       m_type            ;
00120   char               *m_args            ;
00121   int                 m_id              ;
00122   int                 m_mem_id          ;
00123   int                 m_instance_id     ; // instance number 
00124   int                 m_sub_id          ; // id used when header body access
00125   int                 m_begin           ; // start of storage
00126   int                 m_size            ; // size of storage
00127   unsigned char      *m_pattern         ;
00128   int                 m_pattern_size    ;
00129   int                 m_position        ;
00130   T_pStringExpression m_string_expr     ;
00131   T_CheckBehaviour    m_check_behaviour ;
00132   int                 m_field_data_num  ;
00133   C_RegExp           *m_regexp_data     ;
00134   T_ExternalMethod    m_external_method ;
00135 } T_CmdAction, *T_pCmdAction ;
00136 
00137 typedef list_t<T_pCmdAction> T_CmdActionList, 
00138                                *T_pCmdActionList ;
00139 
00140 
00141 typedef enum _enum_behaviour_scenario {
00142 
00143   E_BEHAVIOUR_SCEN_SUCCESS,
00144   E_BEHAVIOUR_SCEN_FAILED,
00145   E_BEHAVIOUR_SCEN_IGNORE
00146 }  T_BehaviourScenario, 
00147   *T_pBehaviourScenario ;
00148 
00149 
00150 typedef enum _cmd_scenario_type {
00151    E_CMD_SCEN_SEND = 0,
00152    E_CMD_SCEN_RECEIVE,
00153    E_CMD_SCEN_WAIT,
00154    E_CMD_SCEN_END,
00155    E_NB_CMD_SCEN
00156 }  T_cmd_type,
00157   *T_pCmd_type ;
00158 
00159 
00160 extern const char* command_name_table [] ;
00161 extern const char* action_name_table [] ;
00162 
00163 typedef struct _action_regexp_str_t {
00164   // char *m_name ;
00165   char *m_expr      ;
00166   int   m_nb_match  ; 
00167   int   m_sub_match ; 
00168   int   m_line      ;     
00169 } T_ActionRegExpStr, *T_pActionRegExpStr ;
00170 
00171 class C_CommandAction ;
00172 
00173 typedef struct _xml_cmd_scenario {
00174 
00175   T_cmd_type           m_type           ;
00176   C_MessageFrame      *m_message        ;
00177   unsigned long        m_duration       ;
00178   unsigned long        m_duration_index ;
00179 
00180   int                  m_channel_id     ;
00181 
00182   int                  m_pre_action     ;
00183   int                  m_post_action    ;
00184 
00185   C_CommandAction**    m_pre_action_table ;
00186   C_CommandAction**    m_post_action_table ;
00187 
00188   unsigned long        m_retrans_delay  ;
00189   unsigned long        m_retrans_index  ;
00190   unsigned long        m_retrans_delay_index  ;
00191 
00192 }  T_cmd_scenario,
00193   *T_pCmd_scenario ;
00194 
00195 class C_ScenarioControl ;
00196 
00197 class C_Scenario {
00198 
00199 public:
00200 
00201   C_Scenario(C_ScenarioControl     *P_scenario_control,
00202              C_ChannelControl      *P_channel_control,
00203              C_ExternalDataControl *P_external_data_control,
00204              T_exeCode              P_exe_code,      
00205              char                  *P_behaviour,
00206              bool                   P_retrans_enabled,
00207              unsigned int           P_check_mask     = 0, 
00208              T_CheckBehaviour       P_checkBehaviour 
00209              = E_CHECK_BEHAVIOUR_WARNING
00210              );
00211   ~C_Scenario();
00212 
00213   void set_size (size_t P_size);
00214 
00215   void set_data_log_controller (C_DataLogControl *P_log);
00216 
00217   size_t add_cmd  (T_cmd_type          P_type,
00218                    int                 P_channel_id,
00219                    T_pC_MessageFrame   P_msg,
00220                    int                 P_nb_pre_action,
00221                    C_CommandAction**   P_pre_act_table,
00222                    unsigned long       P_retrans_delay);
00223 
00224 
00225   // define post actions for the last command added
00226   size_t define_post_actions (int          P_nb_post_action,
00227                               C_CommandAction** P_post_act_table) ;
00228   size_t define_pre_actions (int          P_nb_pre_action,
00229                              C_CommandAction** P_pre_act_table) ;
00230 
00231 
00232   size_t add_cmd  (T_cmd_type    P_type,
00233                    unsigned long P_duration);
00234   size_t add_cmd  (T_cmd_type    P_type);
00235 
00236   bool check_msg_received (T_pReceiveMsgContext P_rcvMsg) ;
00237 
00238   T_exeCode          execute_cmd (T_pCallContext P_callCtxt, 
00239                                   bool P_resume);
00240 
00241   T_CallContextState first_state();
00242 
00243   T_exeCode          execute_cmd_retrans (int P_index, T_pCallContext P_callCtxt);
00244   void update_retrans_delay_cmd (size_t P_nb, unsigned long *P_table) ;
00245 
00246   void update_wait_cmd (size_t P_nb, unsigned long *P_table) ;
00247 
00248   friend iostream_output& operator<<(iostream_output&, C_Scenario&);
00249 
00250   void set_stats(C_ScenarioStats *P_scenStat) ;
00251   C_ScenarioStats* get_stats();
00252   void delete_stats () ;
00253 
00254   T_exeCode    get_exe_end_code()  ;
00255 
00256   int                  get_nb_retrans();
00257 
00258   int                  get_nb_recv_per_scen () ;
00259 
00260   int                  get_nb_send_per_scen () ;
00261 
00262 
00263 
00264   T_pCmd_scenario      get_commands() ;
00265 
00266   friend class C_ScenarioStats ;
00267 
00268 private:
00269 
00270   typedef map_t<string_t, int> T_MemoryIdMap, *T_pMemoryIdMap ; 
00271 
00272   int              m_sequence_max  ;
00273   int              m_sequence_size ;
00274   T_pCmd_scenario  m_cmd_sequence  ;
00275   C_GeneratorStats *m_stat          ;
00276 
00277   C_DataLogControl *m_log            ;
00278   C_ExternalDataControl  *m_external_data ;
00279 
00280   unsigned int     m_check_mask      ;
00281   T_CheckBehaviour m_check_behaviour ;
00282 
00283   C_ScenarioControl *m_controller    ;
00284   C_ChannelControl  *m_channel_ctrl  ;
00285   C_ScenarioStats   *m_stats         ;
00286   T_exeCode          m_exe_end_code  ;
00287 
00288 
00289   T_exeCode          execute_action (T_pCmd_scenario      P_pCmd,
00290                                      T_pCallContext       P_callCtxt,
00291                                      C_MessageFrame      *P_msg,
00292                                      int                  P_nbActions,
00293                                      C_CommandAction**    P_actions,
00294                                      C_MessageFrame      *P_ref);
00295 
00296   void delete_post_actions (int P_cmd_index);
00297 
00298   T_BehaviourScenario m_behaviour ;
00299 
00300   bool                  m_retrans_enabled  ;
00301   int                   m_nb_retrans            ;
00302 
00303 
00304   int                   m_nb_send_per_scene   ;
00305   int                   m_nb_recv_per_scene   ;
00306 
00307 } ;
00308 
00309 typedef C_Scenario *T_pC_Scenario ;
00310 
00311 #endif // _C_SCENARIO_H
00312 
00313 
00314 
00315 
00316 
00317 

Generated on Wed Mar 7 14:44:57 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002