VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVrlinkDataInterMarshaller.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <vlutil/vlPrint.h>
15 #include <vl/datumRecordSet.h>
16 
17 namespace vrvControlToolkit
18 {
19 
23 template<class DataMsg>
25 {
26 public:
29 
31  virtual void encode(DtVrvControl_v1* cmd, DataMsg* msg);
32 
38  virtual DtVrvControl_v1* decode(const DataMsg* msg);
39 
40 protected:
41 
42 };
43 
44 
45 
46 template<class DataMsg>
48 {
49 
50 }
51 
52 template<class DataMsg>
54 {
55 
56 }
57 
58 template<class DataMsg>
60 {
61  DtDatumRetCode ret;
62 
63  //setup the var field
64  msg->setNumVarFields(1);
65 
66  //odd that these start their indexes at 1
67  msg->setDatumParam(DtVar, 1, (DtDatumParam)DtVrvControlDatumParamId);
68  msg->setVarDataBytes(1, cmd->mySize, &ret);
69  msg->setDatumValByteArray(DtVar, 1, (char*)cmd, &ret);
70 }
71 
72 template<class DataMsg>
74 {
75  DtDatumRetCode ret;
76  DtDatumRecordType type;
77  int index;
78  int size;
79 
80  msg->getIndex((DtDatumParam)DtVrvControlDatumParamId, &type, &index, &ret);
81  if(ret!=DtDatumValid)
82  {
83  return NULL;
84  }
85 
86  //actually get the data out of the pdu/interaction
87  size=msg->datumSizeBytes(type, index);
88  const char* buffer=msg->datumValByteArray(type, index);
89 
90  //create some memory
91  char* cmdBuffer=new char[size];
92 
93  //copy message to buffer;
94  memcpy(cmdBuffer, buffer, size);
95 
96  //cast a control structure
97  DtVrvControl_v1* cmd=(DtVrvControl_v1*)cmdBuffer;
98 
99  //check magic number for endiness
101  {
102  delete [] cmdBuffer;
103  return NULL;
104  }
105 
106  return cmd;
107 }
108 
109 } //vrvControlToolkit::
voidpf void uLong size
Definition: ioapi.h:39
DtUInt32 myMagicNumber
Bit pattern that indicates that this is a view control packet.
Definition: vrvControlToolkitDataTypes.h:246
const DtUInt32 DtVrvMagicNumber
Definition: vrvControlToolkitDataTypes.h:23
const DtUInt32 DtVrvControlDatumParamId
Definition: vrvControlToolkitDataTypes.h:20
Base structure for all controls.
Definition: vrvControlToolkitDataTypes.h:242
DtUInt16 mySize
The total size of the VC packet, including this header This will be filled in by the specific view co...
Definition: vrvControlToolkitDataTypes.h:250
Contains vrvControlToolkit control structures and defines.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)