1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/frame/TlsData.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,122 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __TLSDATA_H__
1.20 +#define __TLSDATA_H__
1.21 +
1.22 +/**
1.23 +@internalComponent
1.24 +@file
1.25 +Comments : definition of the thread local storage data structure,
1.26 + and the global access pointer.
1.27 +*/
1.28 +#include <ecom/ecom.h>
1.29 +
1.30 +//Forward declarations
1.31 +class CLoadManager;
1.32 +class CGlobalData;
1.33 +
1.34 +/**
1.35 +CGlobalData class controls the life time of a single CEComSession instance and
1.36 +single CLoadManager instance. It works in a close cooperation with REComSession class.
1.37 +The life time of the CGlobalData singleton instance will be controlled by the following
1.38 +static and non-static methods of REComSession:
1.39 +1) REComSession::OpenL() (static method).
1.40 + CGlobalData singleton instance, so the CEComSession instance and CLoadManager instance,
1.41 + will be created during the first successfull call of REComSession::OpenL().
1.42 + Each next REComSession::OpenL() call will not create new CGlobalData instance,
1.43 + it will just increment the reference count of the already created singleton.
1.44 +2) REComSession::Close() (non-static method).
1.45 + It will not destroy the created CGlobalData singleton, it will just decrement its
1.46 + reference count.
1.47 +3) REcomSession::FinalClose() (static method).
1.48 + It will check the reference count of CGlobalData singleton and if it is less or equal to
1.49 + 0, then CGlobalData singleton, so the CEComSession instance and CLoadManager instance,
1.50 + will be destroyed.
1.51 +@internalComponent
1.52 +*/
1.53 +NONSHARABLE_CLASS(CGlobalData) : public CBase
1.54 + {
1.55 +public:
1.56 + static CGlobalData* NewL();
1.57 + static CGlobalData* Instance();
1.58 + virtual ~CGlobalData();
1.59 +
1.60 + inline TInt IncRefCnt();
1.61 + inline TInt DecRefCnt();
1.62 + inline TInt RefCnt() const;
1.63 +
1.64 + inline REComSession& EComSession();
1.65 + inline CLoadManager& LoadManager();
1.66 +
1.67 +private:
1.68 + CGlobalData();
1.69 + void ConstructL();
1.70 +
1.71 +private:
1.72 + /** The overall count of successfull REComSession::OpenL() calls. */
1.73 + TInt iRefCount;
1.74 + /** The single REComSession instance */
1.75 + REComSession iEComSession;
1.76 + /** Handles the loading of the dlls and the deletion of objects */
1.77 + CLoadManager* iLoadManager;
1.78 + };
1.79 +
1.80 +/**
1.81 +Increments the reference count of CGlobalData object.
1.82 +It should be called for every successfull call of REComSession::OpenL().
1.83 +@return Reference count value after the increment.
1.84 +*/
1.85 +inline TInt CGlobalData::IncRefCnt()
1.86 + {
1.87 + return ++iRefCount;
1.88 + }
1.89 +
1.90 +/**
1.91 +Decrements the CGlobalData object's reference count.
1.92 +It should be called from REComSession::Close().
1.93 +@return Reference count value after the decrement.
1.94 +*/
1.95 +inline TInt CGlobalData::DecRefCnt()
1.96 + {
1.97 + return --iRefCount;
1.98 + }
1.99 +
1.100 +/**
1.101 +It is used in REComSession::FinalClose().
1.102 +@return Reference count value.
1.103 +*/
1.104 +inline TInt CGlobalData::RefCnt() const
1.105 + {
1.106 + return iRefCount;
1.107 + }
1.108 +
1.109 +/**
1.110 +@return A reference to the controlled REComSession object.
1.111 +*/
1.112 +inline REComSession& CGlobalData::EComSession()
1.113 + {
1.114 + return iEComSession;
1.115 + }
1.116 +
1.117 +/**
1.118 +@return A reference to the controlled CLoadManager object.
1.119 +*/
1.120 +inline CLoadManager& CGlobalData::LoadManager()
1.121 + {
1.122 + return *iLoadManager;
1.123 + }
1.124 +
1.125 +#endif //__TLSDATA_H__