examples/Base/IPC/AdvancedClientServerExample/driver/driver1.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description: Interface to example Logical Device Driver  
00028 */
00029 
00030 
00035 #ifndef __DRIVER1_H__
00036 #define __DRIVER1_H__
00037 
00038 #include <e32cmn.h>
00039 #include <e32ver.h>
00040 #ifndef __KERNEL_MODE__
00041 #include <e32std.h>
00042 #endif
00043 
00047 class RDriver1 : public RBusLogicalChannel
00048         {
00049 public:
00054         class TCaps
00055                 {
00056         public:
00057                 TVersion iVersion;
00058                 };
00059 
00063         class TConfig
00064                 {
00065         public:
00066                 TInt iSpeed;                            
00067                 TInt iPddBufferSize;            
00068                 TInt iMaxSendDataSize;          
00069                 TInt iMaxReceiveDataSize;       
00070                 };
00071         typedef TPckgBuf<TConfig> TConfigBuf;
00072 
00073 public:
00074         inline TInt Open();
00075         inline TInt GetConfig(TConfigBuf& aConfig);
00076         inline TInt SetConfig(const TConfigBuf& aConfig);
00077         inline void SendData(TRequestStatus &aStatus,const TDesC8& aData);
00078         inline void SendDataCancel();
00079         inline void ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer);
00080         inline void ReceiveDataCancel();
00081         inline static const TDesC& Name();
00082         inline static TVersion VersionRequired();
00083 private:
00087         enum TControl
00088                 {
00089                 EGetConfig,
00090                 ESetConfig
00091                 };
00092 
00096         enum TRequest
00097                 {
00098                 ESendData,
00099                 EReceiveData,
00100                 ENumRequests,
00101                 EAllRequests = (1<<ENumRequests)-1
00102                 };
00103 
00104         // Kernel side LDD channel is a friend
00105         friend class DDriver1Channel;
00106         };
00107 
00112 inline const TDesC& RDriver1::Name()
00113         {
00114         _LIT(KDriver1Name,"DRIVER1");
00115         return KDriver1Name;
00116         }
00117 
00122 inline TVersion RDriver1::VersionRequired()
00123         {
00124         const TInt KMajorVersionNumber=1;
00125         const TInt KMinorVersionNumber=0;
00126         const TInt KBuildVersionNumber=KE32BuildVersionNumber;
00127         return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
00128         }
00129 
00130 /*
00131   NOTE: The following methods would normally be exported from a seperate client DLL
00132   but are included in this header file for convenience.
00133 */
00134 
00135 #ifndef __KERNEL_MODE__
00136 
00141 inline TInt RDriver1::Open()
00142         {
00143         return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
00144         }
00145 
00151 inline TInt RDriver1::GetConfig(TConfigBuf& aConfig)
00152         {
00153         return DoControl(EGetConfig,(TAny*)&aConfig);
00154         }
00155 
00163 inline TInt RDriver1::SetConfig(const TConfigBuf& aConfig)
00164         {
00165         return DoControl(ESetConfig,(TAny*)&aConfig);
00166         }
00167 
00176 inline void RDriver1::SendData(TRequestStatus &aStatus,const TDesC8& aData)
00177         {
00178         DoRequest(ESendData,aStatus,(TAny*)&aData);
00179         }
00180 
00184 inline void RDriver1::SendDataCancel()
00185         {
00186         DoCancel(1<<ESendData);
00187         }
00188 
00197 inline void RDriver1::ReceiveData(TRequestStatus &aStatus,TDes8& aBuffer)
00198         {
00199         DoRequest(EReceiveData,aStatus,(TAny*)&aBuffer);
00200         }
00201 
00205 inline void RDriver1::ReceiveDataCancel()
00206         {
00207         DoCancel(1<<EReceiveData);
00208         }
00209 
00210 #endif  // !__KERNEL_MODE__
00211 
00212 #endif // __DRIVER1_H__
00213 

Generated by  doxygen 1.6.2