"Fossies" - the Fresh Open Source Software Archive

Member "erltools/com/connect/metaconnect.h" (28 May 2004, 10957 Bytes) of package /linux/misc/old/erltools-4.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "metaconnect.h" see the Fossies "Dox" file reference documentation.

    1 ///////////////////////////////////////////////////////////////////////////////////
    2 // connect.h : manage a connection
    3 ///////////////////////////////////////////////////////////////////////////////////
    4 #ifndef METAQCONNECT_FILE
    5 #define METAQCONNECT_FILE 1
    6 #include "token.h"
    7 #include "metainetutil.h"
    8 #ifdef MOST_RECENT_STL
    9 #include <list>
   10 #else
   11 #include <list.h>
   12 #endif
   13 
   14 // #include <String.h>
   15 #include "../asn/decasn.h"
   16 #include "../asnext/asnext.h"
   17 class GenGramm ;
   18 
   19 class MetaConnection {
   20     
   21     public :
   22     
   23         enum TypeMessage { SEND_EVENT, SEND_EVENT_CHUNK
   24             , SEND_EVENT_CHUNK_END, GET_EVENT, GET_EVENT_BLOCKED };
   25         
   26         // constructor 
   27         MetaConnection ()
   28             : pvSenderName(""),  pvSenderChannel(""),  pvSecStamp("0")
   29                 ,  pvMSecStamp("0")
   30         {}
   31         
   32         // destructor
   33         ~MetaConnection () {}
   34         
   35         // Open : opening of a connection under a name
   36         // parameters :
   37         //             name : name of the connection
   38         //             locAddr : local ip address
   39         //             _iIpAddr : IP address where to connect
   40         //             port : port where to connect
   41         //             maxTry : number max of try on dispatcher
   42         // return : the object
   43         virtual MetaConnection &Open ( const EString &name
   44             , char *locAddr = "127.0.0.1", char *_iIpAddr = (char *)0
   45             , int port = dispatcherPort, int maxTry = -1 )
   46         {
   47             return *this ;
   48         }
   49         
   50         // OpenChannel : opening a channel in a connection
   51         // parameters :
   52         //             channel : name of the channel
   53         //             outputPco : declare as an only ouput channel
   54         // return : the object
   55         virtual MetaConnection &OpenChannel ( EString channel
   56             , bool ouputPco = false )
   57         {
   58             return *this ;
   59         }
   60         
   61         // CloseChannel : closing a channel in a connection
   62         // parameters :
   63         //             channel : name of the channel
   64         // return : the object
   65         virtual MetaConnection &CloseChannel ( EString channel )
   66         {
   67             return *this ;
   68         }
   69         
   70         // CloseChannels : closing channels in a connection
   71         virtual void CloseChannels () {}
   72         
   73         // SendRaw : send a raw content 
   74         // parameters :
   75         //               message : message to be send
   76         virtual void SendRaw ( PTREE message ) {}
   77         
   78         // Send : send a content on a channel
   79         // parameters :
   80         //               channel : the channel where to send
   81         //               content : the content to send
   82         //               coarse : tell to send as a coarse string
   83         virtual void Send ( const EString &channel, PTREE content
   84             , bool coarse = false )
   85   {}    
   86         
   87         // SendString : send a string content on a channel 
   88         // parameters :
   89         //               channel : the channel where to send
   90         //               messageString : message string to be send
   91         virtual void SendString ( const EString &channel
   92             , const EString &messageString )
   93   {}    
   94         
   95         // Rearm : rearm connection to receive an event
   96         virtual void Rearm () {}
   97         
   98         // Receive : receive a content 
   99         // parameters :
  100         //               blocked : tell if wait for message
  101         // return : received tree
  102         virtual PTREE Receive ( bool blocked = false )
  103         {
  104             return PTREE(0);
  105         }
  106         
  107         // Syntax : set syntax for connection
  108         // parameters :
  109         // 
  110         //              channel : channel where to put syntax
  111         //              fileSyntax : file where to read syntax
  112         // return : the whole object
  113         virtual MetaConnection &Syntax ( EString channel
  114             , GenGramm *genGramm )
  115         {
  116             return *this ;
  117         }
  118         
  119         // Syntax : set syntax for connection
  120         // parameters :
  121         // 
  122         //              channel : channel where to put syntax
  123         //              fileSyntax : file where to read syntax
  124         // return : the whole object
  125         virtual MetaConnection &Syntax ( EString channel
  126             , EString fileSyntax )
  127         {
  128             return *this ;
  129         }
  130         
  131         // Syntax : set syntax for connection, default syntax
  132         // parameters :
  133         // 
  134         //              fileSyntax : file where to read syntax
  135         // return : the whole object
  136         virtual MetaConnection &Syntax ( EString fileSyntax )
  137         {
  138             return *this ;
  139         }
  140         
  141 #if 0
  142         
  143         // SenderName : get sender name
  144         // return : the  sender name
  145         virtual const EString &SenderName () const
  146         {
  147             return pvEmptyString ;
  148         }
  149         
  150         // SenderChannel : get sender channel
  151         // return : the  sender channel
  152         virtual const EString &SenderChannel () const
  153         {
  154             return pvEmptyString ;
  155         }
  156 #endif
  157         
  158         // FullInterpret : interpret a string coded as hexa string with user grammar
  159         // parameters :
  160         //              message : the string to be interpreted
  161         //              channel : channel of interpretation (if some)
  162         // return : the decoded tree
  163         virtual PTREE FullInterpret ( EString &message
  164             , EString channel = " " )
  165         {
  166             return PTREE(0);
  167         }
  168         
  169         // FullEncode : full encoding of a tree
  170         // parameters :
  171         //              tree : the tree to be encoded
  172         //              channel : channel of interpretation (if some)
  173         // return : the encoding
  174         virtual EString FullEncode ( PTREE tree, EString channel = " " )
  175         {
  176             return "";
  177         }
  178         
  179         // TimeVal : TimeVal modifier
  180         // parameters :
  181         //               timeVal : new value for timeval
  182         virtual void TimeVal ( struct timeval &tval ) {}
  183         
  184         // Connected : accessor
  185         virtual bool Connected () const
  186         {
  187             return false ;
  188         }
  189         
  190         // Connected : connected modifier
  191         // parameters :
  192         //              connected : the new connected value
  193         // return : the whole object
  194         virtual MetaConnection &Connected ( bool connected )
  195         {
  196             return *this ;
  197         }
  198         
  199         // Empty : tell if they are messages allready read
  200         // return : true if no message
  201         virtual bool Empty ()
  202         {
  203             return false ;
  204         }
  205         
  206         // FastEncode : tell if fast encode
  207         //              channel : channel to look for
  208         virtual bool FastEncode ( const EString &channel )
  209         {
  210             return false ;
  211         }
  212         
  213         // FastEncode : set fast encode
  214         // parameters :
  215         //              channel : channel to look for
  216         //              fastSpeed : tell if fast encode
  217         virtual void FastEncode ( const EString &channel, bool fastSpeed ) {}
  218         
  219         // GetAMessage : get different type of messages
  220         // parameters :
  221         //               typeMessage : type of message
  222         //               string1 : first parameter string in message
  223         //               string2 : second parameter string in message
  224         //               string3 : third parameter string in message
  225         // return : the message
  226         virtual PTREE GetAMessage ( TypeMessage typeMessage, char *string1
  227             , char *string2 = (char *)0, char *string3 = (char *)0 )
  228         {
  229             return PTREE(0);
  230         }
  231         
  232         // OutputSock : output socket 
  233         // return : the output socket
  234         virtual SOCKET OutputSock ()
  235         {
  236             return (SOCKET) -1 ;
  237         }
  238         
  239         // InputSock : input socket 
  240         // return : the input sockets
  241         virtual std::vector<SOCKET>  InputSock () = 0 ;
  242         
  243         // SizeMin : set size min of pdu
  244         // parameters :
  245         //               sizeMin : the size min
  246         // return : the whole object
  247         virtual MetaConnection &SizeMin ( unsigned int sizeMin )
  248         {
  249             
  250             // return object
  251             return *this ;
  252         }
  253         
  254         // IsLookAhead : search if message is searched lookahead
  255         // parameters :
  256         //               name : name of appli
  257         //               message : received message
  258         // return 0 not good 1 good 2 good to be saved
  259         static int  IsLookAhead (EString &name, PTREE &message) ;
  260         
  261         // LookAheadSynchro : get look ahead synchro
  262         // parameters :
  263         //              name : name for look ahead
  264         //              nbSynchro : nb of synchro
  265         //              util : the util object
  266         //              listMess : the list of message
  267         //              lookTimeOut : look if time out
  268         //              lookTimeVal : look time out val
  269         //              dispatchRefNumber : ref number for dispatcher (used for kill)
  270         static bool LookAheadSynchro (EString &name, int nbSynchro
  271             , MetaInetUtil &util, list<PTREE> &listMess
  272             , bool lookTimeOut = false, int lookTimeVal = -1
  273             , int dispatchRefNumber = -1) ;
  274         
  275         // SearchChunkEnd : get chunk end 
  276         // parameters :
  277         //              name : name for look ahead
  278         //              util : the util object
  279         //              sendUtil : the util for sending acks
  280         //              listMess : the list of message
  281         //              chunks : where to store messages
  282         //              oldProtocol : type of protocol
  283         PTREE       MetaConnection::SearchChunkEnd (EString &name
  284             , MetaInetUtil &util, MetaInetUtil &sendUtil
  285             , list<PTREE> &chunks, bool olProtocol) ;
  286         
  287         // SenderName : get sender name
  288         // return : the  sender name
  289         virtual const EString &SenderName () const
  290         {
  291             return pvSenderName ;
  292         }
  293         
  294         // SenderChannel : get sender channel
  295         // return : the  sender channel
  296         virtual const EString &SenderChannel () const
  297         {
  298             return pvSenderChannel ;
  299         }
  300         
  301         // SecStamp 
  302         const EString &SecStamp ()
  303         {
  304             return pvSecStamp ;
  305         }
  306         
  307         // MSecStamp 
  308         const EString &MSecStamp ()
  309         {
  310             return pvMSecStamp ;
  311         }
  312     
  313     protected :
  314     
  315         list<PTREE>     chunks ;          // chunks of message
  316         EString         pvSenderName ;    // name of last message sender
  317         EString         pvSenderChannel ; // channel of last message
  318         EString         pvSecStamp ;      // stamp
  319         EString         pvMSecStamp ;     // stamp
  320     
  321     private :
  322     
  323         EString pvEmptyString ;
  324 };
  325 #endif