VR-Link API Documentation for HLA 1.3
interDecoder.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00005 
00008 
00009 #ifndef DtInteractionDecoder_H_
00010 #define DtInteractionDecoder_H_
00011 
00012 #if DtHLA 
00013 
00014 
00015 #include <vlutil/vlMachineTypes.h>
00016 #include <vlutil/vlPrint.h>
00017 #include <vlpi/bufferMgr.h>
00018 
00019 #include "rtiNamespace.h"
00020 #include "rtiCompatibility.h"
00021 #include <map>
00022 
00023 class DT_DLL_VL DtExerciseConn;
00024 class DT_DLL_VL DtInterClassDesc;
00025 
00030 class DT_DLL_VL DtInteractionRep;
00031 
00032 
00036 class DT_DLL_VL DtInteractionDecoder
00037 {
00038 public:
00039 
00041    typedef void (*DtParameterDecoder)(DtInteractionRep* inter,
00042       const RTI::ParameterHandleValuePairSet& pvlist,
00043       int i);
00044 
00045 public:
00046 
00048    DtInteractionDecoder(DtExerciseConn* exConn,
00049       DtInterClassDesc* classDesc);
00050 
00052    virtual ~DtInteractionDecoder();
00053 
00059    DtParameterDecoder addDecoder(RTI::ParameterHandle handle,
00060       DtParameterDecoder proc);
00061 
00067    DtParameterDecoder addDecoder(char* name,
00068       DtParameterDecoder proc);
00069 
00071    virtual DtParameterDecoder decoder(RTI::ParameterHandle handle) const;
00072 
00074    virtual void decode(
00075       DtInteractionRep* interaction,
00076 #if DtHLA_1516
00077       const RTI::ParameterHandleValueMap& pvMap
00078 #else
00079       const RTI::ParameterHandleValuePairSet& pvList
00080 #endif
00081       );
00082 
00084    virtual RTI::InteractionClassHandle interactionClassHandle();
00085 
00087    virtual DtInteractionDecoder* clone() const;
00088 
00093    virtual DtInteractionDecoder* clone(DtInterClassDesc* interDesc) const;
00094 
00095 public:
00096 
00101    static char* decodingBuffer(int length);
00102 
00103 protected:
00104 
00106    DtInteractionDecoder(const DtInteractionDecoder& orig);
00107 
00109    DtInteractionDecoder& operator=(const DtInteractionDecoder& orig);
00110 
00112    virtual void decodeParameter(DtInteractionRep* inter,
00113       const RTI::ParameterHandleValuePairSet& pvList, int index);
00114 
00115 protected:
00116 
00117    DtExerciseConn* myExConn;
00118    DtInterClassDesc* myClassDesc;
00119 
00120    RTI::InteractionClassHandle myClassHandle;
00121 
00123    std::map<RTI::ParameterHandle, DtParameterDecoder> myList;
00124 
00125 };
00126 
00127 inline RTI::InteractionClassHandle 
00128    DtInteractionDecoder::interactionClassHandle() 
00129 {
00130    return myClassHandle;
00131 }
00132 
00133 inline char* DtInteractionDecoder::decodingBuffer(int length)
00134 {
00135    return DtDecodingBuffer(length);
00136 }
00137 
00138 
00141 #define DtADD_PARAM_DECODER(attrName) \
00142    addDecoder((char *)#attrName, (DtParameterDecoder) decode##attrName)
00143 
00146 #define DtDECLARE_PARAM_DECODER(RepT, paramName) \
00147    static void decode##paramName(RepT* inter, \
00148       const RTI::ParameterHandleValuePairSet& params, int pairSetIndex)
00149 
00150 #define DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
00151    paramName, netType, mutator, castExpr) \
00152 void decClass::decode##paramName(interClass* inter, \
00153    const RTI::ParameterHandleValuePairSet& params, \
00154    int index) \
00155 { \
00156    RTI::ULong length = params.getValueLength(index); \
00157    if (length > sizeof(netType)) \
00158    { \
00159       DtWarn("Size of value decoded for parameter %s (%d)\n", \
00160          #paramName, length); \
00161       DtWarn(" is larger than size of %s (%d)\n", #netType, sizeof(netType)); \
00162       return; \
00163    } \
00164    netType netVal; \
00165    params.getValue(index, (char*) &netVal, length); \
00166    inter->mutator(castExpr netVal); \
00167 }
00168 
00169 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_PARAM_DECODER( \
00170    decClass, interClass, paramName, mutator) \
00171 void decClass::decode##paramName(interClass* inter, \
00172    const RTI::ParameterHandleValuePairSet& params, \
00173    int index) \
00174 { \
00175    RTI::ULong length = 0; \
00176    DtGlobalObjectDesignator objName = \
00177       (char*) params.getValuePointer(index, length); \
00178    inter->mutator(objName); \
00179 }
00180 
00181 
00182 #define DtDEFINE_SIMPLE_PARAM_DECODER(decClass, interClass, \
00183                                       paramName, netType, mutator) \
00184    DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
00185       paramName, netType, mutator, (netType))
00186 
00187 #endif
00188 #endif
00189 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)