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

ltkcpp_frame.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 
00035 namespace LLRP
00036 {
00037 class CFrameExtract;
00038 class CFrameDecoder;
00039 class CFrameDecoderStream;
00040 class CFrameEncoder;
00041 class CFrameEncoderStream;
00042 
00043 class CFrameExtract
00044 {
00045   public:
00046     enum {
00047         UNKNOWN,
00048         READY,
00049         FRAME_ERROR,
00050         NEED_MORE
00051     }                           m_eStatus;
00052 
00053     llrp_u32_t                  m_MessageLength;
00054     llrp_u16_t                  m_MessageType;
00055     llrp_u8_t                   m_ProtocolVersion;
00056     llrp_u32_t                  m_MessageID;
00057 
00058     unsigned int                m_nBytesNeeded;
00059 
00060     CFrameExtract (void);
00061 
00062     CFrameExtract (
00063       const unsigned char *     pBuffer,
00064       unsigned int              nBuffer);
00065 };
00066 
00067 class CFrameDecoder : public CDecoder
00068 {
00069     friend class CFrameDecoderStream;
00070 
00071   public:
00072     CFrameDecoder (
00073       const CTypeRegistry *     pTypeRegistry,
00074       unsigned char *           pBuffer,
00075       unsigned int              nBuffer);
00076 
00077     ~CFrameDecoder (void);
00078 
00079     CMessage *
00080     decodeMessage (void);
00081 
00082   private:
00083     unsigned char *             m_pBuffer;
00084     unsigned int                m_nBuffer;
00085 
00086     unsigned int                m_iNext;
00087     unsigned int                m_BitFieldBuffer;
00088     unsigned int                m_nBitFieldResid;
00089 
00090     llrp_u8_t
00091     next_u8(void);
00092 
00093     llrp_u16_t
00094     next_u16(void);
00095 
00096     llrp_u32_t
00097     next_u32(void);
00098 
00099     llrp_u64_t
00100     next_u64(void);
00101 };
00102 
00103 class CFrameDecoderStream : public CDecoderStream
00104 {
00105     friend class CFrameDecoder;
00106 
00107   public:
00108     /*
00109      * 8-bit types
00110      */
00111 
00112     llrp_u8_t
00113     get_u8 (
00114       const CFieldDescriptor *  pFieldDescriptor);
00115 
00116     llrp_s8_t
00117     get_s8 (
00118       const CFieldDescriptor *  pFieldDescriptor);
00119 
00120     llrp_u8v_t
00121     get_u8v (
00122       const CFieldDescriptor *  pFieldDescriptor);
00123 
00124     llrp_s8v_t
00125     get_s8v (
00126       const CFieldDescriptor *  pFieldDescriptor);
00127 
00128     /*
00129      * 16-bit types
00130      */
00131 
00132     llrp_u16_t
00133     get_u16 (
00134       const CFieldDescriptor *  pFieldDescriptor);
00135 
00136     llrp_s16_t
00137     get_s16 (
00138       const CFieldDescriptor *  pFieldDescriptor);
00139 
00140     llrp_u16v_t
00141     get_u16v (
00142       const CFieldDescriptor *  pFieldDescriptor);
00143 
00144     llrp_s16v_t
00145     get_s16v (
00146       const CFieldDescriptor *  pFieldDescriptor);
00147 
00148     /*
00149      * 32-bit types
00150      */
00151 
00152     llrp_u32_t
00153     get_u32 (
00154       const CFieldDescriptor *  pFieldDescriptor);
00155 
00156     llrp_s32_t
00157     get_s32 (
00158       const CFieldDescriptor *  pFieldDescriptor);
00159 
00160     llrp_u32v_t
00161     get_u32v (
00162       const CFieldDescriptor *  pFieldDescriptor);
00163 
00164     llrp_s32v_t
00165     get_s32v (
00166       const CFieldDescriptor *  pFieldDescriptor);
00167 
00168     /*
00169      * 64-bit types
00170      */
00171 
00172     llrp_u64_t
00173     get_u64 (
00174       const CFieldDescriptor *  pFieldDescriptor);
00175 
00176     llrp_s64_t
00177     get_s64 (
00178       const CFieldDescriptor *  pFieldDescriptor);
00179 
00180     llrp_u64v_t
00181     get_u64v (
00182       const CFieldDescriptor *  pFieldDescriptor);
00183 
00184     llrp_s64v_t
00185     get_s64v (
00186       const CFieldDescriptor *  pFieldDescriptor);
00187 
00188     /*
00189      * Special types
00190      */
00191 
00192     llrp_u1_t
00193     get_u1 (
00194       const CFieldDescriptor *  pFieldDescriptor);
00195 
00196     llrp_u1v_t
00197     get_u1v (
00198       const CFieldDescriptor *  pFieldDescriptor);
00199 
00200     llrp_u2_t
00201     get_u2 (
00202       const CFieldDescriptor *  pFieldDescriptor);
00203 
00204     llrp_u96_t
00205     get_u96 (
00206       const CFieldDescriptor *  pFieldDescriptor);
00207 
00208     llrp_utf8v_t
00209     get_utf8v (
00210       const CFieldDescriptor *  pFieldDescriptor);
00211 
00212     llrp_bytesToEnd_t
00213     get_bytesToEnd (
00214       const CFieldDescriptor *  pFieldDescriptor);
00215 
00216     /*
00217      * Enumerated types of various sizes
00218      */
00219 
00220     int
00221     get_e1 (
00222       const CFieldDescriptor *  pFieldDescriptor);
00223 
00224     int
00225     get_e2 (
00226       const CFieldDescriptor *  pFieldDescriptor);
00227 
00228     int
00229     get_e8 (
00230       const CFieldDescriptor *  pFieldDescriptor);
00231 
00232     int
00233     get_e16 (
00234       const CFieldDescriptor *  pFieldDescriptor);
00235 
00236     int
00237     get_e32 (
00238       const CFieldDescriptor *  pFieldDescriptor);
00239 
00240     llrp_u8v_t
00241     get_e8v (
00242       const CFieldDescriptor *  pFieldDescriptor);
00243 
00244     /*
00245      * Reserved types are some number of bits
00246      */
00247 
00248     void
00249     get_reserved (
00250       unsigned int              nBit);
00251 
00252   private:
00253     CFrameDecoder *             m_pDecoder;
00254     CFrameDecoderStream *       m_pEnclosingDecoderStream;
00255     const CTypeDescriptor *     m_pRefType;
00256     unsigned int                m_iBegin;
00257     unsigned int                m_iLimit;
00258 
00259     CFrameDecoderStream (
00260       CFrameDecoder *           pDecoder);
00261 
00262     CFrameDecoderStream (
00263       CFrameDecoderStream *     pEnclosingDecoderStream);
00264 
00265     /* no destructor necessary */
00266 
00267     CMessage *
00268     getMessage (void);
00269 
00270     CParameter *
00271     getParameter (void);
00272 
00273     unsigned int
00274     getRemainingByteCount (void);
00275 
00276     llrp_bool_t
00277     checkAvailable (
00278       unsigned int              nByte,
00279       const CFieldDescriptor *  pFieldDescriptor);
00280 
00281     unsigned int
00282     getBitField (
00283       unsigned int              nBit,
00284       const CFieldDescriptor *  pFieldDescriptor);
00285 
00286     llrp_u16_t
00287     getVarlenCount (
00288       const CFieldDescriptor *  pFieldDescriptor);
00289 
00290     llrp_bool_t
00291     verifyVectorAllocation (
00292       const void *              pValue,
00293       const CFieldDescriptor *  pFieldDescriptor);
00294 };
00295 
00296 class CFrameEncoder : public CEncoder
00297 {
00298   friend class CFrameEncoderStream;
00299 
00300   public:
00301     CFrameEncoder (
00302       unsigned char *           pBuffer,
00303       unsigned int              nBuffer);
00304 
00305     ~CFrameEncoder (void);
00306 
00307     void
00308     encodeElement (
00309       const CElement *          pElement);
00310 
00311     unsigned int
00312     getLength(void);
00313 
00314   private:
00315     unsigned char *             m_pBuffer;
00316     unsigned int                m_nBuffer;
00317 
00318     unsigned int                m_iNext;
00319     unsigned int                m_BitFieldBuffer;
00320     unsigned int                m_nBitFieldResid;
00321 
00322     void
00323     next_u8 (
00324       llrp_u8_t                 Value);
00325 
00326     void
00327     next_u16 (
00328       llrp_u16_t                Value);
00329 
00330     void
00331     next_u32 (
00332       llrp_u32_t                Value);
00333 
00334     void
00335     next_u64 (
00336       llrp_u64_t                Value);
00337 };
00338 
00339 class CFrameEncoderStream : public CEncoderStream
00340 {
00341   friend class CFrameEncoder;
00342 
00343   public:
00344     void
00345     putRequiredSubParameter (
00346       const CParameter *        pParameter,
00347       const CTypeDescriptor *   pRefType);
00348 
00349     void
00350     putOptionalSubParameter (
00351       const CParameter *        pParameter,
00352       const CTypeDescriptor *   pRefType);
00353 
00354     void
00355     putRequiredSubParameterList (
00356       const tListOfParameters * pParameterList,
00357       const CTypeDescriptor *   pRefType);
00358 
00359     void
00360     putOptionalSubParameterList (
00361       const tListOfParameters * pParameterList,
00362       const CTypeDescriptor *   pRefType);
00363 
00364     /*
00365      * 8-bit types
00366      */
00367 
00368     void
00369     put_u8 (
00370       llrp_u8_t                 Value,
00371       const CFieldDescriptor *  pFieldDescriptor);
00372 
00373     void
00374     put_s8 (
00375       llrp_s8_t                 Value,
00376       const CFieldDescriptor *  pFieldDescriptor);
00377 
00378     void
00379     put_u8v (
00380       llrp_u8v_t                Value,
00381       const CFieldDescriptor *  pFieldDescriptor);
00382 
00383     void
00384     put_s8v (
00385       llrp_s8v_t                Value,
00386       const CFieldDescriptor *  pFieldDescriptor);
00387 
00388     /*
00389      * 16-bit types
00390      */
00391 
00392     void
00393     put_u16 (
00394       llrp_u16_t                Value,
00395       const CFieldDescriptor *  pFieldDescriptor);
00396 
00397     void
00398     put_s16 (
00399       llrp_s16_t                Value,
00400       const CFieldDescriptor *  pFieldDescriptor);
00401 
00402     void
00403     put_u16v (
00404       llrp_u16v_t               Value,
00405       const CFieldDescriptor *  pFieldDescriptor);
00406 
00407     void
00408     put_s16v (
00409       llrp_s16v_t               Value,
00410       const CFieldDescriptor *  pFieldDescriptor);
00411 
00412     /*
00413      * 32-bit types
00414      */
00415 
00416     void
00417     put_u32 (
00418       llrp_u32_t                Value,
00419       const CFieldDescriptor *  pFieldDescriptor);
00420 
00421     void
00422     put_s32 (
00423       llrp_s32_t                Value,
00424       const CFieldDescriptor *  pFieldDescriptor);
00425 
00426     void
00427     put_u32v (
00428       llrp_u32v_t               Value,
00429       const CFieldDescriptor *  pFieldDescriptor);
00430 
00431     void
00432     put_s32v (
00433       llrp_s32v_t               Value,
00434       const CFieldDescriptor *  pFieldDescriptor);
00435 
00436     /*
00437      * 64-bit types
00438      */
00439 
00440     void
00441     put_u64 (
00442       llrp_u64_t                Value,
00443       const CFieldDescriptor *  pFieldDescriptor);
00444 
00445     void
00446     put_s64 (
00447       llrp_s64_t                Value,
00448       const CFieldDescriptor *  pFieldDescriptor);
00449 
00450     void
00451     put_u64v (
00452       llrp_u64v_t               Value,
00453       const CFieldDescriptor *  pFieldDescriptor);
00454 
00455     void
00456     put_s64v (
00457       llrp_s64v_t               Value,
00458       const CFieldDescriptor *  pFieldDescriptor);
00459 
00460     /*
00461      * Special types
00462      */
00463 
00464     void
00465     put_u1 (
00466       llrp_u1_t                 Value,
00467       const CFieldDescriptor *  pFieldDescriptor);
00468 
00469     void
00470     put_u1v (
00471       llrp_u1v_t                Value,
00472       const CFieldDescriptor *  pFieldDescriptor);
00473 
00474     void
00475     put_u2 (
00476       llrp_u2_t                 Value,
00477       const CFieldDescriptor *  pFieldDescriptor);
00478 
00479     void
00480     put_u96 (
00481       llrp_u96_t                Value,
00482       const CFieldDescriptor *  pFieldDescriptor);
00483 
00484     void
00485     put_utf8v (
00486       llrp_utf8v_t              Value,
00487       const CFieldDescriptor *  pFieldDescriptor);
00488 
00489     void
00490     put_bytesToEnd (
00491       llrp_bytesToEnd_t         Value,
00492       const CFieldDescriptor *  pFieldDescriptor);
00493 
00494     /*
00495      * Enumerated types of various sizes
00496      */
00497 
00498     void
00499     put_e1 (
00500       int                       eValue,
00501       const CFieldDescriptor *  pFieldDescriptor);
00502 
00503     void
00504     put_e2 (
00505       int                       eValue,
00506       const CFieldDescriptor *  pFieldDescriptor);
00507 
00508     void
00509     put_e8 (
00510       int                       eValue,
00511       const CFieldDescriptor *  pFieldDescriptor);
00512 
00513     void
00514     put_e16 (
00515       int                       eValue,
00516       const CFieldDescriptor *  pFieldDescriptor);
00517 
00518     void
00519     put_e32 (
00520       int                       eValue,
00521       const CFieldDescriptor    *pFieldDescriptor);
00522 
00523     void
00524     put_e8v (
00525       llrp_u8v_t                Value,
00526       const CFieldDescriptor *  pFieldDescriptor);
00527 
00528     /*
00529      * Reserved types are some number of bits
00530      */
00531 
00532     void
00533     put_reserved (
00534       unsigned int              nBits);
00535 
00536   private:
00537     CFrameEncoder *             m_pEncoder;
00538     CFrameEncoderStream *       m_pEnclosingEncoderStream;
00539     const CTypeDescriptor *     m_pRefType;
00540     unsigned int                m_iBegin;
00541 
00542     CFrameEncoderStream (
00543       CFrameEncoder *           pEncoder);
00544 
00545     CFrameEncoderStream (
00546       CFrameEncoderStream *     pEnclosingEncoderStream);
00547 
00548     /* no destructor needed */
00549 
00550     void
00551     putElement (
00552       const CElement *          pElement);
00553 
00554     llrp_bool_t
00555     checkAvailable (
00556       unsigned int              nByte,
00557       const CFieldDescriptor *  pFieldDescriptor);
00558 
00559     llrp_bool_t
00560     putBitField (
00561       unsigned int              nBit,
00562       unsigned int              Value,
00563       const CFieldDescriptor *  pFieldDescriptor);
00564 };
00565 
00566 
00567 };

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