mtpdataproviders/mtpfileandfolderdp/src/rmtpfiledpsingletons.cpp
changeset 49 c20dd21d1eb4
parent 0 d0791faffa3f
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    17 
    17 
    18 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpdataproviderframework.h>
    19 #include <mtp/cmtpobjectmetadata.h>
    19 #include <mtp/cmtpobjectmetadata.h>
    20 
    20 
    21 #include "cmtpfiledpconfigmgr.h"
    21 #include "cmtpfiledpconfigmgr.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "rmtpfiledpsingletonsTraces.h"
       
    25 #endif
       
    26 
    22 
    27 
    23 // Class constants.
    28 // Class constants.
    24 __FLOG_STMT(_LIT8(KComponent,"FileDpSingletons");)
       
    25 
    29 
    26 /**
    30 /**
    27 Constructor.
    31 Constructor.
    28 */
    32 */
    29 RMTPFileDpSingletons::RMTPFileDpSingletons() :
    33 RMTPFileDpSingletons::RMTPFileDpSingletons() :
    34 /**
    38 /**
    35 Opens the singletons reference.
    39 Opens the singletons reference.
    36 */
    40 */
    37 void RMTPFileDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    41 void RMTPFileDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    38     {
    42     {
    39     __FLOG_OPEN(KMTPSubsystem, KComponent);
    43     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_OPENL_ENTRY );
    40     __FLOG(_L8("OpenL - Entry"));
       
    41     iSingletons = &CSingletons::OpenL(aFramework);
    44     iSingletons = &CSingletons::OpenL(aFramework);
    42     __FLOG(_L8("OpenL - Exit"));
    45     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_OPENL_EXIT );
    43     }
    46     }
    44     
    47     
    45 /**
    48 /**
    46 Closes the singletons reference.
    49 Closes the singletons reference.
    47 */
    50 */
    48 void RMTPFileDpSingletons::Close()
    51 void RMTPFileDpSingletons::Close()
    49     {
    52     {
    50     __FLOG(_L8("Close - Entry"));
    53     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_CLOSE_ENTRY );
    51     if (iSingletons)
    54     if (iSingletons)
    52         {
    55         {
    53         iSingletons->Close();
    56         iSingletons->Close();
    54         iSingletons = NULL;
    57         iSingletons = NULL;
    55         }
    58         }
    56     __FLOG(_L8("Close - Exit"));
    59     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_CLOSE_EXIT );
    57     __FLOG_CLOSE;
       
    58     }
    60     }
    59 
    61 
    60 /**
    62 /**
    61 Provides a handle to the MTP file data provider's configuration manager.
    63 Provides a handle to the MTP file data provider's configuration manager.
    62 @return The file data provider configuration manager.
    64 @return The file data provider configuration manager.
    63 */
    65 */
    64 
    66 
    65 CMTPFileDpConfigMgr& RMTPFileDpSingletons::FrameworkConfig()
    67 CMTPFileDpConfigMgr& RMTPFileDpSingletons::FrameworkConfig()
    66     {
    68     {
    67     __FLOG(_L8("FrameworkConfig - Entry"));
    69     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_FRAMEWORKCONFIG_ENTRY );
    68     __ASSERT_DEBUG(iSingletons, User::Invariant());
    70     __ASSERT_DEBUG(iSingletons, User::Invariant());
    69     __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
    71     __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
    70     __FLOG(_L8("FrameworkConfig - Exit"));
    72     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_FRAMEWORKCONFIG_EXIT );
    71     return *iSingletons->iConfigMgr;
    73     return *iSingletons->iConfigMgr;
    72     }
    74     }
    73 
    75 
    74 RMTPFileDpSingletons::CSingletons* RMTPFileDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
    76 RMTPFileDpSingletons::CSingletons* RMTPFileDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
    75     {
    77     {
    80     return self;
    82     return self;
    81     }
    83     }
    82 
    84 
    83 RMTPFileDpSingletons::CSingletons& RMTPFileDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    85 RMTPFileDpSingletons::CSingletons& RMTPFileDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    84     {
    86     {
    85     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
    87     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_CSINGLETONS_OPENL_ENTRY );
    86     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
    88     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
    87     if (!self)
    89     if (!self)
    88         {
    90         {
    89         self = CSingletons::NewL(aFramework);
    91         self = CSingletons::NewL(aFramework);
    90         Dll::SetTls(reinterpret_cast<TAny*>(self));
    92         Dll::SetTls(reinterpret_cast<TAny*>(self));
    91         }
    93         }
    92     else
    94     else
    93         {        
    95         {        
    94         self->Inc();
    96         self->Inc();
    95         }
    97         }
    96     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
    98     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_CSINGLETONS_OPENL_EXIT );
    97     return *self;
    99     return *self;
    98     }
   100     }
    99     
   101     
   100 void RMTPFileDpSingletons::CSingletons::Close()
   102 void RMTPFileDpSingletons::CSingletons::Close()
   101     {
   103     {
   102     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   104     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   103     if (self)
   105     if (self)
   104         {
   106         {
   105         __FLOG(_L8("CSingletons::Close - Entry"));
   107         OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_CSINGLETONS_CLOSE_ENTRY );
   106         self->Dec();
   108         self->Dec();
   107         if (self->AccessCount() == 0)
   109         if (self->AccessCount() == 0)
   108             {
   110             {
   109             __FLOG(_L8("CSingletons::Close - Exit"));
   111             OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_CSINGLETONS_CLOSE_EXIT );
   110             delete self;
   112             delete self;
   111             Dll::SetTls(NULL);
   113             Dll::SetTls(NULL);
   112             }
   114             }
   113         else
   115         else
   114             {
   116             {
   115             __FLOG(_L8("CSingletons::Close - Exit"));
   117             OstTraceFunctionExit0( DUP1_RMTPFILEDPSINGLETONS_CSINGLETONS_CLOSE_EXIT );
   116             }
   118             }
   117         }
   119         }
   118     }
   120     }
   119     
   121     
   120 RMTPFileDpSingletons::CSingletons::~CSingletons()
   122 RMTPFileDpSingletons::CSingletons::~CSingletons()
   121     {
   123     {
   122     __FLOG(_L8("CSingletons::~CSingletons - Entry"));
   124     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_CSINGLETONS_CSINGLETONS_ENTRY );
   123     delete iConfigMgr;
   125     delete iConfigMgr;
   124     __FLOG(_L8("CSingletons::~CSingletons - Exit"));
   126     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_CSINGLETONS_CSINGLETONS_EXIT );
   125     __FLOG_CLOSE;
       
   126     }
   127     }
   127     
   128     
   128 void RMTPFileDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
   129 void RMTPFileDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
   129     {
   130     {
   130     __FLOG_OPEN(KMTPSubsystem, KComponent);
   131     OstTraceFunctionEntry0( RMTPFILEDPSINGLETONS_CSINGLETONS_CONSTRUCTL_ENTRY );
   131     __FLOG(_L8("CSingletons::ConstructL - Entry"));
       
   132     iConfigMgr = CMTPFileDpConfigMgr::NewL(aFramework);
   132     iConfigMgr = CMTPFileDpConfigMgr::NewL(aFramework);
   133     __FLOG(_L8("CSingletons::ConstructL - Exit"));
   133     OstTraceFunctionExit0( RMTPFILEDPSINGLETONS_CSINGLETONS_CONSTRUCTL_EXIT );
   134     }
   134     }
   135 
   135 
   136 
   136 
   137 
   137