phonebookui/Phonebook/inc/CPbkExtGlobals.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 "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 *       PbkExt.dll global variables. A singleton class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkExtGlobals_H__
       
    21 #define __CPbkExtGlobals_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "CPbkExtensionScanner.h" // CPbkExtensionArray typedef
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class MPbkExtensionFactory;
       
    29 class CPbkMultiExtensionFactory;
       
    30 class MPbkUiExtensionBase;
       
    31 
       
    32 /**
       
    33  * Singleton class.
       
    34  */
       
    35 class CPbkExtGlobals : public CBase
       
    36     {
       
    37     public:
       
    38         /**
       
    39          * Returns the instance of this class.
       
    40          */
       
    41         IMPORT_C static CPbkExtGlobals* InstanceL();
       
    42 
       
    43         /**
       
    44          * Returns the extensionfactory. If no instance exists yet it is 
       
    45 		 * created.
       
    46          */
       
    47         IMPORT_C MPbkExtensionFactory& FactoryL();
       
    48 
       
    49         /**
       
    50          * Pushes this object to cleanup stack for releasing.
       
    51          */
       
    52         void PushL();
       
    53 
       
    54     private: // Interface for Release(CPbkExtGlobals*)
       
    55 		friend void Release(CPbkExtGlobals*);
       
    56         virtual void DoRelease();
       
    57 		static void CleanupRelease(TAny* aObj);
       
    58 
       
    59     private: // Implementation
       
    60         CPbkExtGlobals();
       
    61         ~CPbkExtGlobals();
       
    62         static CPbkExtGlobals* NewLC();
       
    63         void IncRef();
       
    64         TInt DecRef();
       
    65         void ScanExtensionsL();
       
    66     private: // Data
       
    67         /// Reference count
       
    68         TInt iRefCount;
       
    69         /// Array of extensions
       
    70         CPbkExtensionArray iExtensions;
       
    71         /// Own: Extension factory
       
    72 		CPbkMultiExtensionFactory* iMultiFactory;
       
    73     };
       
    74 
       
    75 // INLINE FUNCTIONS
       
    76 
       
    77 inline void CPbkExtGlobals::PushL()
       
    78 	{
       
    79     CleanupStack::PushL(TCleanupItem(CleanupRelease,this)); 
       
    80 	}
       
    81 
       
    82 inline void Release(CPbkExtGlobals* aObj)
       
    83 	{
       
    84 	if (aObj)
       
    85 		{
       
    86 		aObj->DoRelease();
       
    87 		}
       
    88 	}
       
    89 
       
    90 inline void CPbkExtGlobals::CleanupRelease(TAny* aObj)
       
    91     { 
       
    92     Release(static_cast<CPbkExtGlobals*>(aObj)); 
       
    93     }
       
    94 
       
    95 #endif // __CPbkExtGlobals_H__
       
    96 
       
    97 // End of File