examples/Basics/ExtensionPattern/src_original_v2/NumberStoreOriginalImplementation_v2.cpp

00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // CPP file demonstrating Extension DLL pattern
00015 // This file contains the original implementation of the CNumberStore function.
00016 // This file has _not_ been modified in order to add public extension functions.
00017 // The only extension is to add the private "DoMultiplyNumbers" function which is
00018 // deliberately "private" to stop code calling it.  It must be called through the 
00019 // public "MultiplyNumbers" function which is available in the extension dll.
00020 //
00021 
00022 
00023 #include <NumberStore.h>
00024 
00025         
00026 //This constant is defined in the CPP to demonstrate an intrusive change; 
00027 //DoMultiplyNumbers must be implemented in this DLL in order to see this const  
00028 const TInt KMagicMultiplyer=2;
00029 
00030 //Function implementations of all _original_ functions
00031 
00032 EXPORT_C CNumberStore::CNumberStore ()
00033         {
00034         }
00035 
00036 EXPORT_C CNumberStore::CNumberStore (TInt aNumber1, TInt aNumber2)
00037         {
00038         SetNumber1(aNumber1);
00039         SetNumber2(aNumber2);
00040         }
00041 
00042 EXPORT_C void CNumberStore::SetNumber1 (TInt aNumber1)
00043         {
00044         iNumber1=aNumber1;
00045         }
00046 
00047 EXPORT_C void CNumberStore::SetNumber2 (TInt aNumber2)
00048         {
00049         iNumber2=aNumber2;
00050         }
00051 
00052 EXPORT_C TInt CNumberStore::Number1 () const
00053         {
00054         return iNumber1;
00055         }
00056 
00057 EXPORT_C TInt CNumberStore::Number2 () const
00058         {
00059         return iNumber2;
00060         }
00061 
00062 // Five new functions added in version 2 of the DLL
00063 // Each of these set to panic to demonstrate if any legacy code calls them inadvertently
00064 EXPORT_C void NewOwnerFunction1()
00065         {
00066         User::Panic(_L("New Function Called"),1);
00067         }
00068         
00069 EXPORT_C void NewOwnerFunction2()
00070         {
00071         User::Panic(_L("New Function Called"),2);
00072         }
00073         
00074 EXPORT_C void NewOwnerFunction3()
00075         {
00076         User::Panic(_L("New Function Called"),3);
00077         }
00078         
00079 EXPORT_C void NewOwnerFunction4()
00080         {
00081         User::Panic(_L("New Function Called"),4);
00082         }
00083         
00084 EXPORT_C void NewOwnerFunction5()
00085         {
00086         User::Panic(_L("New Function Called"),5);
00087         }
00088         
00089 //Function implementations of private functions which are only used by the extension dll
00090 //Note that this function occurs at a different ordinal position in the lib / def file due
00091 //to the addition of the 5 new functions above
00092 //This function must be defined in this file so it can see KMagicMultiplyer.
00093 EXPORT_C TInt CNumberStore::DoMultiplyNumbers() const
00094         {
00095         return (iNumber1*iNumber2*KMagicMultiplyer);
00096         }

Generated by  doxygen 1.6.2