LTKCPP-- LLRP Toolkit C Plus Plus Library
Library/ltkcpp_base.h
00001 
00002 /*
00003  *****************************************************************************
00004  *                                                                           *
00005  *                 IMPINJ CONFIDENTIAL AND PROPRIETARY                       *
00006  *                                                                           *
00007  * This source code is the sole property of Impinj, Inc.  Reproduction or    *
00008  * utilization of this source code in whole or in part is forbidden without  *
00009  * the prior written consent of Impinj, Inc.                                 *
00010  *                                                                           *
00011  * (c) Copyright Impinj, Inc. 2007,2008. All rights reserved.                *
00012  *                                                                           *
00013  *****************************************************************************/
00014 
00037 namespace LLRP
00038 {
00039 
00040 /*
00041  * Forward declarations of structs and classes
00042  */
00043 
00044 //enum EResultCode;
00045 class CErrorDetails;
00046 class CVendorDescriptor;
00047 class CNamespaceDescriptor;
00048 class CTypeDescriptor;
00049 class CFieldDescriptor;
00050 struct SEnumTableEntry;
00051 class CTypeRegistry;
00052 class CElement;
00053 class CMessage;
00054 class CParameter;
00055 class CDecoder;
00056 class CDecoderStream;
00057 class CEncoder;
00058 class CEncoderStream;
00059 
00060 
00061 /*
00062  * Simple array (vector) types. There is an array type
00063  * for each of {u,s}{8,16,32,64}v and u1v and utf8v.
00064  *
00065  * The member variables are:
00066  *      m_nValue            The number of array elements
00067  *      m_pValue            Pointer to the first element
00068  *
00069  * The interfaces:
00070  *      llrp_XXv_t(void)    Default constructor, just sets the
00071  *                          member fields to zero.
00072  *      llrp_XXv_t(llrp_XXv_t & rOther)
00073  *                          Constructor that clones an existing object.
00074  *      ~llrp_XXv_t(void)   Destructor, just deletes m_pValue in case
00075  *                          there is something allocated to it.
00076  *      operator=           Assignment operator. Used to copy an
00077  *                          existing instance. It's careful
00078  *                          to delete m_pValue before overwriting it.
00079  *
00080  * Private subroutines
00081  *      copy()              Makes a copy, supports operator=
00082  *      reset()             Clears the variable much like the
00083  *                          destructor does.
00084  */
00085 
00093 class llrp_u8v_t
00094 {
00095   public:
00097     llrp_u16_t                  m_nValue;
00099     llrp_u8_t *                 m_pValue;
00100 
00102     llrp_u8v_t(void);
00103 
00105     llrp_u8v_t (
00106       unsigned int              nValue);
00107 
00109     llrp_u8v_t (
00110       const llrp_u8v_t &        rOther);
00111 
00113     ~llrp_u8v_t(void);
00114 
00116     llrp_u8v_t &
00117     operator= (
00118       const llrp_u8v_t &        rValue);
00119 
00120   private:
00121     void
00122     copy (
00123       const llrp_u8v_t &        rOther);
00124 
00125     void
00126     reset (void);
00127 };
00128 
00136 class llrp_s8v_t
00137 {
00138   public:
00140     llrp_u16_t                  m_nValue;
00142     llrp_s8_t *                 m_pValue;
00143 
00145     llrp_s8v_t(void);
00146 
00148     llrp_s8v_t (
00149       unsigned int              nValue);
00150 
00152     llrp_s8v_t (
00153       const llrp_s8v_t &        rOther);
00154 
00156     ~llrp_s8v_t(void);
00157 
00159     llrp_s8v_t &
00160     operator= (
00161       const llrp_s8v_t &        rValue);
00162 
00163   private:
00164     void
00165     copy (
00166       const llrp_s8v_t &        rOther);
00167 
00168     void
00169     reset (void);
00170 };
00171 
00179 class llrp_u16v_t
00180 {
00181   public:
00183     llrp_u16_t                  m_nValue;
00185     llrp_u16_t *                m_pValue;
00186 
00188     llrp_u16v_t(void);
00189 
00191     llrp_u16v_t (
00192       unsigned int              nValue);
00193 
00195     llrp_u16v_t (
00196       const llrp_u16v_t &       rOther);
00197 
00199     ~llrp_u16v_t(void);
00200 
00202     llrp_u16v_t &
00203     operator= (
00204       const llrp_u16v_t &       rValue);
00205 
00206   private:
00207     void
00208     copy (
00209       const llrp_u16v_t &       rOther);
00210 
00211     void
00212     reset (void);
00213 };
00214 
00222 class llrp_s16v_t
00223 {
00224   public:
00226     llrp_u16_t                  m_nValue;
00228     llrp_s16_t *                m_pValue;
00229 
00231     llrp_s16v_t(void);
00232 
00234     llrp_s16v_t (
00235       unsigned int              nValue);
00236 
00238     llrp_s16v_t (
00239       const llrp_s16v_t &       rOther);
00240 
00242     ~llrp_s16v_t(void);
00243 
00245     llrp_s16v_t &
00246     operator= (
00247       const llrp_s16v_t &       rValue);
00248 
00249   private:
00250     void
00251     copy (
00252       const llrp_s16v_t &       rOther);
00253 
00254     void
00255     reset (void);
00256 };
00257 
00265 class llrp_u32v_t
00266 {
00267   public:
00269     llrp_u16_t                  m_nValue;
00271     llrp_u32_t *                m_pValue;
00272 
00274     llrp_u32v_t(void);
00275 
00277     llrp_u32v_t (
00278       unsigned int              nValue);
00279 
00281     llrp_u32v_t (
00282       const llrp_u32v_t &       rOther);
00283 
00285     ~llrp_u32v_t(void);
00286 
00288     llrp_u32v_t &
00289     operator= (
00290       const llrp_u32v_t &       rValue);
00291 
00292   private:
00293     void
00294     copy (
00295       const llrp_u32v_t &       rOther);
00296 
00297     void
00298     reset (void);
00299 };
00300 
00308 class llrp_s32v_t
00309 {
00310   public:
00312     llrp_u16_t                  m_nValue;
00314     llrp_s32_t *                m_pValue;
00315 
00317     llrp_s32v_t(void);
00318 
00320     llrp_s32v_t (
00321       unsigned int              nValue);
00322 
00324     llrp_s32v_t (
00325       const llrp_s32v_t &       rOther);
00326 
00328     ~llrp_s32v_t(void);
00329 
00331     llrp_s32v_t &
00332     operator= (
00333       const llrp_s32v_t &       rValue);
00334 
00335   private:
00336     void
00337     copy (
00338       const llrp_s32v_t &       rOther);
00339 
00340     void
00341     reset (void);
00342 };
00343 
00351 class llrp_u64v_t
00352 {
00353   public:
00355     llrp_u16_t                  m_nValue;
00357     llrp_u64_t *                m_pValue;
00358 
00360     llrp_u64v_t(void);
00361 
00363     llrp_u64v_t (
00364       unsigned int              nValue);
00365 
00367     llrp_u64v_t (
00368       const llrp_u64v_t &       rOther);
00369 
00371     ~llrp_u64v_t(void);
00372 
00374     llrp_u64v_t &
00375     operator= (
00376       const llrp_u64v_t &       rValue);
00377 
00378   private:
00379     void
00380     copy (
00381       const llrp_u64v_t &       rOther);
00382 
00383     void
00384     reset (void);
00385 };
00386 
00394 class llrp_s64v_t
00395 {
00396   public:
00398     llrp_u16_t                  m_nValue;
00400     llrp_s64_t *                m_pValue;
00401 
00403     llrp_s64v_t(void);
00404 
00406     llrp_s64v_t (
00407       unsigned int              nValue);
00408 
00410     llrp_s64v_t (
00411       const llrp_s64v_t &       rOther);
00412 
00414     ~llrp_s64v_t(void);
00415 
00417     llrp_s64v_t &
00418     operator= (
00419       const llrp_s64v_t &       rValue);
00420 
00421   private:
00422     void
00423     copy (
00424       const llrp_s64v_t &       rOther);
00425 
00426     void
00427     reset (void);
00428 };
00429 
00437 class llrp_u1v_t
00438 {
00439   public:
00441     llrp_u16_t                  m_nBit;
00443     llrp_u8_t *                 m_pValue;
00444 
00446     llrp_u1v_t(void);
00447 
00449     llrp_u1v_t (
00450       unsigned int              nBit);
00451 
00453     llrp_u1v_t (
00454       const llrp_u1v_t &        rOther);
00455 
00457     ~llrp_u1v_t(void);
00458 
00460     llrp_u1v_t &
00461     operator= (
00462       const llrp_u1v_t &        rValue);
00463 
00464   private:
00465     void
00466     copy (
00467       const llrp_u1v_t &        rOther);
00468 
00469     void
00470     reset (void);
00471 };
00472 
00480 class llrp_utf8v_t
00481 {
00482   public:
00484     llrp_u16_t                  m_nValue;
00486     llrp_utf8_t *               m_pValue;
00487 
00489     llrp_utf8v_t(void);
00490 
00492     llrp_utf8v_t (
00493       unsigned int              nValue);
00494 
00496     llrp_utf8v_t (
00497       const llrp_utf8v_t &      rOther);
00498 
00500     ~llrp_utf8v_t(void);
00501 
00503     llrp_utf8v_t &
00504     operator= (
00505       const llrp_utf8v_t &      rValue);
00506 
00507   private:
00508     void
00509     copy (
00510       const llrp_utf8v_t &      rOther);
00511 
00512     void
00513     reset (void);
00514 };
00515 
00523 class llrp_bytesToEnd_t
00524 {
00525   public:
00527     llrp_u16_t                  m_nValue;
00529     llrp_byte_t *               m_pValue;
00530 
00532     llrp_bytesToEnd_t(void);
00533 
00535     llrp_bytesToEnd_t (
00536       unsigned int              nValue);
00537 
00539     llrp_bytesToEnd_t (
00540       const llrp_bytesToEnd_t & rOther);
00541 
00543     ~llrp_bytesToEnd_t(void);
00544 
00546     llrp_bytesToEnd_t &
00547     operator= (
00548       const llrp_bytesToEnd_t & rValue);
00549 
00550   private:
00551     void
00552     copy (
00553       const llrp_bytesToEnd_t & rOther);
00554 
00555     void
00556     reset (void);
00557 };
00558 
00566 class llrp_u96_t
00567 {
00568   public:
00570     llrp_u8_t                   m_aValue[12];
00571 };
00572 
00573 
00583 enum EResultCode
00584 {
00585     RC_OK                       = 0,   
00586     RC_MiscError                = 100, 
00587     RC_Botch,                          
00588     RC_SendIOError,                    
00589     RC_RecvIOError,                    
00590     RC_RecvEOF,                        
00591     RC_RecvTimeout,                    
00592     RC_RecvFramingError,               
00593     RC_RecvBufferOverflow,             
00594     RC_BadVersion,                     
00595     RC_MissingResponseType,            
00596     RC_UnknownMessageType,             
00597     RC_UnknownParameterType,           
00598     RC_ExcessiveLength,                
00599     RC_InvalidLength,                  
00600     RC_FieldUnderrun,                  
00601     RC_ReservedBitsUnderrun,           
00602     RC_FieldOverrun,                   
00603     RC_ReservedBitsOverrun,            
00604     RC_UnalignedBitField,              
00605     RC_UnalignedReservedBits,          
00606     RC_MessageAllocationFailed,        
00607     RC_ParameterAllocationFailed,      
00608     RC_FieldAllocationFailed,          
00609     RC_ExtraBytes,                     
00610     RC_MissingParameter,               
00611     RC_UnexpectedParameter,            
00612     RC_InvalidChoiceMember,            
00613     RC_EnrollBadTypeNumber,            
00614     RC_NotAllowedAtExtensionPoint,     
00615     RC_XMLInvalidNodeType,             
00616     RC_XMLMissingField,                
00617     RC_XMLExtraNode,                   
00618     RC_XMLInvalidFieldCharacters,      
00619     RC_XMLOutOfRange,                  
00620 };
00621 
00631 class CErrorDetails
00632 {
00633   public:
00635     EResultCode                 m_eResultCode;
00637     const char *                m_pWhatStr;
00639     const CTypeDescriptor *     m_pRefType;
00641     const CFieldDescriptor *    m_pRefField;
00642 
00643     int                         m_OtherDetail;
00644 
00646     CErrorDetails (void);
00647 
00649     void
00650     clear (void);
00651 
00656     void
00657     missingParameter (
00658       const CTypeDescriptor *   pRefType);
00659 
00664     void
00665     unexpectedParameter (
00666       const CParameter *        pParameter);
00667 
00672     void
00673     resultCodeAndWhatStr (
00674       EResultCode               eResultCode,
00675       const char *              pWhatStr);
00676 };
00677 
00685 class CVendorDescriptor
00686 {
00687   public:
00689     const char *                m_pName;
00690 
00692     llrp_u32_t                  m_VendorID;
00693 };
00694 
00700 class CNamespaceDescriptor
00701 {
00702   public:
00704     const char *                m_pPrefix;
00705 
00707     const char *                m_pURI;
00708 
00711     const char *                m_pSchemaLocation;
00712 };
00713 
00714 
00715 
00755 class CTypeDescriptor
00756 {
00757   public:
00759     llrp_bool_t                 m_bIsMessage;
00760 
00762     char *                      m_pName;
00763 
00766     const CVendorDescriptor *   m_pVendorDescriptor;
00767 
00769     const CNamespaceDescriptor *m_pNamespaceDescriptor;
00770 
00772     llrp_u32_t                  m_TypeNum;
00773 
00776     const CTypeDescriptor *     m_pResponseType;
00777 
00779     const CFieldDescriptor * const * const m_ppFieldDescriptorTable;
00780 
00782     CElement *
00783     (*m_pfConstruct)(void);
00784 
00786     void
00787     (*m_pfDecodeFields) (
00788       CDecoderStream *          pDecoderStream,
00789       CElement *                pTargetElement);
00790 
00791   public:
00793     inline CElement *
00794     constructElement(void) const
00795     {
00796        return (*m_pfConstruct)();
00797     }
00798 };
00799 
00807 class CFieldDescriptor
00808 {
00809   public:
00811     enum FieldType {
00812         FT_U8,  FT_S8,  FT_U8V,  FT_S8V,
00813         FT_U16, FT_S16, FT_U16V, FT_S16V,
00814         FT_U32, FT_S32, FT_U32V, FT_S32V,
00815         FT_U64, FT_S64, FT_U64V, FT_S64V,
00816 
00817         FT_U1,  FT_U1V, FT_U2,   FT_U96,
00818         FT_UTF8V,
00819 
00820         FT_E1, FT_E2, FT_E8, FT_E16, FT_E32,
00821         FT_E8V,
00822 
00823         FT_BYTESTOEND,
00824     };
00825 
00827     enum FieldFormat {
00828         FMT_NORMAL,
00829         FMT_DEC,
00830         FMT_HEX,
00831         FMT_UTF8,
00832         FMT_DATETIME,
00833     };
00834 
00836     FieldType                   m_eFieldType;
00838     FieldFormat                 m_eFieldFormat;
00840     char *                      m_pName;
00842     const SEnumTableEntry *     m_pEnumTable;
00843 };
00844 
00845 /*
00846  * ltkcpp_hdrfd.c
00847  */
00848 extern CFieldDescriptor     g_fdMessageHeader_Type;
00849 extern CFieldDescriptor     g_fdMessageHeader_Length;
00850 extern CFieldDescriptor     g_fdMessageHeader_MessageID;
00851 extern CFieldDescriptor     g_fdMessageHeader_VendorPEN;
00852 extern CFieldDescriptor     g_fdMessageHeader_Subtype;
00853 extern CFieldDescriptor     g_fdParameterHeader_TVType;
00854 extern CFieldDescriptor     g_fdParameterHeader_TLVType;
00855 extern CFieldDescriptor     g_fdParameterHeader_TLVLength;
00856 extern CFieldDescriptor     g_fdParameterHeader_VendorPEN;
00857 extern CFieldDescriptor     g_fdParameterHeader_Subtype;
00858 
00859 
00860 /*
00861  * SEnumTableEntry
00862  *
00863  * @brief Simple table of enumerations. Table is terminated
00864  * by an entry with pName==NULL.
00865  */
00866 struct SEnumTableEntry
00867 {
00868     /* String name, (e.g. "Immediate") */
00869     char *                      pName;
00870     int                         Value;
00871 };
00872 
00885 class CTypeRegistry
00886 {
00887   public:
00889     const CTypeDescriptor *     m_apStdMessageTypeDescriptors[1024u];
00891     const CTypeDescriptor *     m_apStdParameterTypeDescriptors[1024u];
00893     std::list<const CTypeDescriptor *> m_listCustomMessageTypeDescriptors;
00895     std::list<const CTypeDescriptor *> m_listCustomParameterTypeDescriptors;
00896 
00897     CTypeRegistry(void);
00898     ~CTypeRegistry(void);
00899 
00901     EResultCode
00902     enroll (
00903       const CTypeDescriptor *   pTypeDescriptor);
00904 
00906     const CTypeDescriptor *
00907     lookupMessage (
00908       unsigned int              MessageTypeNum) const;
00909 
00911     const CTypeDescriptor *
00912     lookupParameter (
00913       unsigned int              ParameterTypeNum) const;
00914 
00916     const CTypeDescriptor *
00917     lookupCustomMessage (
00918       unsigned int              VendorID,
00919       unsigned int              MessageSubTypeNum) const;
00920 
00922     const CTypeDescriptor *
00923     lookupCustomParameter (
00924       unsigned int              VendorID,
00925       unsigned int              ParameterSubTypeNum) const;
00926 
00927    /* look up the type descriptor*/
00928     const CTypeDescriptor *
00929     lookupByName (
00930       char *                    pName) const;
00931 
00932 };
00933 
00934 
00935 
00936 typedef std::list<CParameter *> tListOfParameters;
00937 
00968 class CElement
00969 {
00970   public:
00972     const CTypeDescriptor *     m_pType;
00973 
00975     CElement *                  m_pParent;
00976 
00978     tListOfParameters           m_listAllSubParameters;
00979 
00980   public:
00981     CElement(void);
00982 
00983     virtual
00984     ~CElement(void);
00985 
00993     void
00994     addSubParameterToAllList (
00995       CParameter *              pParameter);
00996 
01005     void
01006     removeSubParameterFromAllList (
01007       CParameter *              pParameter);
01008 
01016     void
01017     clearSubParameterList (
01018       tListOfParameters *       pParameterList);
01019 
01021     int
01022     walk (
01023       int                       (*pFunc)(
01024                                   const CElement *  pElement,
01025                                   void *            pArg),
01026       void *                    pArg,
01027       int                       iDepth,
01028       int                       nMaxDepth) const;
01029 
01030 
01037     EResultCode
01038     toXMLString (
01039       char *                    pBuffer,
01040       int                       nBuffer);
01041 
01042 
01051     virtual void
01052     decodeFields (
01053       CDecoderStream *          pDecoderStream) = 0;
01054 
01065     virtual void
01066     assimilateSubParameters (
01067       CErrorDetails *           pError) = 0;
01068 
01074     virtual void
01075     encode (
01076       CEncoderStream *          pEncoderStream) const = 0;
01077 };
01078 
01079 
01088 class CMessage : public CElement
01089 {
01090   public:
01091     CMessage(void);
01092 
01096     inline void
01097     setMessageID (
01098       llrp_u32_t                MessageID)
01099     {
01100         m_MessageID = MessageID;
01101     }
01102 
01106     inline llrp_u32_t
01107     getMessageID (void) const
01108     {
01109         return m_MessageID;
01110     }
01111 
01112   protected:
01113     llrp_u32_t                  m_MessageID;
01114 
01115 };
01116 
01125 class CParameter : public CElement
01126 {
01127   public:
01135     virtual llrp_bool_t
01136     isAllowedIn (
01137       const CTypeDescriptor *   pEnclosingTypeDescriptor) const;
01138 
01146     llrp_bool_t
01147     isAllowedExtension (
01148       const CTypeDescriptor *   pEnclosingTypeDescriptor);
01149 };
01150 
01205 class CDecoder
01206 {
01207   public:
01209     CErrorDetails               m_ErrorDetails;
01210 
01211     CDecoder (void);
01212 
01214     CDecoder (
01215       const CTypeRegistry *     pTypeRegistry);
01216 
01217     virtual
01218     ~CDecoder (void) = 0;
01219 
01221     virtual CMessage *
01222     decodeMessage (void) = 0;
01223 
01224   protected:
01225     const CTypeRegistry *       m_pRegistry;
01226 };
01227 
01235 class CDecoderStream
01236 {
01237   public:
01238     virtual
01239     ~CDecoderStream(void) = 0;
01240 
01241     /*
01242      * 8-bit types
01243      */
01244 
01246     virtual llrp_u8_t
01247     get_u8 (
01248       const CFieldDescriptor *  pFieldDesc) = 0;
01249 
01251     virtual llrp_s8_t
01252     get_s8 (
01253       const CFieldDescriptor *  pFieldDesc) = 0;
01254 
01256     virtual llrp_u8v_t
01257     get_u8v (
01258       const CFieldDescriptor *  pFieldDesc) = 0;
01259 
01261     virtual llrp_s8v_t
01262     get_s8v (
01263       const CFieldDescriptor *  pFieldDesc) = 0;
01264 
01265     /*
01266      * 16-bit types
01267      */
01268 
01270     virtual llrp_u16_t
01271     get_u16 (
01272       const CFieldDescriptor *  pFieldDesc) = 0;
01273 
01275     virtual llrp_s16_t
01276     get_s16 (
01277       const CFieldDescriptor *  pFieldDesc) = 0;
01278 
01280     virtual llrp_u16v_t
01281     get_u16v (
01282       const CFieldDescriptor *  pFieldDesc) = 0;
01283 
01285     virtual llrp_s16v_t
01286     get_s16v (
01287       const CFieldDescriptor *  pFieldDesc) = 0;
01288 
01289     /*
01290      * 32-bit types
01291      */
01292 
01294     virtual llrp_u32_t
01295     get_u32 (
01296       const CFieldDescriptor *  pFieldDesc) = 0;
01297 
01299     virtual llrp_s32_t
01300     get_s32 (
01301       const CFieldDescriptor *  pFieldDesc) = 0;
01302 
01304     virtual llrp_u32v_t
01305     get_u32v (
01306       const CFieldDescriptor *  pFieldDesc) = 0;
01307 
01309     virtual llrp_s32v_t
01310     get_s32v (
01311       const CFieldDescriptor *  pFieldDesc) = 0;
01312 
01313     /*
01314      * 64-bit types
01315      */
01316 
01318     virtual llrp_u64_t
01319     get_u64 (
01320       const CFieldDescriptor *  pFieldDesc) = 0;
01321 
01323     virtual llrp_s64_t
01324     get_s64 (
01325       const CFieldDescriptor *  pFieldDesc) = 0;
01326 
01328     virtual llrp_u64v_t
01329     get_u64v (
01330       const CFieldDescriptor *  pFieldDesc) = 0;
01331 
01333     virtual llrp_s64v_t
01334     get_s64v (
01335       const CFieldDescriptor *  pFieldDesc) = 0;
01336 
01337     /*
01338      * Special types
01339      */
01340 
01342     virtual llrp_u1_t
01343     get_u1 (
01344       const CFieldDescriptor *  pFieldDesc) = 0;
01345 
01347     virtual llrp_u1v_t
01348     get_u1v (
01349       const CFieldDescriptor *  pFieldDesc) = 0;
01350 
01352     virtual llrp_u2_t
01353     get_u2 (
01354       const CFieldDescriptor *  pFieldDesc) = 0;
01355 
01357     virtual llrp_u96_t
01358     get_u96 (
01359       const CFieldDescriptor *  pFieldDesc) = 0;
01360 
01362     virtual llrp_utf8v_t
01363     get_utf8v (
01364       const CFieldDescriptor *  pFieldDesc) = 0;
01365 
01367     virtual llrp_bytesToEnd_t
01368     get_bytesToEnd (
01369       const CFieldDescriptor *  pFieldDesc) = 0;
01370 
01371     /*
01372      * Enumerated types of various sizes
01373      */
01374 
01376     virtual int
01377     get_e1 (
01378       const CFieldDescriptor *  pFieldDesc) = 0;
01379 
01381     virtual int
01382     get_e2 (
01383       const CFieldDescriptor *  pFieldDesc) = 0;
01384 
01386     virtual int
01387     get_e8 (
01388       const CFieldDescriptor *  pFieldDesc) = 0;
01389 
01391     virtual int
01392     get_e16 (
01393       const CFieldDescriptor *  pFieldDesc) = 0;
01394 
01396     virtual int
01397     get_e32 (
01398       const CFieldDescriptor *  pFieldDesc) = 0;
01399 
01401     virtual llrp_u8v_t
01402     get_e8v (
01403       const CFieldDescriptor *  pFieldDesc) = 0;
01404 
01405     /*
01406      * Reserved means some number of bits
01407      */
01408     /* @brief skips a number of reserved bits and discards during the encode/decode process */
01409     virtual void
01410     get_reserved (
01411       unsigned int          nBits) = 0;
01412 };
01413 
01421 class CEncoder
01422 {
01423   public:
01425     CErrorDetails               m_ErrorDetails;
01426 
01428     CEncoder (void);
01429 
01431     virtual
01432     ~CEncoder (void) = 0;
01433 
01435     virtual void
01436     encodeElement (
01437       const CElement *          pElement) = 0;
01438 };
01439 
01447 class CEncoderStream
01448 {
01449   public:
01450     virtual
01451     ~CEncoderStream(void) = 0;
01452 
01457     virtual void
01458     putRequiredSubParameter (
01459       const CParameter *        pParameter,
01460       const CTypeDescriptor *   pRefType) = 0;
01461 
01466     virtual void
01467     putOptionalSubParameter (
01468       const CParameter *        pParameter,
01469       const CTypeDescriptor *   pRefType) = 0;
01470 
01475     virtual void
01476     putRequiredSubParameterList (
01477       const tListOfParameters * pParameterList,
01478       const CTypeDescriptor *   pRefType) = 0;
01479 
01484     virtual void
01485     putOptionalSubParameterList (
01486       const tListOfParameters * pParameterList,
01487       const CTypeDescriptor *   pRefType) = 0;
01488 
01489     /*
01490      * 8-bit types
01491      */
01492 
01497     virtual void
01498     put_u8 (
01499       llrp_u8_t                 Value,
01500       const CFieldDescriptor *  pFieldDesc) = 0;
01501 
01506     virtual void
01507     put_s8 (
01508       llrp_s8_t                 Value,
01509       const CFieldDescriptor *  pFieldDesc) = 0;
01510 
01515     virtual void
01516     put_u8v (
01517       llrp_u8v_t                Value,
01518       const CFieldDescriptor *  pFieldDesc) = 0;
01519 
01524     virtual void
01525     put_s8v (
01526       llrp_s8v_t                Value,
01527       const CFieldDescriptor *  pFieldDesc) = 0;
01528 
01529     /*
01530      * 16-bit types
01531      */
01532 
01537     virtual void
01538     put_u16 (
01539       llrp_u16_t                Value,
01540       const CFieldDescriptor *  pFieldDesc) = 0;
01541 
01546     virtual void
01547     put_s16 (
01548       llrp_s16_t                Value,
01549       const CFieldDescriptor *  pFieldDesc) = 0;
01550 
01555     virtual void
01556     put_u16v (
01557       llrp_u16v_t               Value,
01558       const CFieldDescriptor *  pFieldDesc) = 0;
01559 
01564     virtual void
01565     put_s16v (
01566       llrp_s16v_t               Value,
01567       const CFieldDescriptor *  pFieldDesc) = 0;
01568 
01569     /*
01570      * 32-bit types
01571      */
01572 
01577     virtual void
01578     put_u32 (
01579       llrp_u32_t                Value,
01580       const CFieldDescriptor *  pFieldDesc) = 0;
01581 
01586     virtual void
01587     put_s32 (
01588       llrp_s32_t                Value,
01589       const CFieldDescriptor *  pFieldDesc) = 0;
01590 
01595     virtual void
01596     put_u32v (
01597       llrp_u32v_t               Value,
01598       const CFieldDescriptor *  pFieldDesc) = 0;
01599 
01604     virtual void
01605     put_s32v (
01606       llrp_s32v_t               Value,
01607       const CFieldDescriptor *  pFieldDesc) = 0;
01608 
01609     /*
01610      * 64-bit types
01611      */
01612 
01617     virtual void
01618     put_u64 (
01619       llrp_u64_t                Value,
01620       const CFieldDescriptor *  pFieldDesc) = 0;
01621 
01626     virtual void
01627     put_s64 (
01628       llrp_s64_t                Value,
01629       const CFieldDescriptor *  pFieldDesc) = 0;
01630 
01635     virtual void
01636     put_u64v (
01637       llrp_u64v_t               Value,
01638       const CFieldDescriptor *  pFieldDesc) = 0;
01639 
01644     virtual void
01645     put_s64v (
01646       llrp_s64v_t               Value,
01647       const CFieldDescriptor *  pFieldDesc) = 0;
01648 
01649     /*
01650      * Special types
01651      */
01652 
01657     virtual void
01658     put_u1 (
01659       llrp_u1_t                 Value,
01660       const CFieldDescriptor *  pFieldDesc) = 0;
01661 
01666     virtual void
01667     put_u1v (
01668       llrp_u1v_t                Value,
01669       const CFieldDescriptor *  pFieldDesc) = 0;
01670 
01675     virtual void
01676     put_u2 (
01677       llrp_u2_t                 Value,
01678       const CFieldDescriptor *  pFieldDesc) = 0;
01679 
01684     virtual void
01685     put_u96 (
01686       llrp_u96_t                Value,
01687       const CFieldDescriptor *  pFieldDesc) = 0;
01688 
01693     virtual void
01694     put_utf8v (
01695       llrp_utf8v_t              Value,
01696       const CFieldDescriptor *  pFieldDesc) = 0;
01697 
01702     virtual void
01703     put_bytesToEnd (
01704       llrp_bytesToEnd_t         Value,
01705       const CFieldDescriptor *  pFieldDesc) = 0;
01706 
01707     /*
01708      * Enumerated types of various sizes
01709      */
01710 
01715     virtual void
01716     put_e1 (
01717       int                       eValue,
01718       const CFieldDescriptor *  pFieldDesc) = 0;
01719 
01724     virtual void
01725     put_e2 (
01726       int                       eValue,
01727       const CFieldDescriptor *  pFieldDesc) = 0;
01728 
01733     virtual void
01734     put_e8 (
01735       int                       eValue,
01736       const CFieldDescriptor *  pFieldDesc) = 0;
01737 
01742     virtual void
01743     put_e16 (
01744       int                       eValue,
01745       const CFieldDescriptor *  pFieldDesc) = 0;
01746 
01751     virtual void
01752     put_e32 (
01753       int                       eValue,
01754       const CFieldDescriptor *  pFieldDesc) = 0;
01755 
01760     virtual void
01761     put_e8v (
01762       llrp_u8v_t                Value,
01763       const CFieldDescriptor *  pFieldDesc) = 0;
01764 
01765     /*
01766      * Reserved types are some number of bits
01767      */
01768 
01769     /* @brief skips a number of reserved bits and discards during the encode/decode process */
01770     virtual void
01771     put_reserved (
01772       unsigned int              nBits) = 0;
01773 };
01774 
01775 
01776 /*
01777 ** @brief Encodes a CElement into an XML string
01778 **
01779 ** @param[in]  pElement      The CElement to encode to XML
01780 ** @param[out] pBuffer       The pointer to the buffer in which to place the XML result
01781 ** @param[in]  nBuffer       The size of the buffer available to hold the XML
01782 **
01783 ** @return EResultCode Result code from the operation
01784 */
01785 extern EResultCode
01786 toXMLString (
01787   const CElement *              pElement,
01788   char *                        pBuffer,
01789   int                           nBuffer);
01790 
01791 }; /* namespace LLRP */