dvrengine/CommonRecordingEngineClient/inc/CCRServerHandleSingleton.h
branchRCL_3
changeset 47 826cea16efd9
parent 45 798ee5f1972c
child 48 13a33d82ad98
equal deleted inserted replaced
45:798ee5f1972c 47:826cea16efd9
     1 /*
       
     2 * Copyright (c) 2007 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:    Singleton to hold server session*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCRSERVERHADLESINGLETON_H
       
    21 #define CCRSERVERHADLESINGLETON_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "RCRService.h"
       
    25 #include "RCRClient.h"
       
    26 #include <e32base.h>
       
    27 
       
    28 // CONSTANTS
       
    29 // None
       
    30 
       
    31 // MACROS
       
    32 // None
       
    33 
       
    34 // DATA TYPES
       
    35 // None
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CCRAPIBase;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Singleton class to store client handles. Instance of this class is kept
       
    44 *  in TLS and a reference count is maintained. This is to ensure that if a
       
    45 *  process creates multiple CCRDvrApi instances, they will all share the
       
    46 *  same session to CommonRecordingEngine.
       
    47 *
       
    48 *  @lib CommonRecordingEngineClient.lib
       
    49 *  @since Series 60 3.0
       
    50 */
       
    51 NONSHARABLE_CLASS( CCRServerHandleSingleton ) : public CBase
       
    52     {
       
    53 
       
    54     /**
       
    55     * CCRApiBase and CCRDvrApi are the only classes 
       
    56     * that should have access to this class.
       
    57     */
       
    58     friend class CCRApiBase;
       
    59     friend class CCRDvrApi;
       
    60 
       
    61 private: // Constructors and destructors
       
    62 
       
    63     /**
       
    64     * Private constructor to prevent direct instantiation. InstanceL must be used.
       
    65     */
       
    66     CCRServerHandleSingleton();
       
    67 
       
    68     /**
       
    69     * Second phase of 2-phased construction
       
    70     */
       
    71     void ConstructL();
       
    72 
       
    73     /**
       
    74     * Private destructor to prevent direct deletion. Release must be used.
       
    75     */
       
    76     ~CCRServerHandleSingleton();
       
    77 
       
    78 private: // New methods
       
    79 
       
    80     /**
       
    81     * Returns the singleton instance. If it does not yet exist, it is created. 
       
    82     * If it does, a reference count is incremented
       
    83     * @since Series 60 3.0
       
    84     * @param none.
       
    85     * @return Instance to singleton class.
       
    86     */
       
    87     static CCRServerHandleSingleton* InstanceL();
       
    88 
       
    89     /**
       
    90     * Releases the singleton instance. If reference count reaches zero, the
       
    91     * instance is destroyed and client connection closed.
       
    92     */
       
    93     static void Release();  
       
    94 
       
    95     /**
       
    96     * Returns a reference to the service handle
       
    97     * @since Series 60 3.0
       
    98     * @param none.
       
    99     * @return Reference to RCRService
       
   100     */
       
   101     inline RCRService& Service() { return iService; }
       
   102 
       
   103 private: // Data
       
   104 
       
   105     /**
       
   106     * Amount of references to this instance.
       
   107     * Instance will be deleted when this reaches zero.
       
   108     */
       
   109     TInt iReferenceCount;
       
   110 
       
   111     /**
       
   112     * Handle to Recording Engine client.
       
   113     */
       
   114     RCRClient iClient;
       
   115 
       
   116     /**
       
   117     * Handle to Recording Engine services.
       
   118     */
       
   119     RCRService iService;
       
   120 
       
   121     };
       
   122 
       
   123 #endif // CCRSERVERHADLESINGLETON_H
       
   124 
       
   125 //  End of File