Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_ReStoreAction.cpp

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 #include "C_ReStoreAction.hpp"
00021 #include "GeneratorTrace.hpp"
00022 #include "GeneratorError.h"
00023 
00024 
00025 C_ReStoreAction::C_ReStoreAction(T_CmdAction        P_cmdAction,
00026                                  T_pControllers P_controllers)
00027   : C_CommandAction (P_cmdAction, P_controllers) {
00028 }
00029 
00030 
00031 C_ReStoreAction::~C_ReStoreAction() {
00032 }
00033 
00034 
00035 T_exeCode    C_ReStoreAction::execute(T_pCmd_scenario P_pCmd,
00036                                       T_pCallContext  P_callCtxt,
00037                                       C_MessageFrame *P_msg,
00038                                       C_MessageFrame *P_ref) {
00039 
00040   T_exeCode           L_exeCode    = E_EXE_NOERROR ;
00041 
00042   T_pValueData        L_mem                        ;
00043   int                 L_size                       ;
00044   
00045   GEN_DEBUG(2, "restore memory id = " << m_mem_id);
00046   GEN_DEBUG(2, "restore field id = "  << m_id);
00047   
00048   L_mem = P_callCtxt->get_memory(m_mem_id);
00049   
00050   L_size = m_size ;
00051   
00052   if (L_size != -1) {
00053     T_ValueData           L_val ;
00054     L_val.m_type = E_TYPE_NUMBER ;
00055     
00056     if (L_mem->m_value.m_val_binary.m_size == 0) {
00057       GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR,
00058                     action_name_table[m_type] 
00059                     << " memory zone that was not previously stored");
00060 
00061       return (L_exeCode);
00062     }
00063     
00064     // RETRIEVE the data 
00065     if (P_msg -> get_field_value(m_id, 
00066                                  m_instance_id,
00067                                  m_sub_id,
00068                                  &L_val) == true) {
00069       
00070           if (L_size > (int)L_val.m_value.m_val_binary.m_size) {
00071             GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR,
00072                           action_name_table[m_type] 
00073                           << ": the size desired  ["
00074                           << L_size << "] exceed the length of buffer ["
00075                           << L_val.m_value.m_val_binary.m_size << "]");
00076             L_size = L_val.m_value.m_val_binary.m_size ;
00077           }
00078 
00079           copyBinaryVal(L_val, m_begin, L_size,
00080                         *L_mem);
00081 
00082           if (P_msg -> set_field_value(&L_val, 
00083                                        m_id,
00084                                        m_instance_id,
00085                                        m_sub_id) == false ) {
00086 
00087             GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00088                           action_name_table[m_type] 
00089                           << ": problem when set field value");
00090             
00091             GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00092                           "error on call with session-id ["
00093                           << P_callCtxt->m_id_table[P_pCmd->m_channel_id] << "]");
00094             
00095             L_exeCode = E_EXE_ERROR;
00096           }
00097           resetMemory(L_val);
00098         } else {
00099           GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00100                         action_name_table[m_type] 
00101                         << ": the value of the field asked is incorrect or not found");
00102           
00103           GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00104                         "error on call with session-id ["
00105                         << P_callCtxt->m_id_table[P_pCmd->m_channel_id] << "]");
00106           
00107           L_exeCode = E_EXE_ERROR;
00108         }
00109       } else {
00110         if (P_msg -> set_field_value(L_mem, 
00111                                      m_id,
00112                                      m_instance_id,
00113                                      m_sub_id) == false ) {
00114 
00115           GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00116                         action_name_table[m_type] 
00117                         << ": problem when set field value");
00118           
00119           GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR, 
00120                         "error on call with session-id ["
00121                         << P_callCtxt->m_id_table[P_pCmd->m_channel_id] << "]");
00122           
00123           L_exeCode = E_EXE_ERROR;
00124         }
00125       }
00126 
00127   return (L_exeCode);
00128 }
00129 
00130 
00131 
00132 
00133 

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