VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtVrvControlMessageMarshaller_v0.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
12 
13 #include <vlutil/vlPrint.h>
14 
15 namespace vrvControlToolkit
16 {
17 
18  template<class DataMsg>
20  {
21  public:
23 
25 
26  virtual void encode(DtVrvControl_v0* cmd, DataMsg* msg);
27  virtual DtVrvControl_v0* decode(const DataMsg* msg);
28 
29  protected:
30 
31  };
32 
33 
34 
35  template<class DataMsg>
37  {
38 
39  }
40 
41  template<class DataMsg>
43  {
44 
45  }
46 
47  template<class DataMsg>
49  {
50  DtDatumRetCode ret;
51  int size=cmd->bufferSize();
52 
53  //serialize to a buffer
54  char* buffer=new char[size];
55  cmd->encode(buffer);
56 
57  //setup the var field
58  msg->setNumVarFields(1);
59 
60  //odd that these start their indexes at 1
61  msg->setDatumParam(DtVar, 1, (DtDatumParam)DtVrvDatumParamId_v0);
62  msg->setVarDataBytes(1, size, &ret);
63  msg->setDatumValByteArray(DtVar, 1, buffer, &ret);
64 
65  delete [] buffer;
66  }
67 
68  template<class DataMsg>
70  {
71  DtDatumRetCode ret;
72  DtDatumRecordType type;
73  int index;
74  int size;
75 
76  msg->getIndex((DtDatumParam)DtVrvDatumParamId_v0, &type, &index, &ret);
77  if(ret!=DtDatumValid)
78  {
79  return NULL;
80  }
81 
82  //actually get the data out of the pdu/interaction
83  size=msg->datumSizeBytes(type, index);
84  const char* buffer=msg->datumValByteArray(type, index);
86 
87  return cmd;
88 
89  }
90 
91 } //vrvControlToolkit::

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)