connectivitylayer/isce/p2prouter_dll/inc/p2prouter.h
changeset 0 63b37f68c1ce
child 9 8486d82aef45
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __P2PROUTER_H__
       
    21 #define __P2PROUTER_H__
       
    22 
       
    23 #include "p2prouterlinkifs.h"       // For MP2PRouterLinkIf
       
    24 #include "p2prouterchannelifs.h"    // For MP2PChRouterIf and MP2PRouterChIf
       
    25 #include "p2pdefs.h"                // For EP2PAmountOfProtocols
       
    26 
       
    27 class DMsgQueue;
       
    28 class DP2PLink;
       
    29 class MP2PRouterChIf;
       
    30 
       
    31 /*
       
    32 * Point-to-point router.
       
    33 */
       
    34 NONSHARABLE_CLASS( DP2PRouter ) : public DBase, public MP2PLinkRouterIf, public MP2PChRouterIf
       
    35     {
       
    36 
       
    37     public:
       
    38 
       
    39         /*
       
    40         * Default contructor
       
    41         */
       
    42         DP2PRouter();
       
    43 
       
    44         /*
       
    45         * Destructor
       
    46         */
       
    47         ~DP2PRouter();
       
    48 
       
    49         // From MP2PLinkRouterIf start
       
    50         /*
       
    51         * See comments from MP2PLinkRouterIf
       
    52         */
       
    53         void NotifyTrxPresenceEnqueDfc( TBool aPresent );
       
    54 
       
    55         /*
       
    56         * See comments from MP2PLinkRouterIf
       
    57         */
       
    58         void Receive( TDes8& aMsg, const TUint8 aProtocolId );
       
    59         // From MP2PLinkRouterIf end
       
    60 
       
    61         // From MP2PChRouterIf start
       
    62         /*
       
    63         * See comments from MP2PChRouterIf
       
    64         */
       
    65         void Close( const TUint8 aProtocolId );
       
    66 
       
    67         /*
       
    68         * See comments from MP2PChRouterIf
       
    69         */
       
    70         TBool ConnectionExist( const TUint8 aProtocolId );
       
    71 
       
    72         /*
       
    73         * See comments from MP2PChRouterIf
       
    74         */
       
    75         TDfcQue* GetDfcThread( const TP2PDfcThread anIndex );
       
    76 
       
    77         /*
       
    78         * See comments from MP2PChRouterIf
       
    79         */
       
    80         void Open( const TUint8 aProtocolId, MP2PRouterChIf* aCallback );
       
    81 
       
    82         /*
       
    83         * See comments from MP2PChRouterIf
       
    84         */
       
    85         TInt Send( TDes8& aMessage, const TUint8 aProtocolId );
       
    86         // From MP2PChRouterIf end
       
    87 
       
    88         /*
       
    89         * Returns pointer to router it self, called only from MP2PChRouterIf::GetIf
       
    90         * @return pointer to router.
       
    91         */
       
    92         static DP2PRouter* GetRouter(){ return iSelfPtr; };
       
    93 
       
    94     private:
       
    95 
       
    96         /*
       
    97         * Handles initialization of this class.
       
    98         * Called in own thread context not supervisors
       
    99         */
       
   100         void Init();
       
   101 
       
   102         static void InitDfc( TAny* aPtr );
       
   103 
       
   104         static void TrxPrecentDfc( TAny* aPtr );
       
   105 
       
   106         static void TrxNotPrecentDfc( TAny* aPtr );
       
   107 
       
   108     private:
       
   109 
       
   110         // Added convention:
       
   111         // Prefix "iSh" means shared member variable
       
   112         // Prefix "gSh" means shared global variable
       
   113 
       
   114         NONSHARABLE_CLASS( TP2PChannel )
       
   115             {
       
   116             public:
       
   117                 MP2PRouterChIf*   iChannel;
       
   118                 MP2PRouterChIf*   iWaitingChannel;
       
   119             };
       
   120 
       
   121         // Guards class shared state of this class, owned
       
   122         NFastMutex*         iShChannelTableFastMutex;
       
   123         // One channel / P2P protocol
       
   124         TP2PChannel         iShChannelTable[ EP2PAmountOfProtocols ];
       
   125         // One link / P2P protocol (cause P2P protocols can use only one transceiver (p2p))
       
   126         // Owned, written only once in construction from one thread no need to sync reading.
       
   127         MP2PRouterLinkIf**  iLinksArray;
       
   128         // Owned, written only once in construction from one thread no need to sync reading.
       
   129         static TDfcQue*     iP2PDfcQueList[ MP2PChRouterIf::EAmountOfP2PDfcThreads ];
       
   130         // Owned
       
   131         TDfc*               iInitDfc;
       
   132         // Owned
       
   133         TDfc*               iTrxPrecentDfc;
       
   134         // Owned
       
   135         TDfc*               iTrxNotPrecentDfc;
       
   136         // Written only once no need to synch.
       
   137         static DP2PRouter*  iSelfPtr;
       
   138 
       
   139     };
       
   140 
       
   141 #endif /* __P2PROUTER_H__ */