VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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::

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)