mtpfws/mtpfw/dataproviders/devdp/src/rmtpdevicedpsingletons.cpp
changeset 47 63cf70d3ecd8
parent 17 aabe5387f5ce
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    21 #include <e32std.h>
    21 #include <e32std.h>
    22 #include "cmtpdevicedatastore.h"
    22 #include "cmtpdevicedatastore.h"
    23 #include "cmtpdevicedpconfigmgr.h"
    23 #include "cmtpdevicedpconfigmgr.h"
    24 #include "cmtpstoragewatcher.h"
    24 #include "cmtpstoragewatcher.h"
    25 #include "rmtpdevicedpsingletons.h"
    25 #include "rmtpdevicedpsingletons.h"
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "rmtpdevicedpsingletonsTraces.h"
       
    29 #endif
       
    30 
    26 
    31 
    27 // Class constants.
    32 // Class constants.
    28 __FLOG_STMT(_LIT8(KComponent,"DeviceDpSingletons");)
       
    29 
    33 
    30 /**
    34 /**
    31 Constructor.
    35 Constructor.
    32 */
    36 */
    33 RMTPDeviceDpSingletons::RMTPDeviceDpSingletons() :
    37 RMTPDeviceDpSingletons::RMTPDeviceDpSingletons() :
    39 /**
    43 /**
    40 Opens the singletons reference.
    44 Opens the singletons reference.
    41 */
    45 */
    42 void RMTPDeviceDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    46 void RMTPDeviceDpSingletons::OpenL(MMTPDataProviderFramework& aFramework)
    43     {
    47     {
    44     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
    45     __FLOG(_L8("OpenL - Entry"));
       
    46     iSingletons = &CSingletons::OpenL(aFramework);
    48     iSingletons = &CSingletons::OpenL(aFramework);
    47     __FLOG(_L8("OpenL - Exit"));
       
    48     }
    49     }
    49     
    50     
    50 /**
    51 /**
    51 Closes the singletons reference.
    52 Closes the singletons reference.
    52 */
    53 */
    53 void RMTPDeviceDpSingletons::Close()
    54 void RMTPDeviceDpSingletons::Close()
    54     {
    55     {
    55     __FLOG(_L8("Close - Entry"));
    56     OstTraceFunctionEntry0( RMTPDEVICEDPSINGLETONS_CLOSE_ENTRY );
    56     if (iSingletons)
    57     if (iSingletons)
    57         {
    58         {
    58         iSingletons->Close();
    59         iSingletons->Close();
    59         iSingletons = NULL;
    60         iSingletons = NULL;
    60         }
    61         }
    61     __FLOG(_L8("Close - Exit"));
    62     OstTraceFunctionExit0( RMTPDEVICEDPSINGLETONS_CLOSE_EXIT );
    62     __FLOG_CLOSE;
       
    63     }
    63     }
    64 
    64 
    65 /**
    65 /**
    66 Provides a handle to the MTP device data provider's device information data 
    66 Provides a handle to the MTP device data provider's device information data 
    67 store singleton.
    67 store singleton.
    68 @return The device information data store singleton.
    68 @return The device information data store singleton.
    69 */
    69 */
    70 CMTPDeviceDataStore& RMTPDeviceDpSingletons::DeviceDataStore()
    70 CMTPDeviceDataStore& RMTPDeviceDpSingletons::DeviceDataStore()
    71     {
    71     {
    72     __FLOG(_L8("DeviceDataStore - Entry"));
    72     OstTraceFunctionEntry0( RMTPDEVICEDPSINGLETONS_DEVICEDATASTORE_ENTRY );
    73     __ASSERT_DEBUG(iSingletons, User::Invariant());
    73     __ASSERT_DEBUG(iSingletons, User::Invariant());
    74     __ASSERT_DEBUG(iSingletons->iDeviceDataStore, User::Invariant());
    74     __ASSERT_DEBUG(iSingletons->iDeviceDataStore, User::Invariant());
    75     __FLOG(_L8("DeviceDataStore - Exit"));
    75     OstTraceFunctionExit0( RMTPDEVICEDPSINGLETONS_DEVICEDATASTORE_EXIT );
    76     return *iSingletons->iDeviceDataStore;
    76     return *iSingletons->iDeviceDataStore;
    77     }
    77     }
    78 
    78 
    79 /**
    79 /**
    80 Provides a handle to the MTP device data provider's config manager singleton.
    80 Provides a handle to the MTP device data provider's config manager singleton.
    81 @return The device config manager singleton.
    81 @return The device config manager singleton.
    82 */
    82 */
    83     
    83     
    84 CMTPDeviceDpConfigMgr& RMTPDeviceDpSingletons::ConfigMgr()
    84 CMTPDeviceDpConfigMgr& RMTPDeviceDpSingletons::ConfigMgr()
    85 	{
    85 	{
    86     __FLOG(_L8("ConfigMgr - Entry"));
    86     OstTraceFunctionEntry0( RMTPDEVICEDPSINGLETONS_CONFIGMGR_ENTRY );
    87     __ASSERT_DEBUG(iSingletons, User::Invariant());
    87     __ASSERT_DEBUG(iSingletons, User::Invariant());
    88     __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
    88     __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant());
    89     __FLOG(_L8("ConfigMgr - Exit"));
    89     OstTraceFunctionExit0( RMTPDEVICEDPSINGLETONS_CONFIGMGR_EXIT );
    90     return *iSingletons->iConfigMgr;
    90     return *iSingletons->iConfigMgr;
    91 	}
    91 	}
    92 
    92 
    93 RMTPDeviceDpSingletons::CSingletons* RMTPDeviceDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
    93 RMTPDeviceDpSingletons::CSingletons* RMTPDeviceDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework)
    94     {
    94     {
       
    95     OstTraceFunctionEntry0( CSINGLETONS_NEWL_ENTRY );
    95     CSingletons* self(new(ELeave) CSingletons());
    96     CSingletons* self(new(ELeave) CSingletons());
    96     CleanupStack::PushL(self);
    97     CleanupStack::PushL(self);
    97     self->ConstructL(aFramework);
    98     self->ConstructL(aFramework);
    98     CleanupStack::Pop(self);
    99     CleanupStack::Pop(self);
       
   100     OstTraceFunctionExit0( CSINGLETONS_NEWL_EXIT );
    99     return self;
   101     return self;
   100     }
   102     }
   101 
   103 
   102 RMTPDeviceDpSingletons::CSingletons& RMTPDeviceDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
   104 RMTPDeviceDpSingletons::CSingletons& RMTPDeviceDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework)
   103     {
   105     {
   104     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
   106     OstTraceFunctionEntry0( CSINGLETONS_OPENL_ENTRY );
   105     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   107     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   106     if (!self)
   108     if (!self)
   107         {
   109         {
   108         self = CSingletons::NewL(aFramework);
   110         self = CSingletons::NewL(aFramework);
   109         Dll::SetTls(reinterpret_cast<TAny*>(self));
   111         Dll::SetTls(reinterpret_cast<TAny*>(self));
   110         }
   112         }
   111     else
   113     else
   112         {        
   114         {        
   113         self->Inc();
   115         self->Inc();
   114         }
   116         }
   115     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
   117     OstTraceFunctionExit0( CSINGLETONS_OPENL_EXIT );
   116     return *self;
   118     return *self;
   117     }
   119     }
   118     
   120     
   119 void RMTPDeviceDpSingletons::CSingletons::Close()
   121 void RMTPDeviceDpSingletons::CSingletons::Close()
   120     {
   122     {
   121     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   123     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   122     if (self)
   124     if (self)
   123         {
   125         {
   124         __FLOG(_L8("CSingletons::Close - Entry"));
   126         OstTraceFunctionEntry0( RMTPDEVICEDPSINGLETONS_CSINGLETONS_CLOSE_ENTRY );
   125         self->Dec();
   127         self->Dec();
   126         if (self->AccessCount() == 0)
   128         if (self->AccessCount() == 0)
   127             {
   129             {
   128             __FLOG(_L8("CSingletons::Close - Exit"));
   130             OstTraceFunctionExit0( RMTPDEVICEDPSINGLETONS_CSINGLETONS_CLOSE_EXIT );
   129             delete self;
   131             delete self;
   130             Dll::SetTls(NULL);
   132             Dll::SetTls(NULL);
   131             }
   133             }
   132         else
   134         else
   133             {
   135             {
   134             __FLOG(_L8("CSingletons::Close - Exit"));
   136             OstTraceFunctionExit0( DUP1_RMTPDEVICEDPSINGLETONS_CSINGLETONS_CLOSE_EXIT );
   135             }
   137             }
   136         }
   138         }
   137     }
   139     }
   138     
   140     
   139 RMTPDeviceDpSingletons::CSingletons::~CSingletons()
   141 RMTPDeviceDpSingletons::CSingletons::~CSingletons()
   140     {
   142     {
   141     __FLOG(_L8("CSingletons::~CSingletons - Entry"));
   143     OstTraceFunctionEntry0( CSINGLETONS_CSINGLETONS_ENTRY );
   142     delete iConfigMgr;
   144     delete iConfigMgr;
   143     delete iDeviceDataStore;
   145     delete iDeviceDataStore;
   144     iPendingStorages.Close();
   146     iPendingStorages.Close();
   145     __FLOG(_L8("CSingletons::~CSingletons - Exit"));
   147     OstTraceFunctionExit0( CSINGLETONS_CSINGLETONS_EXIT );
   146     __FLOG_CLOSE;
       
   147     }
   148     }
   148     
   149     
   149 void RMTPDeviceDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
   150 void RMTPDeviceDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework)
   150     {
   151     {
   151     __FLOG_OPEN(KMTPSubsystem, KComponent);
   152     OstTraceFunctionEntry0( CSINGLETONS_CONSTRUCTL_ENTRY );
   152     __FLOG(_L8("CSingletons::ConstructL - Entry"));
       
   153     iDeviceDataStore = CMTPDeviceDataStore::NewL();
   153     iDeviceDataStore = CMTPDeviceDataStore::NewL();
   154     iConfigMgr = CMTPDeviceDpConfigMgr::NewL(aFramework);
   154     iConfigMgr = CMTPDeviceDpConfigMgr::NewL(aFramework);
   155     __FLOG(_L8("CSingletons::ConstructL - Exit"));
   155     OstTraceFunctionExit0( CSINGLETONS_CONSTRUCTL_EXIT );
   156     }
   156     }
   157 
   157 
   158 RArray<TUint>& RMTPDeviceDpSingletons::PendingStorages()
   158 RArray<TUint>& RMTPDeviceDpSingletons::PendingStorages()
   159 	{
   159 	{
   160     __FLOG(_L8("PendingStorages - Entry"));
   160     OstTraceFunctionEntry0( RMTPDEVICEDPSINGLETONS_PENDINGSTORAGES_ENTRY );
   161     __ASSERT_DEBUG(iSingletons, User::Invariant());
   161     __ASSERT_DEBUG(iSingletons, User::Invariant());
   162     __FLOG(_L8("PendingStorages - Exit"));
   162     OstTraceFunctionExit0( RMTPDEVICEDPSINGLETONS_PENDINGSTORAGES_EXIT );
   163     return iSingletons->iPendingStorages;
   163     return iSingletons->iPendingStorages;
   164 	}
   164 	}
   165 
   165