tracefw/tracecompiler/test/TracesInHeadersApps/singlemmp_diffnames/dll/src/HelloTraceInterface.cpp
changeset 56 aa2539c91954
parent 54 a151135b0cf9
child 60 e54443a6878c
child 62 1c2bb2fc7c87
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "HelloTraceInterface.h"
       
    21 #include "HelloTraceInterfaceDup.h"
       
    22 #include "HelloTraceInterfaceDup2.inl"
       
    23 #include "HelloTracePanic.h"
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "HelloTraceInterfaceTraces.h"
       
    27 #endif
       
    28 
       
    29 EXPORT_C CHelloTraceInterface* CHelloTraceInterface::NewLC()
       
    30     {
       
    31     CHelloTraceInterface* self = new (ELeave) CHelloTraceInterface;
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL();
       
    34     return self;
       
    35     }
       
    36 
       
    37 EXPORT_C CHelloTraceInterface* CHelloTraceInterface::NewL()
       
    38     {
       
    39     CHelloTraceInterface* self = CHelloTraceInterface::NewLC();
       
    40     CleanupStack::Pop(self);
       
    41     return self;
       
    42     }
       
    43 
       
    44 CHelloTraceInterface::CHelloTraceInterface()
       
    45     {
       
    46     OstTrace1( TRACE_NORMAL, CHELLOTRACEDLL_CHELLOTRACEDLL_CTOR, "[0x%08x]", (TUint32) this );    
       
    47     }
       
    48 
       
    49 void CHelloTraceInterface::ConstructL()
       
    50     {
       
    51     iString = new (ELeave) THelloTraceDllExampleString;
       
    52     }
       
    53 
       
    54 EXPORT_C CHelloTraceInterface::~CHelloTraceInterface()
       
    55     {
       
    56     delete iString;
       
    57     OstTrace1( TRACE_NORMAL, CHELLOTRACEDLL_CHELLOTRACEDLL_DTOR, "[0x%08x]", (TUint32) this );    
       
    58     }
       
    59 
       
    60 EXPORT_C TVersion CHelloTraceInterface::Version()
       
    61     {
       
    62     const TInt KMajor = 1;
       
    63     const TInt KMinor = 0;
       
    64     const TInt KBuild = 1;
       
    65     TVersion version = TVersion(KMajor, KMinor, KBuild);
       
    66     OstTraceExt1( TRACE_BORDER, CHELLOTRACEDLL_VERSION, "CHelloTraceInterface::Version = %S", version.Name());   
       
    67     return version;
       
    68     }
       
    69 
       
    70 EXPORT_C const TPtrC CHelloTraceInterface::String() const
       
    71     {
       
    72     __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer));
       
    73 
       
    74     OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CHELLOTRACEDLL_STRING, 
       
    75                      "[0x%08x] Returned %S", (TUint32) this, *iString);   
       
    76     return *iString;
       
    77     }
       
    78 
       
    79 EXPORT_C void CHelloTraceInterface::AddCharL(const TChar& aChar)
       
    80     {
       
    81     __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer));
       
    82 
       
    83     OstTraceExt3( TRACE_BORDER, CHELLOTRACEDLL_ADDCHARL, 
       
    84                   "[0x%08x] Adding %d to %S", (TUint32) this, (TInt32) aChar, *iString);   
       
    85     if (iString->Length() >= KHelloTraceDllBufferLength)
       
    86         {
       
    87         OstTrace1( TRACE_ERROR, CHELLOTRACEDLL_ADDCHARL_ERR,
       
    88                    "[0x%08x] Not enough space to add character", (TUint32) this);
       
    89         User::Leave( KErrTooBig);
       
    90         }
       
    91     iString->Append(aChar);
       
    92     }
       
    93 
       
    94 EXPORT_C void CHelloTraceInterface::RemoveLast()
       
    95     {
       
    96     __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer));
       
    97 
       
    98     OstTraceExt2( TRACE_BORDER, CHELLOTRACEDLL_REMOVELAST, 
       
    99                   "[0x%08x] Attempting to remove last character from %S", (TUint32) this, *iString);
       
   100     if (iString->Length() > 0)
       
   101         {
       
   102         iString->SetLength(iString->Length() - 1);
       
   103         }
       
   104     else
       
   105         {
       
   106         OstTrace1( TRACE_WARNING, CHELLOTRACEDLL_REMOVELAST_WARN, "[0x%08x] String already empty", (TUint32) this);   
       
   107         }
       
   108     }
       
   109 
       
   110 EXPORT_C void CHelloTraceInterface::ResetString()
       
   111     {
       
   112     OstTraceExt2( TRACE_BORDER, CHELLOTRACEDLL_RESETSTRING, "[0x%08x] Reseting string %S", (TUint32) this, *iString);
       
   113     if (iString == NULL)
       
   114         {
       
   115         iString = new (ELeave) THelloTraceDllExampleString;
       
   116         }
       
   117     else
       
   118         {
       
   119         iString->SetLength(0);
       
   120         }
       
   121     }