VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
registerExtendedAttributeClassesDIS.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2017 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 
10 #pragma once
11 
12 #ifdef DtDIS
13 
17 #include <vl/aggregatePublisher.h>
18 
19 #define DtALMOST(x, y, e) (((x)<=((y)+(e))) && ((x)>=((y)-(e))))
20 
21 namespace makVrfVrlinkExtToolkit
22 {
28  template <typename StateRepType, typename PublisherType, typename ReflectedObjType>
29  void registerExtendedAttributeClasses(DtExerciseConn* exConn)
30  {
31  // Do not reregister if already done. Need to check if this is the same exConn as last time
32  // to handle the case of disconnect/reconnect. Unfortunately sometimes the memory address is
33  // reused, so we can't simply check that. Instead use the exConn's clock to check the time
34  // the exConn was initialized.
35  static DtTime prevExConnInitTime = -1.0;
36  DtTime exConnInitTime = exConn->clock()->absRealTime() - exConn->clock()->elapsedRealTime();
37  if (DtALMOST(prevExConnInitTime, exConnInitTime, 0.0001))
38  {
39  // Already registered
40  return;
41  }
42 
43  // Set the state repository creators
44  PublisherType::setStateRepCreator((typename PublisherType::DtStateRepCreator)
45  StateRepType::create);
46  ReflectedObjType::setStateRepCreator((typename ReflectedObjType::DtStateRepCreator)
47  StateRepType::create);
48 
49  // Set the variable record factory
50  if (!dynamic_cast<DtVrfVariableRecordFactory*>(exConn->pduFactory()->standardVariableRecordFactory()))
51  {
52  // Already registered
54  exConn->pduFactory()->setStandardVariableRecordFactory(new DtVrfVariableRecordFactory);
55  delete oldFactory;
56  }
57 
58  prevExConnInitTime = exConnInitTime;
59  }
60 }
61 
62 #endif
Contains the DtExtendedAttributeVariableRecord class declaration.
#define DtALMOST(x, y, e)
Definition: registerExtendedAttributeClassesDIS.h:19
Contains the DtVrfVariableRecordFactory class declaration.

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)