tracesrv/tracecore/btrace_handler/src/TraceCoreNotificationReceiver.cpp
changeset 56 aa2539c91954
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Base class for notification receivers of TraceCore
       
    15 //
       
    16 
       
    17 #include "TraceCoreNotificationReceiver.h"
       
    18 #include "TraceCore.h"
       
    19 #include "TraceCoreNotifier.h"
       
    20 #include "TraceCoreDebug.h"
       
    21 #include "TraceCoreConstants.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "TraceCoreNotificationReceiverTraces.h"
       
    25 #endif
       
    26 
       
    27 #include "TraceCoreTComArgMacro.h"
       
    28 
       
    29 /**
       
    30  * Constructor
       
    31  */
       
    32 EXPORT_C MTraceCoreNotificationReceiver::MTraceCoreNotificationReceiver()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 /**
       
    38  * Destructor
       
    39  */
       
    40 EXPORT_C MTraceCoreNotificationReceiver::~MTraceCoreNotificationReceiver()
       
    41     {
       
    42     UnregisterNotificationReceiver();
       
    43     }
       
    44 
       
    45 
       
    46 /**
       
    47  * Register notification receiver by component id
       
    48  * 
       
    49  * @param aComponentId The component ID
       
    50  */
       
    51 EXPORT_C TInt MTraceCoreNotificationReceiver::RegisterNotificationReceiver( TUint32 aComponentId )
       
    52     {
       
    53     return RegisterNotificationReceiver( aComponentId, KAllGroups );
       
    54     }
       
    55     
       
    56 /**
       
    57  * Register notification receiver by component id and group id
       
    58  * 
       
    59  * @param aComponentId The component ID
       
    60  * @param aGroupId The group ID 
       
    61  */
       
    62 EXPORT_C TInt MTraceCoreNotificationReceiver::RegisterNotificationReceiver( TUint32 aComponentId, TInt32 aGroupId )
       
    63     {
       
    64     OstTraceExt2( TRACE_BORDER, MTRACECORENOTIFICATIONRECEIVER_REGISTERNOTIFICATIONRECEIVER_ENTRY, "> MTraceCoreNotificationReceiver::RegisterNotificationReceiver. CID:0x%x GID:0x%x", aComponentId, aGroupId );
       
    65     TInt ret;
       
    66     
       
    67     // Get TraceCore
       
    68     DTraceCore* traceCore = DTraceCore::GetInstance();
       
    69     if ( traceCore != NULL )
       
    70         {
       
    71         TNotificationReceiverItem notificationReceiverItem;
       
    72         notificationReceiverItem.iComponentID = aComponentId;
       
    73         notificationReceiverItem.iGroupID = aGroupId;
       
    74         notificationReceiverItem.iReceiver = this;
       
    75         
       
    76         // Register notification receiver
       
    77         ret = traceCore->GetNotifier().RegisterNotificationReceiver( notificationReceiverItem );
       
    78         }
       
    79     else
       
    80         {
       
    81         ret = KErrGeneral;
       
    82         }
       
    83     OstTrace1( TRACE_BORDER, MTRACECORENOTIFICATIONRECEIVER_REGISTERNOTIFICATIONRECEIVER_EXIT, "< MTraceCoreNotificationReceiver::RegisterNotificationReceiver. Ret:%d", ret );
       
    84     return ret;
       
    85     }
       
    86     
       
    87 
       
    88 /**
       
    89  * Unregister notification receiver by component id
       
    90  * 
       
    91  * @param aComponentId The component ID
       
    92  */
       
    93 EXPORT_C void MTraceCoreNotificationReceiver::UnregisterNotificationReceiver( TUint32 aComponentId )
       
    94     {
       
    95     
       
    96     UnregisterNotificationReceiver( aComponentId, KAllGroups );
       
    97     }
       
    98     
       
    99 /**
       
   100  * Unregister notification receiver by component id and group id
       
   101  * 
       
   102  * @param aComponentId The component ID
       
   103  * @param aGroupId The group ID  
       
   104  */
       
   105 EXPORT_C void MTraceCoreNotificationReceiver::UnregisterNotificationReceiver( TUint32 aComponentId, TInt32 aGroupId )
       
   106     {
       
   107     OstTraceExt2( TRACE_BORDER, MTRACECORENOTIFICATIONRECEIVER_UNREGISTERNOTIFICATIONRECEIVER_ENTRY, "> MTraceCoreNotificationReceiver::UnregisterNotificationReceiver. CID:0x%x GID:0x%x", aComponentId, aGroupId );
       
   108     DTraceCore* traceCore = DTraceCore::GetInstance();
       
   109     if ( traceCore != NULL )
       
   110         {
       
   111         TNotificationReceiverItem notificationReceiverItem;
       
   112         notificationReceiverItem.iComponentID = aComponentId;
       
   113         notificationReceiverItem.iGroupID = aGroupId;
       
   114         notificationReceiverItem.iReceiver = this;
       
   115         traceCore->GetNotifier().UnregisterNotificationReceiver( notificationReceiverItem );
       
   116         }
       
   117     }
       
   118 
       
   119 /**
       
   120  * Unsubscribes all message ID's of this notification receiver
       
   121  */
       
   122 void MTraceCoreNotificationReceiver::UnregisterNotificationReceiver()
       
   123     {
       
   124     // Get TraceCore
       
   125     DTraceCore* traceCore = DTraceCore::GetInstance();
       
   126     if ( traceCore != NULL )
       
   127         {
       
   128         
       
   129         // Unregister notification receiver
       
   130         traceCore->GetNotifier().UnregisterNotificationReceiver( *this );
       
   131         }
       
   132     }
       
   133 
       
   134 /**
       
   135  * Callback function for trace error
       
   136  * 
       
   137  * @param aComponentId The component ID
       
   138  * @param aGroupId The group ID    
       
   139  * @param aError The reason for error
       
   140  */
       
   141 EXPORT_C void MTraceCoreNotificationReceiver::TraceError( TUint32 TCOM_ARG(aComponentId), 
       
   142                                                           TUint32 TCOM_ARG(aGroupId), 
       
   143                                                           TInt TCOM_ARG(aError)  )
       
   144     {
       
   145     OstTraceExt3( TRACE_BORDER, MTRACECORENOTIFICATIONRECEIVER_TRACEERROR_ENTRY, "> MTraceCoreNotificationReceiver::TraceError. CID:0x%x GID:0x%x Err:%d", aComponentId, aGroupId, (TInt32) aError );
       
   146     }
       
   147 
       
   148 // End of File