WebLVC 1.7d API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rprTranslator.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2016 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 // Disable warning about missing operators.
13 // Comparison and assignment operators are declared but not defined
14 // to prevent their usage, but this causes a warning in template classes.
15 #pragma warning( disable : 4661 )
16 
17 #include <rprBroker/dllExport.h>
19 
22 
25 
26 // All RPR Translators must have the following template arguments:
27 // The integer define of the DtPortalMessageKind,
28 // The PortalObject this message translates,
29 // The Reflected Portal Object class the message translates
30 // The Reflected RPR Object class
31 // The reflected list of objects
32 // The state repository class of the RPR Object
33 // The publisher class of the RPR Object
34 #define RPR_TEMPLATE_LIST \
35  template \
36  < class T_PortalObject \
37  , class T_PortalReflectedObject \
38  , class T_RprReflectedObject \
39  , class T_RprReflectedObjectList \
40  , class T_RprObjectStateRepository \
41  , class T_RprObjectPublisher>
42 
43 #define RPR_TEMPLATE_FUNCTION \
44  T_PortalObject, T_PortalReflectedObject, \
45  T_RprReflectedObject, T_RprReflectedObjectList, \
46  T_RprObjectStateRepository, T_RprObjectPublisher
47 
49 #define DtVrxCATCH_AND_WARN( exception ) \
50  catch ( exception ) \
51  { \
52  DtWarn << this->name() << " Translator caught " << #exception \
53  << " when sending interaction." << std::endl; \
54  }
55 
56 class DtInteraction;
57 class DtReflectedObject;
58 class DtStateRepository;
59 
60 namespace MAKVrExchange
61 {
62 
63  class DtRequestTranslationDiagnosticMessage;
64 
65  namespace DtRprBroker
66  {
67 
68  class DtRprBroker;
69 
94  : public DtBaseObjectTranslator<T_PortalObject,T_PortalReflectedObject>
95  {
96  public:
97 
99  typedef enum
100  {
101  none = 0,
102  discover = 1,
103  update = 2,
104  remove = 3
105  } UpdateType;
106 
109 
110  public:
111 
114  const DtString& name, DtPortalMessageKind kind );
115 
117  virtual ~DtRprObjectTranslator();
118 
120  virtual void enableReflectTranslator( bool enabled );
121 
124  virtual void forceUpdateAll();
125 
127  virtual void tick();
128 
129  virtual DtRprBroker* rprBroker();
130  virtual const DtRprBroker* rprBroker() const;
131 
133  virtual void shutdown();
134 
135  protected:
136 
139 
140  virtual void initializeRprCallbacks();
141  virtual void removeRprCallbacks();
142 
144 
147 
149  virtual DtBrokerObject* createBrokerObject( const DtReflectedObject* refObj );
151 
154  virtual DtBrokerObject* findBrokerObject( const DtReflectedObject* refObj );
155  virtual DtBrokerObject* findBrokerObject( const DtPortalReflectedObject* refObj );
156 
159  virtual DtBrokerObject* findBrokerObject( const DtString& objectName );
160 
164  virtual DtBrokerObject* releaseBrokerObject( const DtReflectedObject* refObj );
166 
168 
171 
174  static bool rprDiscoveryCriteria( DtReflectedObject* refObj, void* usr );
175 
177  static void rprObjectAddedCb( T_RprReflectedObject* refObj, void* usr );
178 
180  static void rprObjectUpdatedCb( T_RprReflectedObject* refObj, void* usr );
181 
183  static void rprObjectDeletedCb( T_RprReflectedObject* refObj, void* usr );
184 
186 
189 
192  virtual bool isPortalDiscoverable( const DtPortalReflectedObject* refObj );
193 
196  virtual bool isRprPublishable( DtBrokerObject* brokerObj,
197  const T_PortalReflectedObject* refObj );
198 
200 
203 
206  virtual bool isRprDiscoverable( const DtReflectedObject* refObj );
207 
209 
218 
219  virtual void discoverRprObject( T_RprReflectedObject& obj );
220  virtual void discoverPortalObject( const T_PortalReflectedObject& obj );
221 
223 
231 
232  virtual void createRprPublisher( DtBrokerObject* brokerObj );
233 
239  virtual DtString rprObjectName( const T_PortalReflectedObject* refObj ) const;
240 
249  virtual T_RprObjectPublisher* instantiateRprPublisher(
250  const T_PortalReflectedObject* refObj, const DtString& name );
251 
257  virtual void fillOutgoingIds( T_RprObjectPublisher* publisher,
258  const DtString& name );
259 
260  virtual void createPortalPublisher( DtBrokerObject* brokerObj );
261 
263 
272 
273  virtual void receiveRprUpdate( T_RprReflectedObject& obj );
274  virtual void receivePortalUpdate( const T_PortalReflectedObject& obj );
275 
277 
286 
287  virtual void updateRprBrokerObject( DtBrokerObject* brokerObj,
288  const T_RprObjectStateRepository& sr );
289  virtual void updatePortalBrokerObject( DtBrokerObject* brokerObj,
290  const T_PortalObject& sr );
291 
300  virtual void updateFilteredState( DtBrokerObject* brokerObj,
302  T_RprReflectedObject* refObj );
303 
307  virtual void updateFilteredState( DtBrokerObject* brokerObj,
308  const T_PortalReflectedObject* refObj );
309 
314  virtual bool filterLocation( const DtReflectedObject& refObj,
315  const DtVector& location );
316 
318  virtual bool filterLocation( const DtPortalReflectedObject& refObj,
319  const DtVector& location );
320 
322 
326 
327  virtual void removeRprObject( const DtReflectedObject& refObj );
328  virtual void removePortalObject( const T_PortalReflectedObject& refObj );
329 
331 
336 
337  virtual void deleteRprPublisher( DtBrokerObject* brokerObj );
338  virtual void deletePortalPublisher( DtBrokerObject* brokerObj );
339 
341 
343  static void requestTransDiagCb( const DtRequestTranslationDiagnosticMessage& msg, void* usr );
344 
347 
349  virtual void printIncomingOutgoingStateReps(
350  const DtPortalObject& incoming, const DtStateRepository& outgoing ) const;
351 
353  virtual void printIncomingOutgoingStateReps(
354  const DtStateRepository& incoming, const DtPortalObject& outgoing ) const;
355 
359  virtual void performPortalDebugging( const DtString& objectName );
360 
362  virtual void performPortalDebugging( const DtPortalObject& incoming,
363  const DtStateRepository& outgoing );
364 
366  virtual void performPortalDebugging( const DtStateRepository& incoming,
367  const DtPortalObject& outgoing );
368 
370  virtual unsigned int numObjects() const;
371 
372  public:
373 
376  virtual T_PortalObject* translate( T_PortalObject* destination,
377  const T_RprObjectStateRepository& source,
378  const T_RprReflectedObject& refObj ) = 0;
379 
382  virtual T_RprObjectStateRepository* translate(
383  T_RprObjectStateRepository* destination, const T_PortalObject& source,
384  const T_PortalReflectedObject& refObj ) = 0;
385 
386  private:
387 
390 
393 
395  bool operator == ( const DtRprObjectTranslator& rightOperand ) const;
396 
398  bool operator != ( const DtRprObjectTranslator& rightOperand ) const;
399 
400  protected:
401 
402  T_RprReflectedObjectList* myRprReflectedList;
403 
404  typedef std::pair<DtTime,bool> LocationFilteringInfo;
405  typedef std::map<const DtReflectedObject*,LocationFilteringInfo> LocationFilteringMap;
407 
408  typedef std::map<const DtReflectedObject*,DtBrokerObject*> RprToPortalReflectedMap;
409  typedef std::map<const DtPortalReflectedObject*,DtBrokerObject*> PortalToRprReflectedMap;
410 
413 
414  typedef std::set<DtString> TransDebugObjectNamesSet;
416 
418 
419  };
420 
421 
438  template <class PortalInterType,class RprInterType>
440  : public DtBaseInteractionTranslator<PortalInterType>
441  {
442  public:
443 
446 
447  public:
448 
451  const DtString& name, DtPortalMessageKind kind );
452 
454  virtual ~DtRprInteractionTranslator();
455 
457  virtual void enableReflectTranslator( bool enabled );
458 
459  virtual DtRprBroker* rprBroker();
460  virtual const DtRprBroker* rprBroker() const;
461 
463  virtual void shutdown();
464 
465  protected:
466 
469 
470  virtual void initializeRprCallbacks();
471  virtual void removeRprCallbacks();
472 
474 
478 
479  static void receiveRprInteraction( RprInterType* inter, void* usr );
480 
482 
490 
491  virtual void createInteraction( const PortalInterType& inter );
492  virtual void createPortalInteraction( const RprInterType& inter );
493 
495 
498  virtual PortalInterType* translate( PortalInterType* destination,
499  const RprInterType& source ) = 0;
500 
503  virtual RprInterType* translate( RprInterType* destination,
504  const PortalInterType& source ) = 0;
505 
507  virtual void printIncomingOutgoingInteractions( const DtPortalInteraction& incoming,
508  const DtInteraction& outgoing ) const;
509 
511  virtual void printIncomingOutgoingInteractions( const DtInteraction& incoming,
512  const DtPortalInteraction& outgoing ) const;
513 
514  private:
515 
518 
521 
523  bool operator == ( const DtRprInteractionTranslator& rightOperand ) const;
524 
526  bool operator != ( const DtRprInteractionTranslator& rightOperand ) const;
527 
528  };
529 
530  }
531 }
532 
533 #define _rprTranslator_INL_
534 #include <rprBroker/rprTranslator.inl>
535 #undef _rprTranslator_INL_
static void rprObjectDeletedCb(T_RprReflectedObject *refObj, void *usr)
Callback called when an object in the reflected list is deleted.
Contains the templated DtPortalReflectedObjectManager types.
Base class for all RPR interaction translators.
Definition: rprTranslator.h:439
virtual DtBrokerObject * findBrokerObject(const DtReflectedObject *refObj)
Find the broker object for the given reflected object.
std::map< const DtReflectedObject *, DtBrokerObject * > RprToPortalReflectedMap
Definition: rprTranslator.h:408
virtual void createRprPublisher(DtBrokerObject *brokerObj)
Determines the name to use for the given reflected object.
Used to request that brokers send translation diagnostic reports.
Definition: requestTransDiagnosticMessage.h:21
DtRprInteractionTranslator(DtBroker *broker, const DtString &name, DtPortalMessageKind kind)
CTOR.
virtual void createPortalPublisher(DtBrokerObject *brokerObj)
Determines the name to use for the given reflected object.
virtual void discoverRprObject(T_RprReflectedObject &obj)
virtual void createPortalInteraction(const RprInterType &inter)
bool operator!=(const DtRprObjectTranslator &rightOperand) const
Private Comparison Operator (Not implemented – Do Not Compare).
Provides container to hold pointers to Protocol/Portal objects.
Definition: brokerObject.h:24
DtRprInteractionTranslator< PortalInterType, RprInterType > ParentClass
Typedef for the templated class type.
Definition: rprTranslator.h:445
virtual void shutdown()
Performs any virtual shutdown logic prior to deletion.
static bool rprDiscoveryCriteria(DtReflectedObject *refObj, void *usr)
The RPR reflected list&#39;s discovery condition callback.
#define RPR_TEMPLATE_LIST
Definition: rprTranslator.h:34
TransDebugObjectNamesSet myTransDebugNames
Definition: rprTranslator.h:415
UpdateType
Enums used with the ObjectAction callback.
Definition: rprTranslator.h:99
virtual DtBrokerObject * createBrokerObject(const DtReflectedObject *refObj)
Creates a broker object for the given reflected object.
virtual void deletePortalPublisher(DtBrokerObject *brokerObj)
DtPortalObject are messages which also serve as state repositories for simulated objects.
Definition: pObject.h:23
Implements a DtBroker for the HLA Protocol.
Definition: rprBroker.h:36
virtual void updateRprBrokerObject(DtBrokerObject *brokerObj, const T_RprObjectStateRepository &sr)
Ensures the given object is properly filtered.
bool operator==(const DtRprObjectTranslator &rightOperand) const
Private Comparison Operator (Not implemented – Do Not Compare).
LocationFilteringMap myLocationFilteringMap
Definition: rprTranslator.h:406
A simple template class to hold different types of State Repositories.
Definition: pObjectPublisher.h:68
virtual PortalInterType * translate(PortalInterType *destination, const RprInterType &source)=0
Translates the given RPR interaction to a Portal interaction (abstract).
virtual void shutdown()
Performs any virtual shutdown logic prior to deletion.
DtBaseInteractionTranslator are responsible for translating messages for things that do not have stat...
Definition: baseInteractionTranslator.h:60
std::pair< DtTime, bool > LocationFilteringInfo
Definition: rprTranslator.h:404
An abstract interface for reflected objects.
Definition: pReflectedObject.h:31
DtBroker * broker() const
Broker Accessor.
Definition: translator.h:80
DtPortalInteractions are a special type of DtPortalMessages which are used to transmit simulation dat...
Definition: pInteraction.h:21
virtual void removeRprObject(const DtReflectedObject &refObj)
Base class for all RPR object translators.
Definition: rprTranslator.h:93
Contains the DtInteractionTranslator and DtBaseInteractionTranslator class declarations.
bool operator==(const DtRprInteractionTranslator &rightOperand) const
Private Comparison Operator (Not implemented – Do Not Compare).
virtual DtBrokerObject * releaseBrokerObject(const DtReflectedObject *refObj)
Find the broker object for the given reflected object.
std::map< const DtPortalReflectedObject *, DtBrokerObject * > PortalToRprReflectedMap
Definition: rprTranslator.h:409
virtual T_RprObjectPublisher * instantiateRprPublisher(const T_PortalReflectedObject *refObj, const DtString &name)
Instantiates the publisher for the given reflected object.
virtual void updateFilteredState(DtBrokerObject *brokerObj, DtPortalObjectPublisherTemplate< T_PortalObject > *publisher, T_RprReflectedObject *refObj)
Ensures the given object is properly filtered.
virtual void performPortalDebugging(const DtString &objectName)
Build and send debugging message for GUI debugging.
PortalToRprReflectedMap myRprPublisherMap
Definition: rprTranslator.h:412
virtual void enableReflectTranslator(bool enabled)
Enables or disables the translator reflecting from RPR.
T_RprReflectedObjectList * myRprReflectedList
Definition: rprTranslator.h:402
Definition: objectHeartbeater.h:24
virtual void deleteRprPublisher(DtBrokerObject *brokerObj)
virtual void fillOutgoingIds(T_RprObjectPublisher *publisher, const DtString &name)
Sets the publisher&#39;s outgoing entity IDs.
static void receiveRprInteraction(RprInterType *inter, void *usr)
Base class for all broker objects.
Definition: broker.h:58
DtBaseObjectTranslators provide common logic for translating objects.
Definition: baseObjectTranslator.h:106
virtual void updatePortalBrokerObject(DtBrokerObject *brokerObj, const T_PortalObject &sr)
Ensures the given object is properly filtered.
virtual bool isPortalDiscoverable(const DtPortalReflectedObject *refObj)
Creates broker object for reflected Portal object.
virtual void printIncomingOutgoingInteractions(const DtPortalInteraction &incoming, const DtInteraction &outgoing) const
Prints incoming and outgoing interactions (before and after translation) to DtInfo.
virtual void tick()
Ticks the publishers for the translated RPR and Portal objects.
bool operator!=(const DtRprInteractionTranslator &rightOperand) const
Private Comparison Operator (Not implemented – Do Not Compare).
Contains the DtObjectTranslator and DtBaseObjectTranslator class declarations.
DtObjectHeartbeater myHeartbeater
Definition: rprTranslator.h:417
DtRprObjectTranslator & operator=(const DtRprObjectTranslator &other)
Private Assignment Operator (Not implemented – Do Not Copy).
virtual T_PortalObject * translate(T_PortalObject *destination, const T_RprObjectStateRepository &source, const T_RprReflectedObject &refObj)=0
Translates the given RPR object to a Portal object (abstract).
DtRprInteractionTranslator & operator=(const DtRprInteractionTranslator &other)
Private Assignment Operator (Not implemented – Do Not Copy).
DtRprObjectTranslator< RPR_TEMPLATE_FUNCTION > ParentClass
Typedef for the templated class type.
Definition: rprTranslator.h:108
virtual bool filterLocation(const DtReflectedObject &refObj, const DtVector &location)
Checks location filtering and returns the filtered state.
Template Instances of DtPortalObjectPublisherTemplate.
Contains the DtObjectHeartbeater class declaration.
DtRprObjectTranslator(DtBroker *broker, const DtString &name, DtPortalMessageKind kind)
CTOR.
virtual bool isRprDiscoverable(const DtReflectedObject *refObj)
Creates broker object for reflected RPR object.
virtual void discoverPortalObject(const T_PortalReflectedObject &obj)
virtual void forceUpdateAll()
Tells all publishers to send an update next tick.
virtual void receivePortalUpdate(const T_PortalReflectedObject &obj)
virtual void createInteraction(const PortalInterType &inter)
This function is required for a translator to correctly publish objects from the portal to your proto...
virtual void receiveRprUpdate(T_RprReflectedObject &obj)
static void rprObjectAddedCb(T_RprReflectedObject *refObj, void *usr)
Callback called when an object is added to the reflected list.
static void rprObjectUpdatedCb(T_RprReflectedObject *refObj, void *usr)
Callback called when an object in the reflected list is updated.
virtual DtString rprObjectName(const T_PortalReflectedObject *refObj) const
Determines the name to use for the given reflected object.
DtPortalMessageKind
A List of message kinds distributed with the Portal.
Definition: pMessageKinds.h:23
static void requestTransDiagCb(const DtRequestTranslationDiagnosticMessage &msg, void *usr)
Static translation diagnostic request callback.
std::map< const DtReflectedObject *, LocationFilteringInfo > LocationFilteringMap
Definition: rprTranslator.h:405
virtual void removePortalObject(const T_PortalReflectedObject &refObj)
RprToPortalReflectedMap myPortalPublisherMap
Definition: rprTranslator.h:411
virtual bool isRprPublishable(DtBrokerObject *brokerObj, const T_PortalReflectedObject *refObj)
Tests whether the object is publishable as a RPR object.
virtual void printIncomingOutgoingStateReps(const DtPortalObject &incoming, const DtStateRepository &outgoing) const
Print debug info for the given state reps.
std::set< DtString > TransDebugObjectNamesSet
Definition: rprTranslator.h:414
virtual unsigned int numObjects() const
Returns the current number of objects.
This callback is regarding an object Discovery.
Definition: rprTranslator.h:103
virtual void enableReflectTranslator(bool enabled)
Enables or disables the translator reflecting objects from RPR.
virtual DtString name() const
Accessor for the translator&#39;s name.

Document ID: Generated on Wed Jun 21 15:05:44 EDT 2023 from SVN revision 256253
Copyright © 2005-2023 MAK Technologies. All Rights Reserved (www.mak.com)