Inheritance diagram for C_ProtocolBinarySeparator:
Public Member Functions | |
C_ProtocolBinarySeparator () | |
~C_ProtocolBinarySeparator () | |
virtual C_ProtocolFrame::T_MsgError | encode_body (int P_nbVal, T_pBodyValue P_val, unsigned char *P_buf, size_t *P_size) |
virtual C_MessageFrame * | create_new_message (C_MessageFrame *P_msg) |
virtual C_MessageFrame * | create_new_message (void *P_xml, T_pInstanceDataList P_list, int *P_nb_value) |
virtual int | decode_body (unsigned char *P_buf, size_t P_size, T_pBodyValue P_valDec, int *P_nbValDec, int *P_headerId) |
virtual void | construction_data (C_XmlData *P_def, char **P_name, T_pContructorResult P_res) |
Definition at line 25 of file C_ProtocolBinarySeparator.hpp.
|
Create a new message Reimplemented from C_ProtocolBinary. Definition at line 79 of file C_ProtocolBinarySeparator.cpp. References C_ProtocolBinary::analyze_setfield(), C_ProtocolBinary::delete_body_value(), C_XmlData::find_value(), C_ProtocolBinary::get_body_value_type(), C_ProtocolBinary::get_header_body_name(), C_ProtocolBinary::get_header_body_value_id(), C_ProtocolBinary::get_header_name(), C_ProtocolBinary::get_header_value_id(), C_XmlData::get_name(), C_ProtocolBinary::m_header_body_field_separator, C_ProtocolBinary::_struct_body_value::m_id, _struct_value::m_id, C_ProtocolBinary::_struct_body_value::m_sub_val, _struct_value::m_type, C_ProtocolBinary::_struct_body_value::m_value, _struct_value::m_value, C_ProtocolBinary::process_grouped_type(), C_ProtocolBinary::reset_grouped_body_value(), C_ProtocolBinary::set_body_value(), C_MessageBinary::set_body_value(), and C_MessageBinary::set_header_id_value(). 00081 { 00082 00083 00084 C_XmlData *L_Xml = (C_XmlData*) P_xml ; 00085 00086 bool L_msgOk = true ; 00087 C_MessageBinarySeparator *L_msg ; 00088 char *L_currentName ; 00089 00090 C_ProtocolFrame::T_MsgError L_decode_result ; 00091 00092 unsigned char *L_buf ; 00093 size_t L_size ; 00094 00095 int L_header_val_id ; 00096 int L_body_val_id ; 00097 00098 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() start: xml"); 00099 00100 // Allocate a new message 00101 00102 NEW_VAR(L_msg, C_MessageBinarySeparator(this)); 00103 00104 // Get the message name from XML definition 00105 L_currentName = L_Xml -> get_name () ; 00106 00107 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() msg xml name is " 00108 << L_currentName ); 00109 00110 if (strcmp(L_currentName, (char*)"CDATA") == 0) { 00111 00112 // direct buffer data definition 00113 L_currentName = L_Xml->find_value((char*)"value"); 00114 00115 L_buf = convert_hexa_char_to_bin(L_currentName, &L_size); 00116 (void) L_msg -> decode(L_buf, L_size, &L_decode_result); 00117 00118 if (L_decode_result != C_ProtocolFrame::E_MSG_OK) { 00119 GEN_ERROR(E_GEN_FATAL_ERROR, 00120 "Error while decoding direct data buffer [" 00121 << L_currentName << "]"); 00122 L_msgOk = false ; 00123 } 00124 00125 } else if (strcmp(L_currentName, get_header_name()) == 0) { 00126 00127 // message decoding 00128 L_currentName = L_Xml -> find_value ((char*) "name") ; 00129 if (L_currentName == NULL) { 00130 GEN_ERROR(E_GEN_FATAL_ERROR, 00131 "name value is mandatory for [" 00132 << get_header_name() 00133 << "]"); 00134 L_msgOk = false ; 00135 } else { 00136 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00137 << "the name of this message is " << L_currentName ); 00138 00139 L_header_val_id = get_header_value_id(L_currentName) ; 00140 00141 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00142 << "L_header_val_id = " << L_header_val_id ); 00143 00144 if (L_header_val_id == -1) { 00145 GEN_ERROR(E_GEN_FATAL_ERROR, 00146 "unknown name [" 00147 << L_currentName << "] for [" << get_header_name() << "]"); 00148 L_msgOk = false ; 00149 00150 } else { 00151 00152 // now search for body values 00153 T_pXmlData_List L_listBodyVal ; 00154 T_XmlData_List::iterator L_bodyValIt ; 00155 C_XmlData *L_bodyData ; 00156 char *L_bodyName, *L_bodyValue ; 00157 C_ProtocolBinary::T_BodyValue L_bodyVal ; 00158 T_TypeType L_type ; 00159 00160 L_msg->set_header_id_value(L_header_val_id); 00161 00162 L_listBodyVal = L_Xml -> get_sub_data() ; 00163 if (L_listBodyVal != NULL) { 00164 for (L_bodyValIt = L_listBodyVal->begin() ; 00165 L_bodyValIt != L_listBodyVal->end() ; 00166 L_bodyValIt++) { 00167 L_bodyData = *L_bodyValIt ; 00168 00169 if (strcmp(L_bodyData->get_name(), 00170 get_header_body_name())==0) { 00171 00172 L_bodyName = L_bodyData->find_value((char*)"name"); 00173 if (L_bodyName == NULL) { 00174 GEN_ERROR(E_GEN_FATAL_ERROR, 00175 "name value is mandatory for [" 00176 << get_header_body_name() 00177 << "] definition"); 00178 L_msgOk = false ; 00179 } 00180 00181 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00182 << "L_bodyName is [" << L_bodyName << "]"); 00183 00184 L_body_val_id = get_header_body_value_id(L_bodyName) ; 00185 if (L_body_val_id == -1) { 00186 GEN_ERROR(E_GEN_FATAL_ERROR, 00187 "No definition found for [" 00188 << L_bodyName << "]"); 00189 L_msgOk = false ; 00190 break ; 00191 } 00192 00193 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00194 << "L_body_val_id is " 00195 << L_body_val_id ); 00196 00197 L_type = get_body_value_type (L_body_val_id) ; 00198 if (L_type 00199 == E_TYPE_GROUPED) { 00200 00201 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00202 << L_bodyName << " is grouped element" ); 00203 00204 00205 if (process_grouped_type(L_bodyData, L_body_val_id, 00206 &L_bodyVal) != 0) { 00207 GEN_ERROR(E_GEN_FATAL_ERROR, 00208 "Grouped Type processing Error for " 00209 << L_bodyName); 00210 L_msgOk = false ; 00211 break ; 00212 } 00213 00214 00215 // Add the grouped value in message 00216 L_msg->set_body_value(&L_bodyVal); 00217 00218 // Now do not forget to clean L_bodyVal 00219 reset_grouped_body_value(&L_bodyVal); 00220 FREE_TABLE(L_bodyVal.m_sub_val); 00221 } else { 00222 bool L_toBeDelete = false; 00223 00224 // not grouped value 00225 L_bodyValue = L_bodyData->find_value((char*)"value"); 00226 if (L_bodyValue == NULL) { 00227 GEN_ERROR(E_GEN_FATAL_ERROR, 00228 "value is mandatory for [" 00229 << get_header_body_name() 00230 << "] definition"); 00231 L_msgOk = false ; 00232 break ; 00233 } 00234 00235 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() " 00236 << "L_bodyValue is \"" << L_bodyValue << "\"" ); 00237 00238 if (set_body_value(L_body_val_id, 00239 L_bodyValue, 00240 1, 00241 &L_bodyVal, 00242 &L_toBeDelete) == 0) { 00243 00244 if (m_header_body_field_separator == NULL) { 00245 L_msg->set_body_value(&L_bodyVal); 00246 } else { 00247 T_ValueData L_tmp_value ; 00248 bool L_exist ; 00249 L_tmp_value.m_value = L_bodyVal.m_value ; 00250 L_tmp_value.m_id = L_bodyVal.m_id ; 00251 L_tmp_value.m_type = L_type; 00252 L_exist = L_msg->set_body_value(L_body_val_id,&L_tmp_value); 00253 if (L_exist == false) { 00254 L_msg->set_body_value(&L_bodyVal); 00255 } 00256 } 00257 00258 if (L_toBeDelete) { 00259 // Now do not forget to clean L_bodyVal 00260 delete_body_value(&L_bodyVal); 00261 } 00262 00263 } else { 00264 GEN_ERROR(E_GEN_FATAL_ERROR, 00265 "Bad format for [" 00266 << L_bodyValue << "]"); 00267 L_msgOk = false ; 00268 break ; 00269 } 00270 00271 } 00272 } else if (strcmp(L_bodyData->get_name(), 00273 (char*)"setfield")==0) { 00274 unsigned long L_val_setfield = 0 ; 00275 int L_id_setfield = 0 ; 00276 L_msgOk = (analyze_setfield(L_bodyData, &L_id_setfield ,&L_val_setfield) == -1) 00277 ? false : true ; 00278 if (L_msgOk) { 00279 L_msg->C_MessageBinary::set_header_value(L_id_setfield, L_val_setfield); 00280 } 00281 00282 } else { 00283 GEN_ERROR(E_GEN_FATAL_ERROR, 00284 "Unkown section [" 00285 << L_bodyData->get_name() 00286 << "]"); 00287 L_msgOk = false; 00288 break ; 00289 } 00290 if (L_msgOk == false) break ; 00291 } 00292 } 00293 } 00294 } 00295 } 00296 00297 // TO-REMOVE 00298 if (L_msgOk == false) { 00299 DELETE_VAR(L_msg); 00300 } else { 00301 // Store the description message in list 00302 m_messageList->push_back(L_msg); 00303 } 00304 00305 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() end: xml"); 00306 00307 return (L_msg); 00308 }
|
|
Create a new message Reimplemented from C_ProtocolBinary. Definition at line 66 of file C_ProtocolBinarySeparator.cpp. 00066 { 00067 00068 C_MessageBinarySeparator *L_msg ; 00069 00070 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() start: msg pt"); 00071 NEW_VAR(L_msg, C_MessageBinarySeparator(this)); 00072 if (P_msg != NULL) { 00073 (*L_msg) = *((C_MessageBinarySeparator*)P_msg) ; 00074 } 00075 GEN_DEBUG(1, "C_ProtocolBinarySeparator::create_new_message() end: msg pt"); 00076 return (L_msg); 00077 }
|