Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_ChannelControl.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_CHANNELCONTROL_H
00021 #define _C_CHANNELCONTROL_H
00022 
00023 #include "string_t.hpp"
00024 #include "map_t.hpp"
00025 
00026 #include "C_IdGenerator.hpp"
00027 #include "C_XmlData.hpp"
00028 
00029 #include "C_MessageFrame.hpp"
00030 #include "C_TransportControl.hpp"
00031 #include "C_ProtocolControl.hpp"
00032 #include "C_SemaphoreTimed.hpp"
00033 
00034 
00035 #define ERROR_CHANNEL_UNKNOWN -1
00036 typedef map_t<string_t, int> T_ChannelNameMap, *T_pChannelNameMap ;
00037 
00038 class C_ChannelControl {
00039 
00040 public:
00041 
00042   typedef enum _channel_type {
00043     E_CHANNEL_GLOBAL,
00044     E_CHANNEL_LOCAL,
00045     E_CHANNEL_UNKNOWN
00046   } T_ChannelType, *T_pChannelType ;
00047 
00048   typedef enum _channel_open_status {
00049     E_CHANNEL_CLOSED,
00050     E_CHANNEL_OPEN_IN_PROGESS,
00051     E_CHANNEL_OPENED
00052   } T_ChannelStatus, *T_pChannelStatus ;
00053 
00054   typedef struct _channel_data {
00055 
00056     int              m_id           ;
00057     T_ChannelType    m_type         ;
00058     int              m_protocol_id  ;
00059     int              m_transport_id ;
00060     C_ProtocolFrame *m_protocol     ;
00061     C_Transport     *m_transport    ;
00062     char            *m_open_args    ;
00063     //    bool             m_open_status  ;
00064     T_ChannelStatus  m_open_status  ;
00065     int              m_open_id      ;
00066     bool             m_reconnect    ;
00067 
00068     char            *m_name         ;
00069     // response id list ?
00070 
00071   } T_ChannelData,  *T_pChannelData ;
00072     
00073    C_ChannelControl() ;
00074   ~C_ChannelControl() ;
00075 
00076   bool fromXml (C_XmlData          *P_data,
00077                 C_ProtocolControl  *P_protocol_ctrl,
00078                 C_TransportControl *P_transport_ctrl) ;
00079 
00080   int            get_channel_id   (char *P_name);
00081   char*          get_channel_name (int P_id);
00082   T_pChannelData get_channel_data (char *P_name);
00083   T_pChannelData get_channel_data (int P_id);
00084 
00085   int            open_global_channel () ;
00086   int            check_global_channel () ;
00087   int            open_local_channel (int           P_id, 
00088                                      char         *P_args,
00089                                      int          *P_table, 
00090                                      T_pOpenStatus P_status);
00091 
00092 
00093 
00094   int            set_option_global_channel (int   P_id,
00095                                             char *P_args,
00096                                             int  *P_table) ;
00097 
00098 
00099   void           close_local_channel (int P_id, int*P_table);
00100 
00101 
00102 
00103   int            nb_channel () ;
00104   int            nb_global_channel() ;
00105   int            open_id_from_channel_id (int P_id, int *P_table);
00106   int            send_to_channel (int P_id, int *P_table, C_MessageFrame *P_msg);
00107 
00108   void           reset_channel (int *P_table);
00109 
00110   void           opened (int P_id, int P_open_id);
00111   void           open_failed (int P_id, int P_open_id);
00112   void           closed (int P_id, int P_open_id);
00113   
00114   int            opened () ;
00115 
00116   C_Transport**  get_transport_table (int *P_size) ;
00117 
00118   C_ProtocolFrame *get_channel_protocol (int P_id) ;
00119 
00120   bool            reconnect() ;
00121 
00122 protected:
00123 private:
00124 
00125   T_pChannelNameMap   m_name_map           ;
00126   T_pChannelData     *m_channel_table      ;
00127   int                 m_channel_table_size ;
00128   T_pC_IdGenerator    m_id_gen             ;
00129 
00130   int                 m_nb_global_channel     ;
00131   int                *m_channel_to_ctxt_table ;
00132   int                *m_ctxt_to_channel_table ;
00133 
00134   C_Transport        **m_transport_table ;
00135   int                  m_nb_transport    ;
00136 
00137   bool                 m_reconnect ;
00138   C_SemaphoreTimed    *m_sem_reconnect ;
00139 
00140   void create_context_channel () ;
00141   void create_transport_table (C_TransportControl *P_transport_ctrl) ;
00142   
00143 } ;
00144 
00145 #endif

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