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

ltkcpp_base.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 
00041 #define LTKCPP_VERSION      0x01000005
00042 #define LTKCPP_VERSION_STR  "1.0.0.5"
00043 
00049 #define BOOL int
00050 
00056 namespace LLRP
00057 {
00058 
00059 /*
00060  * Forward declarations of structs and classes
00061  */
00062 
00063 //enum EResultCode;
00064 class CErrorDetails;
00065 class CVendorDescriptor;
00066 class CNamespaceDescriptor;
00067 class CTypeDescriptor;
00068 class CFieldDescriptor;
00069 struct SEnumTableEntry;
00070 class CTypeRegistry;
00071 class CElement;
00072 class CMessage;
00073 class CParameter;
00074 class CDecoder;
00075 class CDecoderStream;
00076 class CEncoder;
00077 class CEncoderStream;
00078 
00079 
00080 /*
00081  * Simple array (vector) types. There is an array type
00082  * for each of {u,s}{8,16,32,64}v and u1v and utf8v.
00083  *
00084  * The member variables are:
00085  *      m_nValue            The number of array elements
00086  *      m_pValue            Pointer to the first element
00087  *
00088  * The interfaces:
00089  *      llrp_XXv_t(void)    Default constructor, just sets the
00090  *                          member fields to zero.
00091  *      llrp_XXv_t(llrp_XXv_t & rOther)
00092  *                          Constructor that clones an existing object.
00093  *      ~llrp_XXv_t(void)   Destructor, just deletes m_pValue in case
00094  *                          there is something allocated to it.
00095  *      operator=           Assignment operator. Used to copy an
00096  *                          existing instance. It's careful
00097  *                          to delete m_pValue before overwriting it.
00098  *
00099  * Private subroutines
00100  *      copy()              Makes a copy, supports operator=
00101  *      reset()             Clears the variable much like the
00102  *                          destructor does.
00103  */
00104 
00112 class llrp_u8v_t
00113 {
00114   public:
00116     llrp_u16_t                  m_nValue; 
00118     llrp_u8_t *                 m_pValue; 
00119 
00121     llrp_u8v_t(void);
00122 
00124     llrp_u8v_t (
00125       unsigned int              nValue);
00126 
00128     llrp_u8v_t (
00129       const llrp_u8v_t &        rOther);
00130 
00132     ~llrp_u8v_t(void);
00133 
00135     llrp_u8v_t &
00136     operator= (
00137       const llrp_u8v_t &        rValue);
00138 
00139   private:
00140     void
00141     copy (
00142       const llrp_u8v_t &        rOther);
00143 
00144     void
00145     reset (void);
00146 };
00147 
00155 class llrp_s8v_t
00156 {
00157   public:
00159     llrp_u16_t                  m_nValue;
00161     llrp_s8_t *                 m_pValue;
00162 
00164     llrp_s8v_t(void);
00165 
00167     llrp_s8v_t (
00168       unsigned int              nValue);
00169 
00171     llrp_s8v_t (
00172       const llrp_s8v_t &        rOther);
00173 
00175     ~llrp_s8v_t(void);
00176 
00178     llrp_s8v_t &
00179     operator= (
00180       const llrp_s8v_t &        rValue);
00181 
00182   private:
00183     void
00184     copy (
00185       const llrp_s8v_t &        rOther);
00186 
00187     void
00188     reset (void);
00189 };
00190 
00198 class llrp_u16v_t
00199 {
00200   public:
00202     llrp_u16_t                  m_nValue;
00204     llrp_u16_t *                m_pValue;
00205 
00207     llrp_u16v_t(void);
00208 
00210     llrp_u16v_t (
00211       unsigned int              nValue);
00212 
00214     llrp_u16v_t (
00215       const llrp_u16v_t &       rOther);
00216 
00218     ~llrp_u16v_t(void);
00219 
00221     llrp_u16v_t &
00222     operator= (
00223       const llrp_u16v_t &       rValue);
00224 
00225   private:
00226     void
00227     copy (
00228       const llrp_u16v_t &       rOther);
00229 
00230     void
00231     reset (void);
00232 };
00233 
00241 class llrp_s16v_t
00242 {
00243   public:
00245     llrp_u16_t                  m_nValue;
00247     llrp_s16_t *                m_pValue;
00248 
00250     llrp_s16v_t(void);
00251 
00253     llrp_s16v_t (
00254       unsigned int              nValue);
00255 
00257     llrp_s16v_t (
00258       const llrp_s16v_t &       rOther);
00259 
00261     ~llrp_s16v_t(void);
00262 
00264     llrp_s16v_t &
00265     operator= (
00266       const llrp_s16v_t &       rValue);
00267 
00268   private:
00269     void
00270     copy (
00271       const llrp_s16v_t &       rOther);
00272 
00273     void
00274     reset (void);
00275 };
00276 
00284 class llrp_u32v_t
00285 {
00286   public:
00288     llrp_u16_t                  m_nValue;
00290     llrp_u32_t *                m_pValue;
00291 
00293     llrp_u32v_t(void);
00294 
00296     llrp_u32v_t (
00297       unsigned int              nValue);
00298 
00300     llrp_u32v_t (
00301       const llrp_u32v_t &       rOther);
00302 
00304     ~llrp_u32v_t(void);
00305 
00307     llrp_u32v_t &
00308     operator= (
00309       const llrp_u32v_t &       rValue);
00310 
00311   private:
00312     void
00313     copy (
00314       const llrp_u32v_t &       rOther);
00315 
00316     void
00317     reset (void);
00318 };
00319 
00327 class llrp_s32v_t
00328 {
00329   public:
00331     llrp_u16_t                  m_nValue;
00333     llrp_s32_t *                m_pValue;
00334 
00336     llrp_s32v_t(void);
00337 
00339     llrp_s32v_t (
00340       unsigned int              nValue);
00341 
00343     llrp_s32v_t (
00344       const llrp_s32v_t &       rOther);
00345 
00347     ~llrp_s32v_t(void);
00348 
00350     llrp_s32v_t &
00351     operator= (
00352       const llrp_s32v_t &       rValue);
00353 
00354   private:
00355     void
00356     copy (
00357       const llrp_s32v_t &       rOther);
00358 
00359     void
00360     reset (void);
00361 };
00362 
00370 class llrp_u64v_t
00371 {
00372   public:
00374     llrp_u16_t                  m_nValue;
00376     llrp_u64_t *                m_pValue;
00377 
00379     llrp_u64v_t(void);
00380 
00382     llrp_u64v_t (
00383       unsigned int              nValue);
00384 
00386     llrp_u64v_t (
00387       const llrp_u64v_t &       rOther);
00388 
00390     ~llrp_u64v_t(void);
00391 
00393     llrp_u64v_t &
00394     operator= (
00395       const llrp_u64v_t &       rValue);
00396 
00397   private:
00398     void
00399     copy (
00400       const llrp_u64v_t &       rOther);
00401 
00402     void
00403     reset (void);
00404 };
00405 
00413 class llrp_s64v_t
00414 {
00415   public:
00417     llrp_u16_t                  m_nValue;
00419     llrp_s64_t *                m_pValue;
00420 
00422     llrp_s64v_t(void);
00423 
00425     llrp_s64v_t (
00426       unsigned int              nValue);
00427 
00429     llrp_s64v_t (
00430       const llrp_s64v_t &       rOther);
00431 
00433     ~llrp_s64v_t(void);
00434 
00436     llrp_s64v_t &
00437     operator= (
00438       const llrp_s64v_t &       rValue);
00439 
00440   private:
00441     void
00442     copy (
00443       const llrp_s64v_t &       rOther);
00444 
00445     void
00446     reset (void);
00447 };
00448 
00456 class llrp_u1v_t
00457 {
00458   public:
00460     llrp_u16_t                  m_nBit;
00462     llrp_u8_t *                 m_pValue;
00463 
00465     llrp_u1v_t(void);
00466 
00468     llrp_u1v_t (
00469       unsigned int              nBit);
00470 
00472     llrp_u1v_t (
00473       const llrp_u1v_t &        rOther);
00474 
00476     ~llrp_u1v_t(void);
00477 
00479     llrp_u1v_t &
00480     operator= (
00481       const llrp_u1v_t &        rValue);
00482 
00483   private:
00484     void
00485     copy (
00486       const llrp_u1v_t &        rOther);
00487 
00488     void
00489     reset (void);
00490 };
00491 
00499 class llrp_utf8v_t
00500 {
00501   public:
00503     llrp_u16_t                  m_nValue;
00505     llrp_utf8_t *               m_pValue;
00506 
00508     llrp_utf8v_t(void);
00509 
00511     llrp_utf8v_t (
00512       unsigned int              nValue);
00513 
00515     llrp_utf8v_t (
00516       const llrp_utf8v_t &      rOther);
00517 
00519     ~llrp_utf8v_t(void);
00520 
00522     llrp_utf8v_t &
00523     operator= (
00524       const llrp_utf8v_t &      rValue);
00525 
00526   private:
00527     void
00528     copy (
00529       const llrp_utf8v_t &      rOther);
00530 
00531     void
00532     reset (void);
00533 };
00534 
00542 class llrp_bytesToEnd_t
00543 {
00544   public:
00546     llrp_u16_t                  m_nValue;
00548     llrp_byte_t *               m_pValue;
00549 
00551     llrp_bytesToEnd_t(void);
00552 
00554     llrp_bytesToEnd_t (
00555       unsigned int              nValue);
00556 
00558     llrp_bytesToEnd_t (
00559       const llrp_bytesToEnd_t & rOther);
00560 
00562     ~llrp_bytesToEnd_t(void);
00563 
00565     llrp_bytesToEnd_t &
00566     operator= (
00567       const llrp_bytesToEnd_t & rValue);
00568 
00569   private:
00570     void
00571     copy (
00572       const llrp_bytesToEnd_t & rOther);
00573 
00574     void
00575     reset (void);
00576 };
00577 
00585 class llrp_u96_t
00586 {
00587   public:
00589     llrp_u8_t                   m_aValue[12];
00590 };
00591 
00592 
00602 enum EResultCode
00603 {
00604     RC_OK                       = 0,   
00605     RC_MiscError                = 100, 
00606     RC_Botch,                          
00607     RC_SendIOError,                    
00608     RC_RecvIOError,                    
00609     RC_RecvEOF,                        
00610     RC_RecvTimeout,                    
00611     RC_RecvFramingError,               
00612     RC_BadVersion,                     
00613     RC_MissingResponseType,            
00614     RC_UnknownMessageType,             
00615     RC_UnknownParameterType,           
00616     RC_ExcessiveLength,                
00617     RC_InvalidLength,                  
00618     RC_FieldUnderrun,                  
00619     RC_ReservedBitsUnderrun,           
00620     RC_FieldOverrun,                   
00621     RC_ReservedBitsOverrun,            
00622     RC_UnalignedBitField,              
00623     RC_UnalignedReservedBits,          
00624     RC_MessageAllocationFailed,        
00625     RC_ParameterAllocationFailed,      
00626     RC_FieldAllocationFailed,          
00627     RC_ExtraBytes,                     
00628     RC_MissingParameter,               
00629     RC_UnexpectedParameter,            
00630     RC_InvalidChoiceMember,            
00631     RC_EnrollBadTypeNumber,            
00632     RC_NotAllowedAtExtensionPoint,     
00633 };
00634 
00644 class CErrorDetails
00645 {
00646   public:
00648     EResultCode                 m_eResultCode;
00650     const char *                m_pWhatStr;
00652     const CTypeDescriptor *     m_pRefType;
00654     const CFieldDescriptor *    m_pRefField;
00655 
00656     int                         m_OtherDetail;
00657 
00659     CErrorDetails (void);
00660 
00662     void
00663     clear (void);
00664 
00669     void
00670     missingParameter (
00671       const CTypeDescriptor *   pRefType);
00672 
00677     void
00678     unexpectedParameter (
00679       const CParameter *        pParameter);
00680 
00685     void
00686     resultCodeAndWhatStr (
00687       EResultCode               eResultCode,
00688       const char *              pWhatStr);
00689 };
00690 
00698 class CVendorDescriptor
00699 {
00700   public:
00702     const char *                m_pName;
00703 
00705     llrp_u32_t                  m_VendorID;
00706 };
00707 
00713 class CNamespaceDescriptor
00714 {
00715   public:
00717     const char *                m_pPrefix;
00718 
00720     const char *                m_pURI;
00721 
00724     const char *                m_pSchemaLocation;
00725 };
00726 
00727 
00728 
00768 class CTypeDescriptor
00769 {
00770   public:
00772     llrp_bool_t                 m_bIsMessage;
00773 
00775     char *                      m_pName;
00776 
00779     const CVendorDescriptor *   m_pVendorDescriptor;
00780 
00782     const CNamespaceDescriptor *m_pNamespaceDescriptor;
00783 
00785     llrp_u32_t                  m_TypeNum;
00786 
00789     const CTypeDescriptor *     m_pResponseType;
00790 
00792     const CFieldDescriptor * const * const m_ppFieldDescriptorTable;
00793 
00795     CElement *
00796     (*m_pfConstruct)(void);
00797 
00799     void
00800     (*m_pfDecodeFields) (
00801       CDecoderStream *          pDecoderStream,
00802       CElement *                pTargetElement);
00803 
00804   public:
00806     inline CElement *
00807     constructElement(void) const
00808     {
00809        return (*m_pfConstruct)();
00810     }
00811 };
00812 
00820 class CFieldDescriptor
00821 {
00822   public:
00824     enum FieldType {
00825         FT_U8,  FT_S8,  FT_U8V,  FT_S8V,
00826         FT_U16, FT_S16, FT_U16V, FT_S16V,
00827         FT_U32, FT_S32, FT_U32V, FT_S32V,
00828         FT_U64, FT_S64, FT_U64V, FT_S64V,
00829 
00830         FT_U1,  FT_U1V, FT_U2,   FT_U96,
00831         FT_UTF8V,
00832 
00833         FT_E1, FT_E2, FT_E8, FT_E16, FT_E32,
00834         FT_E8V,
00835 
00836         FT_BYTESTOEND,
00837     };
00838 
00840     enum FieldFormat {
00841         FMT_NORMAL,
00842         FMT_DEC,
00843         FMT_HEX,
00844         FMT_UTF8,
00845         FMT_DATETIME,
00846     };
00847 
00849     FieldType                   m_eFieldType;
00851     FieldFormat                 m_eFieldFormat;
00853     char *                      m_pName;
00855     const SEnumTableEntry *     m_pEnumTable;
00856 };
00857 
00858 /*
00859  * ltkcpp_hdrfd.c
00860  */
00861 extern CFieldDescriptor     g_fdMessageHeader_Type;
00862 extern CFieldDescriptor     g_fdMessageHeader_Length;
00863 extern CFieldDescriptor     g_fdMessageHeader_MessageID;
00864 extern CFieldDescriptor     g_fdMessageHeader_VendorPEN;
00865 extern CFieldDescriptor     g_fdMessageHeader_Subtype;
00866 extern CFieldDescriptor     g_fdParameterHeader_TVType;
00867 extern CFieldDescriptor     g_fdParameterHeader_TLVType;
00868 extern CFieldDescriptor     g_fdParameterHeader_TLVLength;
00869 extern CFieldDescriptor     g_fdParameterHeader_VendorPEN;
00870 extern CFieldDescriptor     g_fdParameterHeader_Subtype;
00871 
00872 
00873 /*
00874  * SEnumTableEntry
00875  *
00876  * @brief Simple table of enumerations. Table is terminated
00877  * by an entry with pName==NULL.
00878  */
00879 struct SEnumTableEntry
00880 {
00881     /* String name, (e.g. "Immediate") */
00882     char *                      pName;
00883     int                         Value;
00884 };
00885 
00898 class CTypeRegistry
00899 {
00900   public:
00902     const CTypeDescriptor *     m_apStdMessageTypeDescriptors[1024u];
00904     const CTypeDescriptor *     m_apStdParameterTypeDescriptors[1024u];
00906     std::list<const CTypeDescriptor *> m_listCustomMessageTypeDescriptors;
00908     std::list<const CTypeDescriptor *> m_listCustomParameterTypeDescriptors;
00909 
00910     CTypeRegistry(void);
00911     ~CTypeRegistry(void);
00912 
00914     EResultCode
00915     enroll (
00916       const CTypeDescriptor *   pTypeDescriptor);
00917 
00919     const CTypeDescriptor *
00920     lookupMessage (
00921       unsigned int              MessageTypeNum) const;
00922 
00924     const CTypeDescriptor *
00925     lookupParameter (
00926       unsigned int              ParameterTypeNum) const;
00927 
00929     const CTypeDescriptor *
00930     lookupCustomMessage (
00931       unsigned int              VendorID,
00932       unsigned int              MessageSubTypeNum) const;
00933 
00935     const CTypeDescriptor *
00936     lookupCustomParameter (
00937       unsigned int              VendorID,
00938       unsigned int              ParameterSubTypeNum) const;
00939 };
00940 
00941 
00942 typedef std::list<CParameter *> tListOfParameters;
00943 
00974 class CElement
00975 {
00976   public:
00978     const CTypeDescriptor *     m_pType;
00979 
00981     CElement *                  m_pParent;
00982 
00984     tListOfParameters           m_listAllSubParameters;
00985 
00986   public:
00987     CElement(void);
00988 
00989     virtual
00990     ~CElement(void);
00991 
00999     void
01000     addSubParameterToAllList (
01001       CParameter *              pParameter);
01002 
01011     void
01012     removeSubParameterFromAllList (
01013       CParameter *              pParameter);
01014 
01022     void
01023     clearSubParameterList (
01024       tListOfParameters *       pParameterList);
01025 
01027     int
01028     walk (
01029       int                       (*pFunc)(
01030                                   const CElement *  pElement,
01031                                   void *            pArg),
01032       void *                    pArg,
01033       int                       iDepth,
01034       int                       nMaxDepth) const;
01035 
01036 
01043     EResultCode
01044     toXMLString (
01045       char *                    pBuffer,
01046       int                       nBuffer);
01047 
01048 
01057     virtual void
01058     decodeFields (
01059       CDecoderStream *          pDecoderStream) = 0;
01060 
01071     virtual void
01072     assimilateSubParameters (
01073       CErrorDetails *           pError) = 0;
01074 
01080     virtual void
01081     encode (
01082       CEncoderStream *          pEncoderStream) const = 0;
01083 };
01084 
01085 
01094 class CMessage : public CElement
01095 {
01096   public:
01100     inline void
01101     setMessageID (
01102       llrp_u32_t                MessageID)
01103     {
01104         m_MessageID = MessageID;
01105     }
01106 
01110     inline llrp_u32_t
01111     getMessageID (void) const
01112     {
01113         return m_MessageID;
01114     }
01115 
01116   protected:
01117     llrp_u32_t                  m_MessageID;
01118 
01119 };
01120 
01129 class CParameter : public CElement
01130 {
01131   public:
01139     virtual llrp_bool_t
01140     isAllowedIn (
01141       const CTypeDescriptor *   pEnclosingTypeDescriptor) const;
01142 
01150     llrp_bool_t
01151     isAllowedExtension (
01152       const CTypeDescriptor *   pEnclosingTypeDescriptor);
01153 };
01154 
01209 class CDecoder
01210 {
01211   public:
01213     CErrorDetails               m_ErrorDetails;
01214 
01215     CDecoder (void);
01216 
01218     CDecoder (
01219       const CTypeRegistry *     pTypeRegistry);
01220 
01221     virtual
01222     ~CDecoder (void) = 0;
01223 
01225     virtual CMessage *
01226     decodeMessage (void) = 0;
01227 
01228   protected:
01229     const CTypeRegistry *       m_pRegistry;
01230 };
01231 
01239 class CDecoderStream
01240 {
01241   public:
01242     virtual
01243     ~CDecoderStream(void) = 0;
01244 
01245     /*
01246      * 8-bit types
01247      */
01248 
01250     virtual llrp_u8_t
01251     get_u8 (
01252       const CFieldDescriptor *  pFieldDesc) = 0;
01253 
01255     virtual llrp_s8_t
01256     get_s8 (
01257       const CFieldDescriptor *  pFieldDesc) = 0;
01258 
01260     virtual llrp_u8v_t
01261     get_u8v (
01262       const CFieldDescriptor *  pFieldDesc) = 0;
01263 
01265     virtual llrp_s8v_t
01266     get_s8v (
01267       const CFieldDescriptor *  pFieldDesc) = 0;
01268 
01269     /*
01270      * 16-bit types
01271      */
01272 
01274     virtual llrp_u16_t
01275     get_u16 (
01276       const CFieldDescriptor *  pFieldDesc) = 0;
01277 
01279     virtual llrp_s16_t
01280     get_s16 (
01281       const CFieldDescriptor *  pFieldDesc) = 0;
01282 
01284     virtual llrp_u16v_t
01285     get_u16v (
01286       const CFieldDescriptor *  pFieldDesc) = 0;
01287 
01289     virtual llrp_s16v_t
01290     get_s16v (
01291       const CFieldDescriptor *  pFieldDesc) = 0;
01292 
01293     /*
01294      * 32-bit types
01295      */
01296 
01298     virtual llrp_u32_t
01299     get_u32 (
01300       const CFieldDescriptor *  pFieldDesc) = 0;
01301 
01303     virtual llrp_s32_t
01304     get_s32 (
01305       const CFieldDescriptor *  pFieldDesc) = 0;
01306 
01308     virtual llrp_u32v_t
01309     get_u32v (
01310       const CFieldDescriptor *  pFieldDesc) = 0;
01311 
01313     virtual llrp_s32v_t
01314     get_s32v (
01315       const CFieldDescriptor *  pFieldDesc) = 0;
01316 
01317     /*
01318      * 64-bit types
01319      */
01320 
01322     virtual llrp_u64_t
01323     get_u64 (
01324       const CFieldDescriptor *  pFieldDesc) = 0;
01325 
01327     virtual llrp_s64_t
01328     get_s64 (
01329       const CFieldDescriptor *  pFieldDesc) = 0;
01330 
01332     virtual llrp_u64v_t
01333     get_u64v (
01334       const CFieldDescriptor *  pFieldDesc) = 0;
01335 
01337     virtual llrp_s64v_t
01338     get_s64v (
01339       const CFieldDescriptor *  pFieldDesc) = 0;
01340 
01341     /*
01342      * Special types
01343      */
01344 
01346     virtual llrp_u1_t
01347     get_u1 (
01348       const CFieldDescriptor *  pFieldDesc) = 0;
01349 
01351     virtual llrp_u1v_t
01352     get_u1v (
01353       const CFieldDescriptor *  pFieldDesc) = 0;
01354 
01356     virtual llrp_u2_t
01357     get_u2 (
01358       const CFieldDescriptor *  pFieldDesc) = 0;
01359 
01361     virtual llrp_u96_t
01362     get_u96 (
01363       const CFieldDescriptor *  pFieldDesc) = 0;
01364 
01366     virtual llrp_utf8v_t
01367     get_utf8v (
01368       const CFieldDescriptor *  pFieldDesc) = 0;
01369 
01371     virtual llrp_bytesToEnd_t
01372     get_bytesToEnd (
01373       const CFieldDescriptor *  pFieldDesc) = 0;
01374 
01375     /*
01376      * Enumerated types of various sizes
01377      */
01378 
01380     virtual int
01381     get_e1 (
01382       const CFieldDescriptor *  pFieldDesc) = 0;
01383 
01385     virtual int
01386     get_e2 (
01387       const CFieldDescriptor *  pFieldDesc) = 0;
01388 
01390     virtual int
01391     get_e8 (
01392       const CFieldDescriptor *  pFieldDesc) = 0;
01393 
01395     virtual int
01396     get_e16 (
01397       const CFieldDescriptor *  pFieldDesc) = 0;
01398 
01400     virtual int
01401     get_e32 (
01402       const CFieldDescriptor *  pFieldDesc) = 0;
01403 
01405     virtual llrp_u8v_t
01406     get_e8v (
01407       const CFieldDescriptor *  pFieldDesc) = 0;
01408 
01409     /*
01410      * Reserved means some number of bits
01411      */
01412     /* @brief skips a number of reserved bits and discards during the encode/decode process */
01413     virtual void
01414     get_reserved (
01415       unsigned int          nBits) = 0;
01416 };
01417 
01425 class CEncoder
01426 {
01427   public:
01429     CErrorDetails               m_ErrorDetails;
01430 
01432     CEncoder (void);
01433 
01435     virtual
01436     ~CEncoder (void) = 0;
01437 
01439     virtual void
01440     encodeElement (
01441       const CElement *          pElement) = 0;
01442 };
01443 
01451 class CEncoderStream
01452 {
01453   public:
01454     virtual
01455     ~CEncoderStream(void) = 0;
01456 
01461     virtual void
01462     putRequiredSubParameter (
01463       const CParameter *        pParameter,
01464       const CTypeDescriptor *   pRefType) = 0;
01465 
01470     virtual void
01471     putOptionalSubParameter (
01472       const CParameter *        pParameter,
01473       const CTypeDescriptor *   pRefType) = 0;
01474 
01479     virtual void
01480     putRequiredSubParameterList (
01481       const tListOfParameters * pParameterList,
01482       const CTypeDescriptor *   pRefType) = 0;
01483 
01488     virtual void
01489     putOptionalSubParameterList (
01490       const tListOfParameters * pParameterList,
01491       const CTypeDescriptor *   pRefType) = 0;
01492 
01493     /*
01494      * 8-bit types
01495      */
01496 
01501     virtual void
01502     put_u8 (
01503       llrp_u8_t                 Value,
01504       const CFieldDescriptor *  pFieldDesc) = 0;
01505 
01510     virtual void
01511     put_s8 (
01512       llrp_s8_t                 Value,
01513       const CFieldDescriptor *  pFieldDesc) = 0;
01514 
01519     virtual void
01520     put_u8v (
01521       llrp_u8v_t                Value,
01522       const CFieldDescriptor *  pFieldDesc) = 0;
01523 
01528     virtual void
01529     put_s8v (
01530       llrp_s8v_t                Value,
01531       const CFieldDescriptor *  pFieldDesc) = 0;
01532 
01533     /*
01534      * 16-bit types
01535      */
01536 
01541     virtual void
01542     put_u16 (
01543       llrp_u16_t                Value,
01544       const CFieldDescriptor *  pFieldDesc) = 0;
01545     
01550     virtual void
01551     put_s16 (
01552       llrp_s16_t                Value,
01553       const CFieldDescriptor *  pFieldDesc) = 0;
01554 
01559     virtual void
01560     put_u16v (
01561       llrp_u16v_t               Value,
01562       const CFieldDescriptor *  pFieldDesc) = 0;
01563 
01568     virtual void
01569     put_s16v (
01570       llrp_s16v_t               Value,
01571       const CFieldDescriptor *  pFieldDesc) = 0;
01572 
01573     /*
01574      * 32-bit types
01575      */
01576 
01581     virtual void
01582     put_u32 (
01583       llrp_u32_t                Value,
01584       const CFieldDescriptor *  pFieldDesc) = 0;
01585 
01590     virtual void
01591     put_s32 (
01592       llrp_s32_t                Value,
01593       const CFieldDescriptor *  pFieldDesc) = 0;
01594 
01599     virtual void
01600     put_u32v (
01601       llrp_u32v_t               Value,
01602       const CFieldDescriptor *  pFieldDesc) = 0;
01603 
01608     virtual void
01609     put_s32v (
01610       llrp_s32v_t               Value,
01611       const CFieldDescriptor *  pFieldDesc) = 0;
01612 
01613     /*
01614      * 64-bit types
01615      */
01616 
01621     virtual void
01622     put_u64 (
01623       llrp_u64_t                Value,
01624       const CFieldDescriptor *  pFieldDesc) = 0;
01625 
01630     virtual void
01631     put_s64 (
01632       llrp_s64_t                Value,
01633       const CFieldDescriptor *  pFieldDesc) = 0;
01634 
01639     virtual void
01640     put_u64v (
01641       llrp_u64v_t               Value,
01642       const CFieldDescriptor *  pFieldDesc) = 0;
01643 
01648     virtual void
01649     put_s64v (
01650       llrp_s64v_t               Value,
01651       const CFieldDescriptor *  pFieldDesc) = 0;
01652 
01653     /*
01654      * Special types
01655      */
01656 
01661     virtual void
01662     put_u1 (
01663       llrp_u1_t                 Value,
01664       const CFieldDescriptor *  pFieldDesc) = 0;
01665 
01670     virtual void
01671     put_u1v (
01672       llrp_u1v_t                Value,
01673       const CFieldDescriptor *  pFieldDesc) = 0;
01674 
01679     virtual void
01680     put_u2 (
01681       llrp_u2_t                 Value,
01682       const CFieldDescriptor *  pFieldDesc) = 0;
01683 
01688     virtual void
01689     put_u96 (
01690       llrp_u96_t                Value,
01691       const CFieldDescriptor *  pFieldDesc) = 0;
01692 
01697     virtual void
01698     put_utf8v (
01699       llrp_utf8v_t              Value,
01700       const CFieldDescriptor *  pFieldDesc) = 0;
01701 
01706     virtual void
01707     put_bytesToEnd (
01708       llrp_bytesToEnd_t         Value,
01709       const CFieldDescriptor *  pFieldDesc) = 0;
01710 
01711     /*
01712      * Enumerated types of various sizes
01713      */
01714 
01719     virtual void
01720     put_e1 (
01721       int                       eValue,
01722       const CFieldDescriptor *  pFieldDesc) = 0;
01723 
01728     virtual void
01729     put_e2 (
01730       int                       eValue,
01731       const CFieldDescriptor *  pFieldDesc) = 0;
01732 
01737     virtual void
01738     put_e8 (
01739       int                       eValue,
01740       const CFieldDescriptor *  pFieldDesc) = 0;
01741 
01746     virtual void
01747     put_e16 (
01748       int                       eValue,
01749       const CFieldDescriptor *  pFieldDesc) = 0;
01750 
01755     virtual void
01756     put_e32 (
01757       int                       eValue,
01758       const CFieldDescriptor *  pFieldDesc) = 0;
01759 
01764     virtual void
01765     put_e8v (
01766       llrp_u8v_t                Value,
01767       const CFieldDescriptor *  pFieldDesc) = 0;
01768 
01769     /*
01770      * Reserved types are some number of bits
01771      */
01772 
01773     /* @brief skips a number of reserved bits and discards during the encode/decode process */
01774     virtual void
01775     put_reserved (
01776       unsigned int              nBits) = 0;
01777 };
01778 
01779 
01780 /*
01781 ** @brief Encodes a CElement into an XML string 
01782 **
01783 ** @param[in]  pElement      The CElement to encode to XML
01784 ** @param[out] pBuffer       The pointer to the buffer in which to place the XML result
01785 ** @param[in]  nBuffer       The size of the buffer available to hold the XML
01786 **
01787 ** @return EResultCode Result code from the operation
01788 */
01789 extern EResultCode
01790 toXMLString (
01791   const CElement *              pElement,
01792   char *                        pBuffer,
01793   int                           nBuffer);
01794 
01795 }; /* namespace LLRP */

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