Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ltkcpp_connection.h

Go to the documentation of this file.
00001 
00002 /*
00003  ***************************************************************************
00004  *  Copyright 2007,2008 Impinj, Inc.
00005  *
00006  *  Licensed under the Apache License, Version 2.0 (the "License");
00007  *  you may not use this file except in compliance with the License.
00008  *  You may obtain a copy of the License at
00009  *
00010  *      http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  *  Unless required by applicable law or agreed to in writing, software
00013  *  distributed under the License is distributed on an "AS IS" BASIS,
00014  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  *  See the License for the specific language governing permissions and
00016  *  limitations under the License.
00017  *
00018  ***************************************************************************
00019  */
00020 
00031 namespace LLRP
00032 {
00033 
00034 /*
00035  * @brief   Forward class declaration of platform-specific socket wrapper
00036  *
00037  * The definition is in ltkcpp_connection.cpp.
00038  *
00039  * On Linux a socket is a simple type (int). On Windows it
00040  * is a pointer to a specific type defined in a WinSock
00041  * header (.h) file. Rather than make that header file a
00042  * prerequisite to every source file that includes this header
00043  * file (ltkcpp_connection.h), the following CPlatformSocket
00044  * class opaquely wraps the platform-specific socket.
00045  *
00046  * The CConnection class references it by pointer only.
00047  * The content of the CPlatformSocket is only known
00048  * within the implementation of CConnection.
00049  */
00050 class CPlatformSocket;
00051 
00081 class CConnection
00082 {
00083   public:
00084     CConnection (
00085       const CTypeRegistry *     pTypeRegistry,
00086       unsigned int              nBufferSize);
00087 
00088     ~CConnection (void);
00089 
00090     int
00091     openConnectionToReader (
00092       const char *              pReaderHostName);
00093 
00094     const char *
00095     getConnectError (void);
00096 
00097     int
00098     closeConnectionToReader (void);
00099 
00100     CMessage *
00101     transact (
00102       CMessage *                pSendMessage,
00103       int                       nMaxMS);
00104 
00105     const CErrorDetails *
00106     getTransactError (void);
00107 
00108     EResultCode
00109     sendMessage (
00110       CMessage *                pMessage);
00111 
00112     const CErrorDetails *
00113     getSendError (void);
00114 
00115     CMessage *
00116     recvMessage (
00117       int                       nMaxMS);
00118 
00119     CMessage *
00120     recvResponse (
00121       int                       nMaxMS,
00122       const CTypeDescriptor *   pResponseType,
00123       llrp_u32_t                ResponseMessageID);
00124 
00125     const CErrorDetails *
00126     getRecvError (void);
00127 
00128   private:
00130     CPlatformSocket *           m_pPlatformSocket;
00131 
00133     const char *                m_pConnectErrorStr;
00134 
00136     const CTypeRegistry *       m_pTypeRegistry;
00137 
00139     std::list<CMessage *>       m_listInputQueue;
00140 
00142     unsigned int                m_nBufferSize;
00143 
00145     struct RecvState
00146     {
00148         llrp_byte_t *       pBuffer;
00149 
00151         unsigned int        nBuffer;
00152 
00156         int                 bFrameValid;
00157 
00159         CFrameExtract       FrameExtract;
00160 
00162         CErrorDetails       ErrorDetails;
00163     }                           m_Recv;
00164 
00166     struct SendState
00167     {
00169         llrp_byte_t *       pBuffer;
00170 
00172         unsigned int        nBuffer;
00173 
00175         CErrorDetails       ErrorDetails;
00176     }                           m_Send;
00177 
00178   private:
00179     EResultCode
00180     recvAdvance (
00181       int                           nMaxMS,
00182       time_t                        timeLimit);
00183 
00184     time_t
00185     calculateTimeLimit (
00186       int                           nMaxMS);
00187 };
00188 
00189 
00190 }; /* namespace LLRP */
00191 

Generated on Wed Nov 26 12:27:44 2008 for LTKCPP-- LLRP Toolkit C Plus Plus Library by  doxygen 1.3.9.1