examples/Base/IPC/AdvancedClientServerExample/driver/driver1_dev.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: Kernel side interfaces to the example Logical and Physical Device Drivers  
00028 */
00029 
00030 
00031 
00036 #ifndef __DRIVER1_DEV_H__
00037 #define __DRIVER1_DEV_H__
00038 
00042 class DDriver1Factory : public DLogicalDevice
00043         {
00044 public:
00045         DDriver1Factory();
00046         ~DDriver1Factory();
00047         
00048         //      Inherited from DLogicalDevice
00049         virtual TInt Install();
00050         virtual void GetCaps(TDes8& aDes) const;
00051         virtual TInt Create(DLogicalChannelBase*& aChannel);
00052         };
00053 
00054 class DDriver1;
00055 
00059 class DDriver1Channel : public DLogicalChannel
00060         {
00061 public:
00062         DDriver1Channel();
00063         virtual ~DDriver1Channel();
00064         
00065         //      Inherited from DObject
00066         virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
00067         
00068         // Inherited from DLogicalChannelBase
00069         virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
00070         
00071         // Inherited from DLogicalChannel
00072         virtual void HandleMsg(TMessageBase* aMsg);
00073 private:
00074         // Panic reasons
00075         enum TPanic
00076                 {
00077                 // A request was issued when one is outstanding.
00078                 ERequestAlreadyPending = 1
00079                 };
00080                 
00081         // Implementation of the different kinds of messages sent through RBusLogicalChannel
00082         TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
00083         TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2);
00084         void DoCancel(TUint aMask);
00085         // Accessor for the PDD
00086         inline DDriver1* Pdd();
00087         // Methods for configuration
00088         TInt GetConfig(TDes8* aConfigBuf);
00089         TInt SetConfig(const TDesC8* aConfigBuf);
00090         void CurrentConfig(RDriver1::TConfig& aConfig);
00091         // Methods for processing a SendData request
00092         TInt SendData(TRequestStatus* aStatus,const TDesC8* aData);
00093         void SendDataCancel();
00094         void DoSendDataComplete();
00095         static void SendDataDfc(TAny* aPtr);
00096         // Methods for processing a ReceiveData request
00097         TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer);
00098         void ReceiveDataCancel();
00099         void DoReceiveDataComplete();
00100         static void ReceiveDataDfc(TAny* aPtr);
00101 public:
00102         // Interface methods for use by PDD
00103         virtual void SendDataComplete(TInt aResult);
00104         virtual void ReceiveDataComplete(TInt aResult);
00105 private:
00106         DThread* iClient;
00107         // Members used for processing a SendData request
00108         TRequestStatus* iSendDataStatus;
00109         TDfc iSendDataDfc;
00110         TInt iSendDataResult;
00111         TBuf8<256> iSendDataBuffer;
00112         // Members used for processing a ReceiveData request
00113         TDes8* iReceiveDataDescriptor;
00114         TRequestStatus* iReceiveDataStatus;
00115         TDfc iReceiveDataDfc;
00116         TInt iReceiveDataResult;
00117         TBuf8<256> iReceiveDataBuffer;
00118         };
00119 
00120 inline DDriver1* DDriver1Channel::Pdd()
00121         { return (DDriver1*)iPdd; }
00122 
00126 class DDriver1 : public DBase
00127         {
00128 public:
00132         class TCaps
00133                 {
00134         public:
00135                 TVersion iVersion;
00136                 };
00137 public:
00138         virtual TInt BufferSize() const =0;
00139         virtual TInt Speed() const =0;
00140         virtual TInt SetSpeed(TInt aSpeed) =0;
00141         virtual TInt SendData(const TDesC8& aData) =0;
00142         virtual void SendDataCancel() =0;
00143         virtual TInt ReceiveData(TDes8& aBuffer) =0;
00144         virtual void ReceiveDataCancel() =0;
00145 public:
00146         DDriver1Channel* iLdd;
00147         };
00148 
00149 #endif
00150 

Generated by  doxygen 1.6.2