mtpfws/mtpfw/src/rmtpframework.cpp
changeset 49 c20dd21d1eb4
parent 0 d0791faffa3f
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    21 #include "cmtpparserrouter.h"
    21 #include "cmtpparserrouter.h"
    22 #include "cmtpstoragemgr.h"
    22 #include "cmtpstoragemgr.h"
    23 #include "rmtpframework.h"
    23 #include "rmtpframework.h"
    24 #include "cmtpdatacodegenerator.h"
    24 #include "cmtpdatacodegenerator.h"
    25 #include "cmtpservicemgr.h"
    25 #include "cmtpservicemgr.h"
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "rmtpframeworkTraces.h"
       
    29 #endif
       
    30 
    26 
    31 
    27 // Class constants.
    32 // Class constants.
    28 __FLOG_STMT(_LIT8(KComponent,"Framework");)
       
    29 
    33 
    30 /**
    34 /**
    31 Constructor.
    35 Constructor.
    32 */
    36 */
    33 EXPORT_C RMTPFramework::RMTPFramework() :
    37 EXPORT_C RMTPFramework::RMTPFramework() :
    39 /**
    43 /**
    40 Opens the singletons reference.
    44 Opens the singletons reference.
    41 */
    45 */
    42 EXPORT_C void RMTPFramework::OpenL()
    46 EXPORT_C void RMTPFramework::OpenL()
    43     {
    47     {
    44     __FLOG_OPEN(KMTPSubsystem, KComponent);
    48     OstTraceFunctionEntry0( RMTPFRAMEWORK_OPENL_ENTRY );
    45     __FLOG(_L8("OpenL - Entry"));
       
    46     iSingletons = &CSingletons::OpenL();
    49     iSingletons = &CSingletons::OpenL();
    47     iNested     = iSingletons->iConstructing;
    50     iNested     = iSingletons->iConstructing;
    48     __FLOG(_L8("OpenL - Exit"));
    51     OstTraceFunctionExit0( RMTPFRAMEWORK_OPENL_EXIT );
    49     }
    52     }
    50 
    53 
    51 /**
    54 /**
    52 Opens the singletons reference. The singletons reference is pushed onto the
    55 Opens the singletons reference. The singletons reference is pushed onto the
    53 cleanup stack.
    56 cleanup stack.
    54 */
    57 */
    55 EXPORT_C void RMTPFramework::OpenLC()
    58 EXPORT_C void RMTPFramework::OpenLC()
    56     {
    59     {
    57     __FLOG_OPEN(KMTPSubsystem, KComponent);
    60     OstTraceFunctionEntry0( RMTPFRAMEWORK_OPENLC_ENTRY );
    58     __FLOG(_L8("OpenLC - Entry"));
       
    59     ::CleanupClosePushL(*this);
    61     ::CleanupClosePushL(*this);
    60     OpenL();
    62     OpenL();
    61     __FLOG(_L8("OpenLC - Exit"));
    63     OstTraceFunctionExit0( RMTPFRAMEWORK_OPENLC_EXIT );
    62     }
    64     }
    63     
    65     
    64 /**
    66 /**
    65 Closes the singletons reference.
    67 Closes the singletons reference.
    66 */
    68 */
    67 EXPORT_C void RMTPFramework::Close()
    69 EXPORT_C void RMTPFramework::Close()
    68     {
    70     {
    69     __FLOG(_L8("Close - Entry"));
    71     OstTraceFunctionEntry0( RMTPFRAMEWORK_CLOSE_ENTRY );
    70     if ((iSingletons) && (!iNested))
    72     if ((iSingletons) && (!iNested))
    71         {
    73         {
    72         iSingletons->Close();
    74         iSingletons->Close();
    73         iSingletons = NULL;
    75         iSingletons = NULL;
    74         }
    76         }
    75     __FLOG(_L8("Close - Exit"));
    77     OstTraceFunctionExit0( RMTPFRAMEWORK_CLOSE_EXIT );
    76     __FLOG_CLOSE;
       
    77     }
    78     }
    78 
    79 
    79 EXPORT_C CMTPConnectionMgr& RMTPFramework::ConnectionMgr() const
    80 EXPORT_C CMTPConnectionMgr& RMTPFramework::ConnectionMgr() const
    80     {
    81     {
    81     __FLOG(_L8("ConnectionMgr - Entry"));
    82     OstTraceFunctionEntry0( RMTPFRAMEWORK_CONNECTIONMGR_ENTRY );
    82     __ASSERT_DEBUG(iSingletons, User::Invariant());
    83     __ASSERT_DEBUG(iSingletons, User::Invariant());
    83     __ASSERT_DEBUG(iSingletons->iSingletonConnectionMgr, User::Invariant());
    84     __ASSERT_DEBUG(iSingletons->iSingletonConnectionMgr, User::Invariant());
    84     __FLOG(_L8("ConnectionMgr - Exit"));
    85     OstTraceFunctionExit0( RMTPFRAMEWORK_CONNECTIONMGR_EXIT );
    85     return *(iSingletons->iSingletonConnectionMgr);
    86     return *(iSingletons->iSingletonConnectionMgr);
    86     }
    87     }
    87     
    88     
    88 EXPORT_C CMTPDataProviderController& RMTPFramework::DpController() const
    89 EXPORT_C CMTPDataProviderController& RMTPFramework::DpController() const
    89     {
    90     {
    90     __FLOG(_L8("DpController - Entry"));
    91     OstTraceFunctionEntry0( RMTPFRAMEWORK_DPCONTROLLER_ENTRY );
    91     __ASSERT_DEBUG(iSingletons, User::Invariant());
    92     __ASSERT_DEBUG(iSingletons, User::Invariant());
    92     __ASSERT_DEBUG(iSingletons->iSingletonDpController, User::Invariant());
    93     __ASSERT_DEBUG(iSingletons->iSingletonDpController, User::Invariant());
    93     __FLOG(_L8("DpController - Exit"));
    94     OstTraceFunctionExit0( RMTPFRAMEWORK_DPCONTROLLER_EXIT );
    94     return *(iSingletons->iSingletonDpController);
    95     return *(iSingletons->iSingletonDpController);
    95     }
    96     }
    96    
    97    
    97 EXPORT_C CMTPFrameworkConfig& RMTPFramework::FrameworkConfig() const
    98 EXPORT_C CMTPFrameworkConfig& RMTPFramework::FrameworkConfig() const
    98     {
    99     {
    99     __FLOG(_L8("FrameworkConfig - Entry"));
   100     OstTraceFunctionEntry0( RMTPFRAMEWORK_FRAMEWORKCONFIG_ENTRY );
   100     __ASSERT_DEBUG(iSingletons, User::Invariant());
   101     __ASSERT_DEBUG(iSingletons, User::Invariant());
   101     __ASSERT_DEBUG(iSingletons->iSingletonFrameworkConfig, User::Invariant());
   102     __ASSERT_DEBUG(iSingletons->iSingletonFrameworkConfig, User::Invariant());
   102     __FLOG(_L8("FrameworkConfig - Exit"));
   103     OstTraceFunctionExit0( RMTPFRAMEWORK_FRAMEWORKCONFIG_EXIT );
   103     return *(iSingletons->iSingletonFrameworkConfig);
   104     return *(iSingletons->iSingletonFrameworkConfig);
   104     }
   105     }
   105 
   106 
   106 EXPORT_C RFs& RMTPFramework::Fs() const
   107 EXPORT_C RFs& RMTPFramework::Fs() const
   107     {
   108     {
   108     __FLOG(_L8("Fs - Entry"));
   109     OstTraceFunctionEntry0( RMTPFRAMEWORK_FS_ENTRY );
   109     __ASSERT_DEBUG(iSingletons, User::Invariant());
   110     __ASSERT_DEBUG(iSingletons, User::Invariant());
   110     __FLOG(_L8("Fs - Exit"));
   111     OstTraceFunctionExit0( RMTPFRAMEWORK_FS_EXIT );
   111     return iSingletons->iSingletonFs;
   112     return iSingletons->iSingletonFs;
   112     }
   113     }
   113 
   114 
   114 EXPORT_C CMTPObjectMgr& RMTPFramework::ObjectMgr() const
   115 EXPORT_C CMTPObjectMgr& RMTPFramework::ObjectMgr() const
   115     {
   116     {
   116     __FLOG(_L8("ObjectMgr - Entry"));
   117     OstTraceFunctionEntry0( RMTPFRAMEWORK_OBJECTMGR_ENTRY );
   117     __ASSERT_DEBUG(iSingletons, User::Invariant());
   118     __ASSERT_DEBUG(iSingletons, User::Invariant());
   118     __ASSERT_DEBUG(iSingletons->iSingletonObjectMgr, User::Invariant());
   119     __ASSERT_DEBUG(iSingletons->iSingletonObjectMgr, User::Invariant());
   119     __FLOG(_L8("ObjectMgr - Exit"));
   120     OstTraceFunctionExit0( RMTPFRAMEWORK_OBJECTMGR_EXIT );
   120     return *(iSingletons->iSingletonObjectMgr);
   121     return *(iSingletons->iSingletonObjectMgr);
   121     }
   122     }
   122 
   123 
   123 EXPORT_C CMTPReferenceMgr& RMTPFramework::ReferenceMgr() const
   124 EXPORT_C CMTPReferenceMgr& RMTPFramework::ReferenceMgr() const
   124     {
   125     {
   125     __FLOG(_L8("ReferenceMgr - Entry"));
   126     OstTraceFunctionEntry0( RMTPFRAMEWORK_REFERENCEMGR_ENTRY );
   126     __ASSERT_DEBUG(iSingletons, User::Invariant());
   127     __ASSERT_DEBUG(iSingletons, User::Invariant());
   127     __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
   128     __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
   128     __FLOG(_L8("ReferenceMgr - Exit"));
   129     OstTraceFunctionExit0( RMTPFRAMEWORK_REFERENCEMGR_EXIT );
   129     return (iSingletons->iSingletonObjectMgr->ObjectStore().ReferenceMgr());
   130     return (iSingletons->iSingletonObjectMgr->ObjectStore().ReferenceMgr());
   130     }
   131     }
   131 
   132 
   132 EXPORT_C CMTPParserRouter& RMTPFramework::Router() const
   133 EXPORT_C CMTPParserRouter& RMTPFramework::Router() const
   133     {
   134     {
   134     __FLOG(_L8("Router - Entry"));
   135     OstTraceFunctionEntry0( RMTPFRAMEWORK_ROUTER_ENTRY );
   135     __ASSERT_DEBUG(iSingletons, User::Invariant());
   136     __ASSERT_DEBUG(iSingletons, User::Invariant());
   136     __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
   137     __ASSERT_DEBUG(iSingletons->iSingletonRouter, User::Invariant());
   137     __FLOG(_L8("Router - Exit"));
   138     OstTraceFunctionExit0( RMTPFRAMEWORK_ROUTER_EXIT );
   138     return *(iSingletons->iSingletonRouter);
   139     return *(iSingletons->iSingletonRouter);
   139     }
   140     }
   140 
   141 
   141 EXPORT_C CMTPStorageMgr& RMTPFramework::StorageMgr() const
   142 EXPORT_C CMTPStorageMgr& RMTPFramework::StorageMgr() const
   142     {
   143     {
   143     __FLOG(_L8("StorageMgr - Entry"));
   144     OstTraceFunctionEntry0( RMTPFRAMEWORK_STORAGEMGR_ENTRY );
   144     __ASSERT_DEBUG(iSingletons, User::Invariant());
   145     __ASSERT_DEBUG(iSingletons, User::Invariant());
   145     __ASSERT_DEBUG(iSingletons->iSingletonStorageMgr, User::Invariant());
   146     __ASSERT_DEBUG(iSingletons->iSingletonStorageMgr, User::Invariant());
   146     __FLOG(_L8("StorageMgr - Exit"));
   147     OstTraceFunctionExit0( RMTPFRAMEWORK_STORAGEMGR_EXIT );
   147     return *(iSingletons->iSingletonStorageMgr);
   148     return *(iSingletons->iSingletonStorageMgr);
   148     }
   149     }
   149 
   150 
   150 EXPORT_C CMTPDataCodeGenerator& RMTPFramework::DataCodeGenerator() const
   151 EXPORT_C CMTPDataCodeGenerator& RMTPFramework::DataCodeGenerator() const
   151     {
   152     {
   152     __FLOG(_L8("DataCodeGenerator - Entry"));
   153     OstTraceFunctionEntry0( RMTPFRAMEWORK_DATACODEGENERATOR_ENTRY );
   153     __ASSERT_DEBUG(iSingletons, User::Invariant());
   154     __ASSERT_DEBUG(iSingletons, User::Invariant());
   154     __ASSERT_DEBUG(iSingletons->iSingleDataCodeGenerator, User::Invariant());
   155     __ASSERT_DEBUG(iSingletons->iSingleDataCodeGenerator, User::Invariant());
   155     __FLOG(_L8("DataCodeGenerator - Exit"));
   156     OstTraceFunctionExit0( RMTPFRAMEWORK_DATACODEGENERATOR_EXIT );
   156     return *(iSingletons->iSingleDataCodeGenerator);
   157     return *(iSingletons->iSingleDataCodeGenerator);
   157     }
   158     }
   158 
   159 
   159 EXPORT_C CMTPServiceMgr& RMTPFramework::ServiceMgr() const
   160 EXPORT_C CMTPServiceMgr& RMTPFramework::ServiceMgr() const
   160     {
   161     {
   161     __FLOG(_L8("ServiceMgr - Entry"));
   162     OstTraceFunctionEntry0( RMTPFRAMEWORK_SERVICEMGR_ENTRY );
   162    __ASSERT_DEBUG(iSingletons, User::Invariant());
   163    __ASSERT_DEBUG(iSingletons, User::Invariant());
   163    __ASSERT_DEBUG(iSingletons->iSingleServiceMgr, User::Invariant());
   164    __ASSERT_DEBUG(iSingletons->iSingleServiceMgr, User::Invariant());
   164    __FLOG(_L8("ServiceMgr - Exit"));
   165    OstTraceFunctionExit0( RMTPFRAMEWORK_SERVICEMGR_EXIT );
   165    return *(iSingletons->iSingleServiceMgr);
   166    return *(iSingletons->iSingleServiceMgr);
   166     }
   167     }
   167 
   168 
   168 RMTPFramework::CSingletons& RMTPFramework::CSingletons::OpenL()
   169 RMTPFramework::CSingletons& RMTPFramework::CSingletons::OpenL()
   169     {
   170     {
   170     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry"));
   171     OstTraceFunctionEntry0( CSINGLETONS_OPENL_ENTRY );
   171     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   172     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   172     if (!self)
   173     if (!self)
   173         {
   174         {
   174         self = new(ELeave) CSingletons();
   175         self = new(ELeave) CSingletons();
   175         Dll::SetTls(reinterpret_cast<TAny*>(self));
   176         Dll::SetTls(reinterpret_cast<TAny*>(self));
   177         }
   178         }
   178     else if (!self->iConstructing)
   179     else if (!self->iConstructing)
   179         {        
   180         {        
   180         self->Inc();
   181         self->Inc();
   181         }
   182         }
   182     __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit"));
   183     OstTraceFunctionExit0( CSINGLETONS_OPENL_EXIT );
   183     return *self;
   184     return *self;
   184     }
   185     }
   185     
   186     
   186 void RMTPFramework::CSingletons::Close()
   187 void RMTPFramework::CSingletons::Close()
   187     {
   188     {   
   188     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   189     CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls()));
   189     if (self)
   190     if (self)
   190         {
   191         {
   191         __FLOG(_L8("CSingletons::Close - Entry"));
   192         OstTraceFunctionEntry0( CSINGLETONS_CLOSE_ENTRY );
   192         self->Dec();
   193         self->Dec();
   193         if (self->AccessCount() == 0)
   194         if (self->AccessCount() == 0)
   194             {
   195             {
   195             __FLOG(_L8("CSingletons::Close - Exit"));
   196             OstTraceFunctionExit0( CSINGLETONS_CLOSE_EXIT );
   196             delete self;
   197             delete self;
   197             Dll::SetTls(NULL);
   198             Dll::SetTls(NULL);
   198             }
   199             }
   199         else
   200         else
   200             {
   201             {
   201             __FLOG(_L8("CSingletons::Close - Exit"));
   202             OstTraceFunctionExit0( DUP1_CSINGLETONS_CLOSE_EXIT );
   202             }
   203             }
   203         }
   204         }
   204     }
   205     }
   205     
   206     
   206 RMTPFramework::CSingletons::~CSingletons()
   207 RMTPFramework::CSingletons::~CSingletons()
   207     {
   208     {
   208     __FLOG(_L8("CSingletons::~CSingletons - Entry"));
   209     OstTraceFunctionEntry0( RMTPFRAMEWORK_CSINGLETONS_CSINGLETONS_DES_ENTRY );
   209     delete iSingletonStorageMgr;
   210     delete iSingletonStorageMgr;
   210     delete iSingletonRouter;
   211     delete iSingletonRouter;
   211     delete iSingletonDpController;
   212     delete iSingletonDpController;
   212     delete iSingletonObjectMgr;
   213     delete iSingletonObjectMgr;
   213     delete iSingletonFrameworkConfig;
   214     delete iSingletonFrameworkConfig;
   214     delete iSingletonConnectionMgr;
   215     delete iSingletonConnectionMgr;
   215     delete iSingleDataCodeGenerator;
   216     delete iSingleDataCodeGenerator;
   216     delete iSingleServiceMgr;
   217     delete iSingleServiceMgr;
   217     
   218     
   218     iSingletonFs.Close();
   219     iSingletonFs.Close();
   219     __FLOG(_L8("CSingletons::~CSingletons - Exit"));
   220     OstTraceFunctionExit0( RMTPFRAMEWORK_CSINGLETONS_CSINGLETONS_DES_EXIT );
   220     __FLOG_CLOSE;
       
   221     }
   221     }
   222     
   222     
   223 void RMTPFramework::CSingletons::ConstructL()
   223 void RMTPFramework::CSingletons::ConstructL()
   224     {
   224     {
   225     __FLOG_OPEN(KMTPSubsystem, KComponent);
   225     OstTraceFunctionEntry0( CSINGLETONS_CONSTRUCTL_ENTRY );
   226     __FLOG(_L8("CSingletons::ConstructL - Entry"));
       
   227     iConstructing = ETrue;
   226     iConstructing = ETrue;
   228     
   227     
   229 	User::LeaveIfError(iSingletonFs.Connect());
   228 	User::LeaveIfError(iSingletonFs.Connect());
   230     iSingletonFrameworkConfig   = CMTPFrameworkConfig::NewL();
   229     iSingletonFrameworkConfig   = CMTPFrameworkConfig::NewL();
   231     iSingletonConnectionMgr     = CMTPConnectionMgr::NewL();
   230     iSingletonConnectionMgr     = CMTPConnectionMgr::NewL();
   235     iSingletonStorageMgr        = CMTPStorageMgr::NewL();
   234     iSingletonStorageMgr        = CMTPStorageMgr::NewL();
   236     iSingleDataCodeGenerator    = CMTPDataCodeGenerator::NewL();
   235     iSingleDataCodeGenerator    = CMTPDataCodeGenerator::NewL();
   237     iSingleServiceMgr           = CMTPServiceMgr::NewL();
   236     iSingleServiceMgr           = CMTPServiceMgr::NewL();
   238     
   237     
   239     iConstructing = EFalse;
   238     iConstructing = EFalse;
   240     __FLOG(_L8("CSingletons::ConstructL - Exit"));
   239     OstTraceFunctionExit0( CSINGLETONS_CONSTRUCTL_EXIT );
   241     }
   240     }