VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
localExtendedPropertiesNetInterface.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #ifdef DtHLA
14 
16 #include "vrfobjcore/vrfObject.h"
22 
23 
26 template <typename BaseNetInterface, typename BaseStateRepository>
28 {
29 protected:
30 
34  , myLastEncodeTime(0)
35  {
36  myClock.init();
37  }
38 
39 public:
40 
42 
45  DtVrfObject* vrfObject,
46  DtReaderWriterRegistry* parentRegistry = 0,
47  bool publishObject = true)
48  : BaseNetInterface(name, vrfObject, parentRegistry, publishObject)
49  , myLastEncodeTime(0)
50  {
51  myClock.init();
52  }
53 
57  DtReaderWriterRegistry * parentRegistry = 0)
58  : BaseNetInterface(orig)
59  , myLastEncodeTime(0)
60  {
61  myClock.init();
62  }
63 
65  const DtLocalExtendedPropertiesNetInterface & operator=(const
67  {
68  return static_cast<const DtLocalExtendedPropertiesNetInterface&>(
69  BaseNetInterface::operator=(orig));
70  }
71 
74 
77  virtual void updatePublisher()
78  {
79  BaseNetInterface::updatePublisher();
80  encodePropertyAttributes();
81  }
82 
84  virtual bool encodePropertyAttributes()
85  {
89  DtVrfObjectStateRepository* localState = this->mySimObject->vrfState();
90 
91  encodeProperties(localState->parameterProperties());
92  encodeProperties(localState->stateProperties());
93 
94  myLastEncodeTime = myClock.absRealTime();
95 
96  return true;
97  }
98 
100  virtual void encodeProperties(const DtRwVariableBindings& properties)
101  {
103  dynamic_cast<DtExtendedPropertiesStateRepository*>(this->myNetworkState);
104 
105  if (netWithProps)
106  {
107  std::vector<DtReaderWriterRegistryData *>::const_iterator iter =
108  properties.registry().registryData().begin();
109  std::vector<DtReaderWriterRegistryData *>::const_iterator endIter =
110  properties.registry().registryData().end();
111  for(; iter != endIter; ++iter)
112  {
113  if ((*iter)->readerWriter()->wasUpdatedSince(myLastEncodeTime) &&
114  netWithProps->publishesAttribute((*iter)->keyword().c_str()))
115  {
116  const DtPropertyInterface* pFace = (*iter)->readerWriter()->property();
117 
118  if (pFace)
119  {
120  int size = pFace->getSize();
121 
122  if (size != 0)
123  {
124  myPropertyBuffer.resize(size);
125  if(myPropertyBuffer.size())
126  {
127  pFace->encode(&myPropertyBuffer[0]);
128  netWithProps->setAttributeByName(
129  (*iter)->keyword().c_str(), &myPropertyBuffer[0], myPropertyBuffer.size());
130  }
131  }
132  }
133  }
134  }
135  }
136  }
137 
138  static DtSimObjectNetInterface * creator(const DtString & name,
139  DtVrfObject* vrfObject,
140  DtReaderWriterRegistry* parentRegistry,
141  bool publishObject)
142  {
144  parentRegistry, publishObject);
145  }
146 
147 protected:
148 
149  std::vector<char> myPropertyBuffer;
152 };
153 
154 #endif

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)