C_MessageText.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_MESSAGE_TEXT_H
00021 #define _C_MESSAGE_TEXT_H
00022 
00023 
00024 #include "C_GeneratorConfig.hpp"
00025 #include "C_MessageFrame.hpp"
00026 #include "iostream_t.hpp"
00027 #include "C_ProtocolTextFrame.hpp"
00028 // #include "C_ContextFrame.hpp"
00029 // #include "ParserFrame.hpp"
00030 #include "TextDef.hpp"
00031 
00032 class C_ProtocolText ;
00033 
00034 class C_MessageText : public C_MessageFrame {
00035 public:
00036 
00037   C_MessageText (C_ProtocolText *P_protocol);
00038   C_MessageText(C_ProtocolText *P_protocol,
00039                 T_pValueData    P_header,
00040                 T_pValueData    P_body,
00041                 int            *P_id)  ;
00042   virtual ~C_MessageText ();
00043 
00044   C_MessageText(C_MessageText &P_val) ;
00045   
00046 
00047   T_pValueData get_session_id (C_ContextFrame *P_ctxt) ;
00048   T_pValueData get_out_of_session_id () ;
00049   bool         update_fields (C_MessageFrame *P_ref) ;
00050   bool         compare_types (C_MessageFrame *P_ref) ;
00051 
00052   void         update_message_stats () ;
00053   bool         check (C_MessageFrame    *P_ref,
00054                                 unsigned int       P_levelMask,
00055                                 T_CheckBehaviour   P_behave) ;
00056   
00057 
00058   bool         check_field_presence (int              P_id,
00059                                      T_CheckBehaviour P_behave,
00060                                      int P_instance,
00061                                      int P_sub_id) ;
00062   
00063   bool         check_field_value (C_MessageFrame  *P_ref,
00064                                   int              P_id,
00065                                   T_CheckBehaviour P_behave,
00066                                   int P_instance,
00067                                   int P_sub_id) ;
00068 
00069   bool         check_field_order (int              P_id,
00070                                   T_CheckBehaviour P_behave,
00071                                   int              P_position) ;
00072 
00073 
00074   T_TypeType   get_field_type  (int P_id,
00075                                 int P_sub_id) ;
00076 
00077 
00078 
00079   bool         get_field_value (int P_id, 
00080                                 C_RegExp *P_reg,
00081                                 T_pValueData P_value) ;
00082 
00083   bool         get_field_value (int P_id, 
00084                                 int P_instance,
00085                                 int P_sub_id,
00086                                 T_pValueData P_value) ;
00087 
00088   int          get_buffer (T_pValueData P_dest,
00089                            T_MessagePartType P_header_body_type) ;
00090 
00091 
00092   bool         set_field_value (T_pValueData P_value, 
00093                                 int P_id,
00094                                 int P_instance,
00095                                 int P_sub_id) ;
00096 
00097 
00098   char*        name() ;
00099 
00100   friend iostream_output& operator<< (iostream_output&, C_MessageText &);
00101   void         dump(iostream_output&) ;
00102 
00103   int          get_id_message() ;
00104   void         set_id_message(int P_id) ;
00105 
00106   char*        get_text_value(bool P_header_body);  
00107   int          set_text_value(bool P_header_body, T_pValueData P_value, 
00108                               int P_start, int P_end);  
00109 
00110   T_pValueData get_data_value(bool P_header_body);  
00111 
00112   C_ProtocolFrame::T_MsgError encode(unsigned char *P_buf,
00113                                      size_t        *P_siz);
00114   
00115   unsigned long decode(unsigned char *P_buf,
00116                        size_t         P_siz,
00117                        C_ProtocolFrame::T_pMsgError P_error) ;
00118   
00119 
00120   // static void set_session_id_id (int  P_id) ;
00121   // static void use_open_id () ;
00122 
00123 //    typedef C_ProtocolFrame::T_MsgError 
00124 //    (C_MessageText::* T_BodyDecodeMethod)(int  P_index,
00125 //                                          char *P_ptr, 
00126 //                                          size_t *P_size);
00127 
00128   // ??? typedef int (C_MessageText::* T_BodyDecodeMethodInit)(void *P_param);
00129 
00130   C_ProtocolFrame::T_MsgError DecodeBodyWithContentLength (int P_index, 
00131                                                            char *P_ptr, size_t *P_size);
00132 
00133   C_ProtocolFrame::T_MsgError DecodeBodyWithParser (int P_index,
00134                                                     char *P_ptr,
00135                                                     size_t *P_size) ;
00136 
00137 //    typedef C_ProtocolFrame::T_MsgError 
00138 //    (C_MessageText::* T_EncodeMethod)(int P_index);
00139 
00140   // ??? typedef int (C_MessageText::* T_EncodeMethodInit)(void *P_param);
00141 
00142 
00143 
00144   //  static void set_names_fields (char** P_names_fields) ;
00145 
00146   //  static void set_number_methods (int P_nb) ;
00147 
00148   // static void destroy_methods () ;
00149 
00150 //    static void set_body_decode_method (int                     P_index,
00151 //                                        T_BodyMethodType        P_type,
00152 //                                        T_BodyDecodeMethod      P_method,
00153 //                                        void                   *P_param);
00154 //    static void set_encode_method (int                 P_index,
00155 //                                   T_BodyMethodType    P_type,
00156 //                                   T_EncodeMethod      P_method,
00157 //                                   void               *P_param);
00158 
00159 
00160   // typedef T_pValueData (C_MessageText::* T_SessionMethod)(C_ContextFrame *P_void);
00161 
00162   C_ProtocolFrame::T_MsgError EncodeWithContentLength (int P_index);
00163 
00164   C_ProtocolFrame::T_MsgError NoEncode (int P_index);
00165 
00166 
00167   T_pValueData getSessionFromField (C_ContextFrame *P_ctxt) ;
00168   T_pValueData getSessionFromOpenId (C_ContextFrame *P_ctxt) ;
00169 
00170 
00171 protected:
00172 private:
00173 
00174   C_ProtocolText            *m_protocol              ;
00175   T_pValueData               m_header, m_body        ;
00176   int                        m_id                    ;
00177   T_pValueData               m_session_id            ;
00178 
00179 
00180   // static T_SessionMethod     m_session_method        ;
00181 
00182 
00183 //    typedef union _union_param {
00184 //      int                 m_id ;
00185 //      T_ParserFunction    m_parser ;
00186 //    } T_ParamMethod, *T_pParamMethod ;
00187 
00188 //    typedef struct _struct_body_decode_data {
00189 //      T_BodyDecodeMethod m_decode ;
00190 //      T_EncodeMethod     m_encode ;
00191 //      T_ParamMethod      m_param_encode  ;
00192 //      T_ParamMethod      m_param_decode  ;
00193 //    } T_BodyDecodeData, *T_pBodyDecodeData ;
00194 
00195 //    static T_BodyDecodeData **m_methods ;
00196 //    static int                m_nb_methods ;
00197 
00198 
00199 //    T_pValueData getSessionFromField (C_ContextFrame *P_ctxt) ;
00200 //    T_pValueData getSessionFromOpenId (C_ContextFrame *P_ctxt) ;
00201 
00202 
00203 } ;
00204 
00205 typedef C_MessageText *T_pC_MessageText ;
00206 
00207 
00208 #endif // _C_MESSAGE_TEXT_H
00209 
00210 
00211 
00212 
00213 
00214 
00215 

Generated on Wed Mar 7 14:57:52 2007 for Seagull by  doxygen 1.4.6