Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_ScenarioControl.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_CONTROL_H
00021 #define _C_SCENARIO_CONTROL_H
00022 
00023 #include "iostream_t.hpp"
00024 #include "map_t.hpp"
00025 #include "set_t.hpp"
00026 #include "string_t.hpp"
00027 
00028 #include "C_GeneratorConfig.hpp"
00029 #include "GeneratorXmlData.hpp"
00030 #include "C_XmlData.hpp"
00031 #include "C_Scenario.hpp"
00032 #include "TrafficType.h"
00033 
00034 #include "C_ProtocolControl.hpp"
00035 #include "C_TransportControl.hpp"
00036 #include "C_ChannelControl.hpp"
00037 
00038 #include "C_DataLogControl.hpp"
00039 
00040 #include "C_ExternalDataControl.hpp"
00041 #include "C_CommandActionFactory.hpp"
00042 
00043 
00044 typedef struct _counter_def_t {
00045   int                 m_id    ;
00046   char               *m_name  ;
00047   T_UnsignedInteger32 m_init  ;
00048   T_UnsignedInteger32 m_value ;
00049 } T_CounterDef, *T_pCounterDef ;
00050 
00051 typedef set_t<unsigned long> T_waitValuesSet, *T_pWaitValuesSet ;
00052 typedef set_t<unsigned long> T_retransDelayValuesSet, *T_pRetransDelayValuesSet ;
00053 
00054 class C_ReadControl ; // prevent from circular include
00055 
00056 class C_CommandAction ; 
00057 
00058 typedef list_t<C_CommandAction *> T_CommandActionLst, 
00059   *T_pCommandActionLst ;
00060 
00061 
00062 class C_ScenarioControl {
00063 public:
00064    C_ScenarioControl(C_ProtocolControl  *P_protocol_control,
00065                      C_TransportControl *P_transport_control,
00066                      C_ChannelControl   *P_channel_control);
00067   ~C_ScenarioControl();
00068 
00069   typedef enum _enum_scen_type {
00070     E_SCENARIO_TRAFFIC = 0 ,
00071     E_SCENARIO_DEFAULT,
00072     E_SCENARIO_INIT,
00073     E_SCENARIO_ABORT
00074   } T_scenario_type, T_pScenario_type ;
00075 
00076   void set_data_log_controller (C_DataLogControl *P_log);
00077 
00078   void set_external_data_controller (C_ExternalDataControl *P_external_data);
00079   bool external_data_used() ;
00080 
00081   bool fromXml (C_XmlData *P_data, 
00082                 bool  P_check_msg,
00083                 bool *P_data_mesure,
00084                 T_pTrafficType P_traffic_type,
00085                 bool  *P_action_check_abort);
00086   
00087   T_pC_Scenario find_scenario (T_pReceiveMsgContext P_rcvMsg);
00088   T_pC_Scenario find_default_scenario (T_pReceiveMsgContext P_rcvMsg);
00089 
00090   T_pC_Scenario get_init_scenario () ;
00091   T_pC_Scenario get_traffic_scenario () ;
00092 
00093   T_pC_Scenario get_abort_scenario () ;
00094   T_pC_Scenario get_default_scenario (int L_index) ;
00095 
00096   T_pC_Scenario outgoing_scenario () ;
00097   T_pC_Scenario init_scenario_defined (T_pTrafficType P_type) ;
00098 
00099   void set_default_scenarii(int P_nb) ;
00100   void switch_to_init() ;
00101   void switch_to_traffic();
00102 
00103   void set_config (C_GeneratorConfig *P_config);
00104 
00105   int  memory_used () ; 
00106 
00107   T_pWaitValuesSet get_wait_values () ;
00108   T_pRetransDelayValuesSet get_retrans_delay_values () ;
00109   void             update_wait_cmd (size_t P_nb, unsigned long *P_table);
00110 
00111   void  update_retrans_delay_cmd (size_t P_nb, unsigned long *P_table);
00112 
00113   friend iostream_output& operator<<(iostream_output&, C_ScenarioControl&);
00114 
00115   bool                set_counters      (C_XmlData *P_xml_counter_def);
00116   T_UnsignedInteger32 get_counter_value (int P_id);
00117   void                increase_counter  (int P_id);
00118   int                 get_counter_id    (char *P_name);
00119 
00120   int                 get_nb_scenario   ();
00121   int                 get_nb_default_scenario () ;
00122   int                 get_max_nb_retrans () ;
00123   int                 get_max_nb_send () ;
00124   int                 get_max_nb_recv () ;
00125 
00126 
00127 private:
00128 
00129 
00130   // memory store/restore name management
00131   typedef map_t<string_t, int> T_MemoryIdMap, *T_pMemoryIdMap ; 
00132   T_pMemoryIdMap  m_memory_map ;
00133   int             m_memory_max ;
00134 
00135   // counter name management
00136   typedef map_t<string_t, T_pCounterDef> T_CounterMap, *T_pCounterMap ;
00137   T_pCounterMap   m_counter_map   ;
00138   int             m_nb_counter    ;
00139   T_pCounterDef  *m_counter_table ;
00140   
00141 
00142   // traffic scenario management
00143   T_pC_Scenario   m_traffic_scen, m_save_traffic_scen ;
00144   T_TrafficType   m_traffic_type ;
00145 
00146   // nb scenario
00147   int             m_nb_scenario  ;
00148 
00149   // init scenario management
00150   T_pC_Scenario   m_init_scen    ;
00151   T_TrafficType   m_init_type    ;
00152 
00153   // abort scenario management
00154   T_pC_Scenario   m_abort_scen   ;
00155 
00156   bool            m_action_check_abort ;
00157 
00158   // default scenario management
00159   T_pC_Scenario  *m_default_scen ;
00160   int            m_max_default  ;
00161   int            m_nb_default   ;
00162 
00163   // configuration data
00164   C_GeneratorConfig *m_config ;
00165 
00166   // data log control
00167   C_DataLogControl  *m_log ;
00168 
00169   // external data management
00170   C_ExternalDataControl  *m_external_data ;
00171   bool m_external_data_used ;
00172 
00173   unsigned int m_check_level ;
00174   T_CheckBehaviour m_check_behaviour ;
00175 
00176   // wait values
00177   T_pWaitValuesSet           m_wait_values ;
00178 
00179   bool                       m_retrans_enabled      ;
00180   T_pRetransDelayValuesSet   m_retrans_delay_values ;
00181 
00182   // generator model
00183   C_ProtocolControl  *m_protocol_ctrl  ;
00184   C_TransportControl *m_transport_ctrl ;
00185   C_ChannelControl   *m_channel_ctrl   ;
00186 
00187 
00188   int add_scenario (T_scenario_type           P_type,
00189                     C_XmlData                *P_scen,
00190                     T_pTrafficType            P_trafficType,
00191                     int                      *P_nbOpen,
00192                     bool                     *P_data_mesure,
00193                     bool                      P_checkMsgRecv = false);
00194 
00195 
00196   char* get_behaviour_scenario(C_XmlData     *P_scen);
00197 
00198   int add_command (T_cmd_type P_cmd_type, 
00199                    C_XmlData *P_data,
00200                    T_pTrafficType            P_trafficType,
00201                    T_pC_Scenario             P_scen,
00202                    int                      *P_nbOpen,
00203                    bool                     *P_data_mesure,
00204                    bool                     *P_map_inserted,
00205                    bool                     *P_selectLine_added,
00206                    T_pTrafficType            P_channelTrafficTable,
00207                    int                      *P_channel_primary_id,
00208                    bool                      P_checkMsgRecv = false
00209                    ) ;
00210 
00211 
00212   int add_actions (C_XmlData *P_msgData,
00213                    T_InstanceDataList& P_instance_list,
00214                    C_ProtocolFrame *P_protocol,
00215                    T_pC_Scenario             P_scen,
00216                    int                      *P_nbOpen,
00217                    bool                     *P_data_mesure,
00218                    bool                     *P_map_inserted,
00219                    bool                     *P_selectLine_added,
00220                    int&                      P_channel_id,
00221                    bool&                     P_pre_action,
00222                    bool&                     P_pre_action_done,
00223                    //                   T_pCmdAction&             P_CmdActionTable,
00224                    int&                      P_nb_action,
00225                    // T_CmdActionList&          P_CmdActionList,
00226                    bool&                     P_inserted,
00227                    int                       P_nb_value,
00228                    int                       P_msg_id,
00229                    C_CommandActionFactory&   P_CmdActionFactory,
00230                    T_CommandActionLst&       P_CommandActionLst,                   
00231                    C_CommandAction**&         P_CommandActionTable
00232                    ) ;
00233 
00234   int add_expression (char                *P_arg,
00235                       C_ProtocolFrame          *P_protocol,
00236                       T_pStringExpression *P_strExpr);  
00237 
00238   int check_expression (T_pCmdAction  P_action,
00239                         C_ProtocolFrame   *P_protocol) ;
00240 
00241 
00242   int check_channel_usage(T_pTrafficType P_channelUsageTable,
00243                           int            P_primary_channel_id,
00244                           int            P_nb_channel);
00245   
00246   int add_memory    (char *P_mem_name) ;
00247   int check_memory  (char *P_mem_name) ;
00248 
00249 
00250 
00251 } ;
00252 
00253 typedef C_ScenarioControl *T_pC_ScenarioControl ;
00254 
00255 #endif // _C_SCENARIO_CONTROL_H
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 

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