|
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 #include "HelloTraceInterface.h" |
|
20 #include "HelloTraceInterfaceDup.h" |
|
21 #include "HelloTraceInterfaceDup2.inl" |
|
22 #include "HelloTracePanic.h" |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "HelloTraceInterfaceTraces.h" |
|
26 #endif |
|
27 |
|
28 EXPORT_C CHelloTraceInterface* CHelloTraceInterface::NewLC() |
|
29 { |
|
30 CHelloTraceInterface* self = new (ELeave) CHelloTraceInterface; |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 EXPORT_C CHelloTraceInterface* CHelloTraceInterface::NewL() |
|
37 { |
|
38 CHelloTraceInterface* self = CHelloTraceInterface::NewLC(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CHelloTraceInterface::CHelloTraceInterface() |
|
44 { |
|
45 OstTrace1( TRACE_NORMAL, CHELLOTRACEDLL_CHELLOTRACEDLL_CTOR, "[0x%08x]", (TUint32) this ); |
|
46 } |
|
47 |
|
48 void CHelloTraceInterface::ConstructL() |
|
49 { |
|
50 iString = new (ELeave) THelloTraceDllExampleString; |
|
51 } |
|
52 |
|
53 EXPORT_C CHelloTraceInterface::~CHelloTraceInterface() |
|
54 { |
|
55 delete iString; |
|
56 OstTrace1( TRACE_NORMAL, CHELLOTRACEDLL_CHELLOTRACEDLL_DTOR, "[0x%08x]", (TUint32) this ); |
|
57 } |
|
58 |
|
59 EXPORT_C TVersion CHelloTraceInterface::Version() |
|
60 { |
|
61 const TInt KMajor = 1; |
|
62 const TInt KMinor = 0; |
|
63 const TInt KBuild = 1; |
|
64 TVersion version = TVersion(KMajor, KMinor, KBuild); |
|
65 OstTraceExt1( TRACE_BORDER, CHELLOTRACEDLL_VERSION, "CHelloTraceInterface::Version = %S", version.Name()); |
|
66 return version; |
|
67 } |
|
68 |
|
69 EXPORT_C const TPtrC CHelloTraceInterface::String() const |
|
70 { |
|
71 __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer)); |
|
72 |
|
73 OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CHELLOTRACEDLL_STRING, |
|
74 "[0x%08x] Returned %S", (TUint32) this, *iString); |
|
75 return *iString; |
|
76 } |
|
77 |
|
78 EXPORT_C void CHelloTraceInterface::AddCharL(const TChar& aChar) |
|
79 { |
|
80 __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer)); |
|
81 |
|
82 OstTraceExt3( TRACE_BORDER, CHELLOTRACEDLL_ADDCHARL, |
|
83 "[0x%08x] Adding %d to %S", (TUint32) this, (TInt32) aChar, *iString); |
|
84 if (iString->Length() >= KHelloTraceDllBufferLength) |
|
85 { |
|
86 OstTrace1( TRACE_ERROR, CHELLOTRACEDLL_ADDCHARL_ERR, |
|
87 "[0x%08x] Not enough space to add character", (TUint32) this); |
|
88 User::Leave( KErrTooBig); |
|
89 } |
|
90 iString->Append(aChar); |
|
91 } |
|
92 |
|
93 EXPORT_C void CHelloTraceInterface::RemoveLast() |
|
94 { |
|
95 __ASSERT_ALWAYS(iString != NULL, Panic(EHelloTraceDllNullPointer)); |
|
96 |
|
97 OstTraceExt2( TRACE_BORDER, CHELLOTRACEDLL_REMOVELAST, |
|
98 "[0x%08x] Attempting to remove last character from %S", (TUint32) this, *iString); |
|
99 if (iString->Length() > 0) |
|
100 { |
|
101 iString->SetLength(iString->Length() - 1); |
|
102 } |
|
103 else |
|
104 { |
|
105 OstTrace1( TRACE_WARNING, CHELLOTRACEDLL_REMOVELAST_WARN, "[0x%08x] String already empty", (TUint32) this); |
|
106 } |
|
107 } |
|
108 |
|
109 EXPORT_C void CHelloTraceInterface::ResetString() |
|
110 { |
|
111 OstTraceExt2( TRACE_BORDER, CHELLOTRACEDLL_RESETSTRING, "[0x%08x] Reseting string %S", (TUint32) this, *iString); |
|
112 if (iString == NULL) |
|
113 { |
|
114 iString = new (ELeave) THelloTraceDllExampleString; |
|
115 } |
|
116 else |
|
117 { |
|
118 iString->SetLength(0); |
|
119 } |
|
120 } |